tkinker:Simulating GUI Button Press

Tim Daneliuk tundra at tundraware.com
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)
         self.mBar.pack(fill=X)

         # Setup the Command Menu

         self.CmdBtn = Menubutton(self.mBar, text=COMMANDMENU, underline=0, state=DISABLED, font=(FNAME, FSZ, "bold"))
         self.CmdBtn.menu = 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"))
         self.DirBtn.menu = 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...

TIA,
------------------------------------------------------------------------------
Tim Daneliuk
tundra at tundraware.com





More information about the Python-list mailing list