lOMoARcPSD|33444859
Tkinter-Cheat Sheet
Programming With Python -- (Dr. A.P.J. Abdul Kalam Technical University)
Scan to open on Studocu
Studocu is not sponsored or endorsed by any college or university
Downloaded by THABANG (phanina01@[Link])
lOMoARcPSD|33444859
Position Widgets using pack(), place() or grid()
The most popular GUI creation tool for
Tkinter Python, Tkinter provides a number of pack() organizes widgets in horizontal and vertical boxes that are limited to left, right, top, bottom
widgets and methods you can use to positions. Each box is offset and relative to each other.
Cheat Sheet create a user interface for your application.
[Link](‘200x100’)
test = [Link](root, text=”pack(side=[Link])”, bg=”teal”)
Tkinter Widgets [Link](side=[Link])
from tkinter import * Options:
Code from tkinter import *
from [Link] import * padx pads externally along the x axis
Button pady pads externally along the y axis
Combobox
instance = Button(root, text="Click instance = [Link](master, ipadx pads internally along the x axis
me!", ...) pack(side=[Link]) ipady pads internally along the y axis
option=value, ...)
Widgets Checkbutton Notebook
instance = [Link](parent, instance = place() places widgets in a two grid() locates widgets in a two
option, ... ) [Link](container, options, dimensional grid using x and y absolute dimensional grid using row and column
Entry
... ) coordinates. absolute coordinates.
instance = [Link](master, option, Progressbar
...) instance = Progressbar(parent, [Link](‘200x100’) [Link](‘200x100’)
options, ... ) Label(root, text=”place(x=5, y=2)”, Label(root, text=”grid(row=2, column=2)”,
Frame
instance = Frame(parent, option, ...) Separator bg=”#A3DBE0”).place(x=5, y=2) width=12).grid(row=2, column=2)
# orient options are
Label 'horizontal' or 'vertical': 5
instance = [Link](text="some text") instance = 4
[Link](container,orient=' 3
LabelFrame horizontal') grid(row=2,column=2)
instance = LabelFrame( master, option, 2 place(x=5,y=2)
... ) Sizegrip 1
instance = [Link](master,
Menubutton options, ... ) 1 2 3 4 5 6 7 8
instance = Menubutton ( master,
options, ... ) Treeview
instance = [Link](master,
Tkinter Images with Pillow
PanedWindow options, ... ) # Pillow is imported as PIL
instance = PanedWindow(master, from PIL import ImageTk, Image
options, ... )
image1 = [Link]("<path/image_name>")
Radiobutton test = [Link](image1)
instance = Radiobutton(master,
options, ... ) label1 = [Link](image=test)
[Link] = test
Scale
instance = Scale (master, option, ... # Position image as the background image
) [Link](x=1, y=1)
# Resize image to fit on button
Scrollbar photoimage = [Link](1, 2)
instance = Scrollbar ( master, # Position image on button
options, ... ) Button(root, image = photoimage,).pack(side = BOTTOM)
©2021 ActiveState Software Inc. All rights reserved. ActiveState®,
ActivePerl®, ActiveTcl®, ActivePython®, Komodo®, ActiveGo™, ActiveRuby™,
For more Python packages related resources visit [Link]/learn-python
Downloaded by THABANG (phanina01@[Link])
ActiveNode™, ActiveLua™, and The Open Source Languages Company™ are
all trademarks of Activestate.