How to query object of GUI?

Muddy Coder cosmo_general at
Wed Apr 15 06:56:16 CEST 2009

Hi Folks,

I need to query the ID of GUI, in Tkinter, but don't know how to do
it. This is my code:

calss MyGUI:
   def make_menu(self):
      top = Menu(self)
      menObj = Menu(top)
      labels = read_from_database()
      for lab in labels:
         menObj.add_command(label=lab, command=self.do_menu)
   def do_menu(self):
      # here I need query which menu item was clicked

For GUI Entry, there is a resource name textvariable, so I can use
textvariable to distinguish one Entry from the others. But, I can't
find such a resource name for Menu. I also noticed label is an
identifier, but I have no idea how to get it. Can somebody help me
out? Thanks in advance!

Muddy Coder

More information about the Python-list mailing list