-   Programming (
-   -   Python: Placing a gtk.Entry() into a Toolbar (

MetaMan 06-18-2011 10:59 AM

Python: Placing a gtk.Entry() into a Toolbar
I've searched the web for quite a while and cannot seem to find a way to add a gtk.Entry() to a toolbar via toolbar.insert().

I currently have this:

self.toolbar = gtk.Toolbar()
self.text = gtk.Entry()
self.toolbar.insert(self.text, 0)

Which in turn spits out "Gtk.Toolbar.insert() argument 1 must be gtk.ToolItem, not gtk.Entry"

How would I do this correctly?

Thanks! :D

MTK358 06-18-2011 01:31 PM

I'm not a GTK+ expert (I use Qt), but I found this in the documentation:

ToolItem is a subclass of Bin which is a subclass of Container. Container has an add() method to add a child. So I would try this:


item = gtk.ToolItem()
self.toolbar.insert(item, 0)

Note that it is not necessary to prepend "self." to all variables which hold a widget, you only need it for those that you will reference later from other methods.

MetaMan 06-18-2011 03:34 PM

Thanks! I agree that all the selfs don't make much sense as is, but there's a lot of code I cut out to get to the point.

Again, Thanks! :D

All times are GMT -5. The time now is 02:45 PM.