Welcome to the most active Linux Forum on the web.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 06-18-2011, 11:59 AM   #1
Registered: Apr 2011
Distribution: Arch Linux :D
Posts: 50

Rep: Reputation: 0
Question 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?

Old 06-18-2011, 02:31 PM   #2
LQ 5k Club
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721
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.
Old 06-18-2011, 04:34 PM   #3
Registered: Apr 2011
Distribution: Arch Linux :D
Posts: 50

Original Poster
Rep: Reputation: 0
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!


gtk, python, toolbar

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Get input from entry using Gtk? michaelinux Programming 3 05-12-2011 03:16 PM
python update - Unable to load GTK2 Python bindings: No module named gtk itpedersen Linux - Software 2 10-03-2008 04:44 AM
basic python entry tkinter widget how-to donnied Programming 2 03-30-2008 11:36 AM
WineX, python-gnome, and python-gtk DrD Fedora 0 08-03-2004 01:11 PM
GTK entry nAvi Programming 2 08-16-2003 11:59 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:21 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration