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

Tkinter Pack Method

tkinter

Uploaded by

sri
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)
120 views1 page

Tkinter Pack Method

tkinter

Uploaded by

sri
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

https://www.tutorialspoint.com/python/tk_pack.htm Copyright © tutorialspoint.

com

Advertisements

This geometry manager organizes widgets in blocks before placing them in the parent widget.

Syntax

widget.pack( pack_options )

Here is the list of possible options −

• expand − When set to true, widget expands to fill any space not otherwise used in widget's parent.

• fill − Determines whether widget fills any extra space allocated to it by the packer, or keeps its own
minimal dimensions: NONE default , X fillonlyhorizontally , Y fillonlyvertically , or BOTH
fillbothhorizontallyandvertically .

• side − Determines which side of the parent widget packs against: TOP default , BOTTOM, LEFT,
or RIGHT.

Example
Try the following example by moving cursor on different buttons −

from Tkinter import *

root = Tk()
frame = Frame(root)
frame.pack()

bottomframe = Frame(root)
bottomframe.pack( side = BOTTOM )

redbutton = Button(frame, text="Red", fg="red")


redbutton.pack( side = LEFT)

greenbutton = Button(frame, text="green", fg="green")


greenbutton.pack( side = LEFT )

bluebutton = Button(frame, text="Blue", fg="blue")


bluebutton.pack( side = LEFT )

blackbutton = Button(bottomframe, text="Black", fg="black")


blackbutton.pack( side = BOTTOM)

root.mainloop()

When the above code is executed, it produces the following result −

You might also like