#pack_sample.py # Use a StringVar to create a changeable label 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 addButton(root, LEFT) # Put the left side of the next widget close to me addButton(root, BOTTOM) # Put bottom of next widget close to me addButton(root, RIGHT) # Put right of next widget close to me addButton(root, BOTTOM) # Put bottom of next widget close to me root.mainloop() # Start the event loop main()