LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices

Reply
 
Search this Thread
Old 06-18-2011, 10:59 AM   #1
MetaMan
Member
 
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:
Code:
...
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!
 
Old 06-18-2011, 01:31 PM   #2
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 713Reputation: 713Reputation: 713Reputation: 713Reputation: 713Reputation: 713Reputation: 713
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:

Code:
item = gtk.ToolItem()
item.add(self.text)
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, 03:34 PM   #3
MetaMan
Member
 
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!
 
  


Reply

Tags
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 02:16 PM
python update - Unable to load GTK2 Python bindings: No module named gtk itpedersen Linux - Software 2 10-03-2008 03:44 AM
basic python entry tkinter widget how-to donnied Programming 2 03-30-2008 10:36 AM
WineX, python-gnome, and python-gtk DrD Fedora 0 08-03-2004 12:11 PM
GTK entry nAvi Programming 2 08-16-2003 10:59 AM


All times are GMT -5. The time now is 02:55 AM.

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