'How to make whole Tkinter window scrollable
I am working on a GUI and have added some labelframes which barely fits the window. I want to add a menubar so after adding it, the last labelframe does not fit the window. Hence I want to make it scrollable. I tried many solutions on internet but still not able to scroll.
Here is the code. Not sending all label frames code since one will give the idea.
self.window = Tk()
self.color = 'dark orange'
self.window.geometry('640x720')
self.window.resizable(False, False)
self.window.configure(background=self.color)
self.window.title('Classify')
#self.window.iconbitmap('py.ico')
self.frame = Frame(self.window)
self.frame.pack(expand=True, fill=BOTH)
self.canvas = Canvas(self.frame,background='dark orange')
self.v_scroll = Scrollbar(self.frame, orient=VERTICAL, command=self.canvas.yview,background='black',activebackground='black')
self.v_scroll.pack(side=RIGHT,fill=Y)
self.canvas['yscrollcommand'] = self.v_scroll.set
self.canvas.pack(expand=True, fill=BOTH)
self.frame2 = Frame(self.canvas,bg='dark orange')
self.canvas.create_window((0, 0), window=self.frame2, anchor=N + W)
self.menubar = Menu(self.frame2)
# Adding File Menu and commands
self.file = Menu(self.menubar, tearoff = 0)
self.menubar.add_cascade(label ='File', menu = self.file)
self.file.add_command(label ='New File', command = None)
self.window.config(menu = self.menubar)
self.frame = LabelFrame(self.canvas, text='File Selection', bg=self.color)
self.frame.place(width=580, height=80, bordermode=OUTSIDE, x=20,y=10)
More labelframes are there having same procedure with different y coordinate only are there but has same procedure so skipping to last lines.
self.window.update()
self.canvas.configure(scrollregion=self.canvas.bbox(ALL))
self.window.mainloop()
What changes should be done?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|

