By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,235 Members | 1,022 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,235 IT Pros & Developers. It's quick & easy.

Pygtk: dynamic menu

P: 144
Hey everybody,

I have a question, I'm building an application in which a popup menu has to be generated on the fly depending of the data being read from an xml file.

The first part is very simple and I have the items in an array and now I want to add them to an existing menu.

Some variables I use just so it all makes sense.
popup_left_menu_plugin: menuitem in a popup in which the other items should be placed
popup_menu_plugins: is an array that will hold the menuitems
tool_command: is a dictionary with the items to be added
Expand|Select|Wrap|Line Numbers
  1. for tool in tool_command.keys():
  2.             if str(len(tool)) != "0":
  3.                 self.popup_menu_plugins.append(gtk.MenuItem(tool))
  5. for tools in self.popup_menu_plugins:
  6.             self.popup_left_menu_plugin.set_submenu(tools)
But that doesn't work, hence my question: how to fix this?

Thx in advance
Mar 25 '09 #1
Share this Question
Share on Google+
2 Replies

P: 144
I always seem to be fixing my own threads :)

Anyway here is the fix that solves the problem
I used the .append to append the menuitem to the menu instead of another menuitem, and then I used the .show to actually show the item...

Mar 25 '09 #2

Expert Mod 2.5K+
P: 2,851

Sometimes describing a problem to others is enough to make a solution clearer. Thanks for the update.

Mar 25 '09 #3

Post your reply

Sign in to post your reply or Sign up for a free account.