tkinker:Simulating GUI Button Press

Tim Daneliuk tundra at
Thu Jan 9 01:40:07 CET 2003

I have this code:

class myUI:

     def __init__(self, root):

         # Setup Menubar frame

         self.mBar = Frame(root, relief=RAISED, borderwidth=2)

         # Setup the Command Menu

         self.CmdBtn = Menubutton(self.mBar, text=COMMANDMENU, underline=0, state=DISABLED, font=(FNAME, FSZ, "bold")) = Menu(self.CmdBtn, font=("courier", FSZ, "bold"))
         self.CmdBtn.pack(side=LEFT, padx='2m')

         # Setup the Directory Menu

         self.DirBtn = Menubutton(self.mBar, text=DIRMENU, underline=0, font=(FNAME, FSZ, "bold")) = Menu(self.DirBtn, font=("courier", FSZ, "bold"))
         self.DirBtn.pack(side=LEFT, padx='2m')


Is there a way to programmatically generate the event that acts like
CmdBtn or DirBtn have been pressed?  I am familiar with keyboard events,
but cannot seem to figure out how to activate a Menubutton element as if
it has been clicked by the user...

Tim Daneliuk
tundra at

More information about the Python-list mailing list