PDA

View Full Version : Python + Glade -- Changing an image filename



robz0rz
December 14th, 2008, 06:39 PM
Hello all


I'm creating a little tool to change certain aspects of my new custom icon-theme, like branding, folders, etc. I decided this was a good project to start learning Python and PyGTK with it.

I'm slowly understanding how Python works, it's a lot of fun to write it actually!

I used Glade to create a user interface. I'm now at a point where I have a GtkImage somewhere, and I want to change the filename of the source image it uses. In other words: I want to set the image it displays through Python instead of Glade (because the image can change on certain events).


imgFuture = self.wTree.get_widget("BrandingFutureSVG")

What method do I have to call on imgFuture in order to do this? Thanks

.nedberg
December 14th, 2008, 07:38 PM
You can use:


filename = path-and-or-filename.png
imgFuture.set_from_file(filename)

robz0rz
December 14th, 2008, 08:40 PM
Thanks! That worked!

Is there any way I can find these methods myself? Is there a good documentation?

For example, other things I am trying to archieve are:
Extracting the filename from the widget
Changing the items in a ComboBox

.nedberg
December 14th, 2008, 08:43 PM
http://www.pygtk.org/

Have a look under "Documentation".

mssever
December 14th, 2008, 09:01 PM
Is there any way I can find these methods myself? Is there a good documentation?
Install DevHelp and the PyGTK doc package. DevHelp will then give you all that info.