Tkinter supports a relatively unlimited number of flags, limited mainly by practical issues, such as system memory and usability restrictions.
There are at least three methods for creating a scrollable container for widgets. Both canvases and text widgets support scrolling, so itβs common practice to use one of them for a container. You can also perform clever stunts with the team place, if you need something difficult.
Using a canvas is good if you want to scroll a frame containing more than just a vertical list of objects. Using a text widget is very convenient if you only need to create one vertical list.
Here is a simple example:
import Tkinter as tk class Example(tk.Frame): def __init__(self, root, *args, **kwargs): tk.Frame.__init__(self, root, *args, **kwargs) self.root = root self.vsb = tk.Scrollbar(self, orient="vertical") self.text = tk.Text(self, width=40, height=20, yscrollcommand=self.vsb.set) self.vsb.config(command=self.text.yview) self.vsb.pack(side="right", fill="y") self.text.pack(side="left", fill="both", expand=True) for i in range(1000): cb = tk.Checkbutton(self, text="checkbutton #%s" % i) self.text.window_create("end", window=cb) self.text.insert("end", "\n") # to force one checkbox per line if __name__ == "__main__": root = tk.Tk() Example(root).pack(side="top", fill="both", expand=True) root.mainloop()
When you learn more about Tkinter, you will realize that there are not as many built-in widgets as some other tools. I hope you also understand that Tkinter has enough fundamental blocks to do everything you can imagine.
Bryan oakley
source share