Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
23 views1 page

Tkinter Pack() Method Button Layout

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views1 page

Tkinter Pack() Method Button Layout

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Activity # 4 Layout using Pack() method

from Tkinter import *


# Hold onto a global reference for the root window
root = None
count = 0 # Click counter

def addButton(root, sideToPack):


global count
name = "Button "+ str(count) +" "+sideToPack
button = Button(root, text=name)
button.pack(side=sideToPack)
count +=1

def main():
global root
root = Tk() # Create the root (base) window where all widgets go
for i in range(5):
addButton(root, TOP)
root.mainloop() # Start the event loop main()
main()

You might also like