473,386 Members | 1,830 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Pygtk: dynamic menu

micmast
144 100+
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))
  4.  
  5. for tools in self.popup_menu_plugins:
  6.             self.popup_left_menu_plugin.set_submenu(tools)
  7.  
  8.  
But that doesn't work, hence my question: how to fix this?

Thx in advance
Mar 25 '09 #1
2 3365
micmast
144 100+
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...

*Sigh*
Mar 25 '09 #2
bvdet
2,851 Expert Mod 2GB
micmast,

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

-BV
Mar 25 '09 #3

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

Similar topics

4
by: j_mckitrick | last post by:
I am having a problem with combo boxes. If I am using an XML glade2 file for my gui definition, what is the command I need to use to access a given combo box and determine the currently selected...
0
by: dataangel | last post by:
I want to make a pygtk app that consists completely of a window. When I run it, a menu should appear where the mouse cursor is. I've been looking at the official pygtk tutorial and documentation,...
25
by: TPJ | last post by:
GUI's etc: PyGtk on Windows "(...) So if someone develops mainly for X and just wants to make sure that it is not impossible to run on Windows, you can use PyGTK. (...)", July 2nd, 1999 pyGTK...
14
by: Rod W | last post by:
I'm just starting out on Python but my primary goal is to provide applications with some user interface (GUI). Can someone point me to a good comparison of whether I should use wxPython (with...
1
by: JyotiC | last post by:
hi, i am making a gui, which looks like excel sheets. i want to give the user the facility of adding rows/columns at the run time. there is some initial size, but that can be increased any time...
10
by: jubei | last post by:
I've been trying to write a custom widget for a project, however when i try to run code that uses it i get the following error > ./nokiagui.py Traceback (most recent call last): File...
1
by: manatlan | last post by:
I was a fan of "SimpleGladeApp/tepache way" to build a pygtk app. I've build a new efficient/dynamic way to build a pygtk app ... Here is an example :...
0
by: Kveldulv | last post by:
HI all, can someone show me how to make simple right-click menu in PyGTK. tia
0
by: Michael Palmer | last post by:
On Sep 16, 12:30 pm, binaryjesus <coolman.gu...@gmail.comwrote: I haven't tried it myself, but I came across a blog post the other day that describes a way of building windows installers for...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.