
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!

Widget (Grouping) Tk.Frame, ttk.Frame Ttk.LabelFrame Tk.PanedWindow Ttk.Notebook
Purpose Displays set of widgets as one unit Frame but with border and title Group widgets in re-sizable panes Tabbed set of frames, only one visible at a time
treeview = ttk.Treeview ( root ) treeview.pack ( ) treeview.insert ( ‘ ‘, ‘item1’, text = ‘First item’) treeview.insert ( ‘ ‘, ‘item2’, text = ‘Second item’) treeview.cofig (height = 5, column = (‘Version’)) treeview.column (‘Version’, width = 50, anchor = CENTER)
root.option_add (‘*tearoff’, False) menubar = Menu (root) root.config (menu = menubar) file = Menu (menubar) edit= Menu (menubar) help_ = Menu (menubar) menubar.add_cascade (menu = file, label = ‘File’) menubar.add_cascade (menu = edit, label = ‘Edit’) menubar.add_cascade (menu = help_, label = ‘Help’) file.add_command (label = ‘New’, command = lambda: print(‘New File’) file.add_separator () file.entryconfig ( ‘New’, accelerator = ‘Ctrl + N’)
from tkinter import filedialog filename = filedialog.askopenfile ( )
from tkinter import colorchooser colorchooser.askcolor ( initialcolor = ‘#FFFFFF’ )
from tkinter import messagebox messagebox.showinfo( title = ‘Example’, message = ‘some text’ ) Widget (information) Purpose Tk.Label, ttk.Label Display static text or image Tk.Message Display static multi line text Ttk.Separator Display a horizontal or vertical separator bar Ttk.Progressbar Show status of running operation Ttk.Treeview Display hierarchical collection of items
Widget (Interactive) Purpose Ttk.Button, tk.Button Execute a command, function or task Tk.Menu Implements Top-level, pull-down and popup menus Ttk.Menubutton Display popup or pull-down menu when activated Tk.OptionMenu Creates a popup menu, and a button to display Tk.Entry, ttk.Entry Text entry (one line only) Tk.Text Text entry (multiple lines) Tk.Checkbutton, ttk.Checkbutton On-Off, True-False selection Tk.Radiobutton, ttk.Radiobutton One or Multiple selections Tk.Listbox Selection from a list of alternatives Ttk.Combobox Combined text field with a pop-down list Tk.Scale, ttk.Scale Moving slider for selecting numerical values Note: Widgets with tk are generic whereas ttk are styled.