As not all the entry I need fit into my window I search who to make a scrolbar and there https://www.google.com/search?q=python+tkinter+scrollbar&oq=python+tkinter+srollba&gs_lcrp=EgZjaHJvbWUqCQgBEAAYDRiABDIGCAAQRRg5MgkIARAAGA0YgAQyCAgCEAAYDRgeMggIAxAAGA0YHjIICAQQABgNGB4yCAgFEAAYDRgeMggIBhAAGA0YHjIICAcQABgNGB4yCAgIEAAYDRgeMggICRAAGA0YHtIBCTE0NjczajBqNKgCALACAQ&sourceid=chrome&ie=UTF-8#fpstate=ive&vld=cid:d4ee0d36,vid:0WafQCaok6g,st:0 I foud the following code
from tkinter import *
from tkinter import ttk
root = Tk()
root.title("CAN Node Config")
root.geometry('500x400')
# Create a Main Frame
main_frame = Frame(root)
main_frame.pack(fill=BOTH, expand=1)
# Create a Canvas
my_canvas=Canvas(main_frame)
my_canvas.pack(side=LEFT, fill=BOTH, expand=1)
# Add A Scrollbar To The Canvas
my_scrollbar=ttk.Scrollbar(main_frame,orient=VERTICAL,command=my_canvas.yview)
my_scrollbar.pack(side=RIGHT, fill=Y)
#Configute The canvas
my_canvas.configure(yscrollcommand=my_scrollbar.set)
my_canvas.bind('<configure>', lambda e: my_canvas.configure(scrollregion = my_canvas.bbox("all")))
# Create Another Frame Inside The Canvas
second_frame=Frame(my_canvas)
# Add that New Frame to a Windows In The Canvas
my_canvas.create_window((0,0),window=second_frame,anchor="nw")
for thing in range(100):
Button(second_frame,text=f'Button {thing} 0!').grid(row=thing,column=0,pady=5,padx=5)
root.mainloop()
before implementing this to my code i would try ist itself
but get the following error
Traceback (most recent call last):
File "/Users/mk/PycharmProjects/pythonCAN_Config_1/test.py", line 23, in <module>
my_canvas.bind('<configure>', lambda e: my_canvas.configure(scrollregion = my_canvas.bbox("all")))
File "/usr/local/Cellar/python@3.9/3.9.19_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/tkinter/__init__.py", line 1392, in bind
return self._bind(('bind', self._w), sequence, func, add)
File "/usr/local/Cellar/python@3.9/3.9.19_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/tkinter/__init__.py", line 1346, in _bind
self.tk.call(what + (sequence, cmd))
_tkinter.TclError: bad event type or keysym "configure"
I double checked but can not figure out whats wrong
In the past I saw a lot of Videos from this author they all worked and I learned al lot of him, but now I am helpless
Regards
Rainer