python

pygtk + toolbar + toolbutton with custom image

Last night I had more trouble than I was expecting while trying to put a custom image on a toolbar button. I had already done this with tabs, normal buttons and solo. It was easy but for the toolbutton it wasn’t so obvious… maybe it was because of the hour, I don’t know.
So here goes a sample to help any one in need:

# create the pixbuf with the image and it's size.
# 24,24 is the TaskEditor's toolbar icon size
# the path gets the current document path to use with the image
path = os.path.dirname(os.path.abspath(__file__))
icon_path = os.path.join(path, "image.png")
pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(icon_path , 24, 24)
 
# create the image and associate the pixbuf
image = gtk.Image()
image.set_from_pixbuf(pixbuf)
image.show()
 
# create the toolbutton
btn = gtk.ToolButton()
btn.set_icon_widget(image)
btn.set_label("Task location")
btn.connect('clicked', self.some_method)
 
# then just add the item (btn) to the position you want
toolbar.insert(btn, position)
btn.show()

That’s all! ;)

Google Summer of Code: Week 7

I’m glad to be working with the GTG! community, it’s growing real fast! This week, Getting Things Gnome! 0.1.2 was released.

GTG
More screenshots here.
For the curious ones a review of GTG! made by Ryan Paul is available here. There are still lots of new features coming up! Anyone that wants to join us, feel free to do it at IRC (gimp net at #gtg).

I just received an e-mail from Google notifying me that I have successfully passed the Midterm Evaluations. I already knew that I was going to pass but the confirmation is always good. :-)

In week 7 I mainly worked on the python-geoclue module. A list of the module’s features are available here.
I also made a test file to test the module’s features and added the setup to install the module.
Suggestions to improve the module are welcome! I already got the suggestion to add gobject-introspection support, so keep those suggestions coming!
The code is available at https://code.launchpad.net/~pcabido/+junk/pygeoclue.

I updated the wiki page that I left behind on the past weeks and created a page (http://live.gnome.org/gtg/soc/whatihavelearned) that is kind of a general report of what I done until now. The idea is to share what I have learned and it is intended to be allot more technical than it is now. It is also a good starting point for all the documentation that I’ll have to do.

Now I’m starting to work with libchamplain. I plan to have a working plugin with geoclue+libchamplin by the end of this week.
All of this part of my work is available here: https://code.launchpad.net/~pcabido/gtg/plugin-engine

Google Summer of Code: Week 3

On week three I accomplished an important part of the project, that was to have by the end of the week a “working prototype” of the plug-in engine. Its not complete but the difficult part and the part where I was (very) confused is done.
Plug-ins are loading and working. Briefly, the system is divided into three parts:

  • The Plugin Manager that handles the GUI for the plug-ins
  • The Plugin Engine that handles the load, initialization, activation, etc for the plug-ins
  • A third part that is the plug-in API (the methods that are allowed for a plug-in to use)

And for the screen shot lovers here are some images of what is done:

Plugin_GUI
Plugin_working

The first screen shot is obvious, it’s the Plug-in Manager GUI and the second screen shot is the features that the plug-ins are implementing. The plug-ins are copys of each other, the each add a menu to the Plug-in menu on the menu bar and by clicking that menu you can see the action on the gnome-terminal and the last two buttons on the ToolBar are also put there by the plug-ins (you can also see the output on the gnome-terminal that resulted by a click on a button). New screen shots or maybe a video next week!

For week 4 I have the intention to finish the plug-in engine, it will be a work in progress but I want to finish all the main parts, and start the geoclue-python module that I will later use with a plug-in in GTG!.

Besides this I will continue my university marathon, here in Portugal the professors seam to wait for each other and set the tasks we have to do all at the same time. I still have 3 exams and 4 assignments to submit during June.