from Tkinter import *
class PackDemo( Frame ):
def __init__( self ):
Frame.__init__( self )
self.master.title( "Packing Demo" )
self.master.geometry( "400x150" )
self.pack( expand = YES, fill = BOTH )
self.button1 = Button( self, text = "Add Button",command = self.addButton )
self.button1.pack( side = TOP )
self.button2 = Button( self,text = "expand = NO, fill = BOTH" )
self.button2.pack( side = BOTTOM, fill = BOTH )
self.button3 = Button( self,text = "expand = YES, fill = X" )
self.button3.pack( side = LEFT, expand = YES, fill = X )
self.button4 = Button( self,text = "expand = YES, fill = Y" )
self.button4.pack( side = RIGHT, expand = YES, fill = Y )
def addButton( self ):
Button( self, text = "New Button" ).pack( pady = 5 )
PackDemo().mainloop()
|