pyGTK, Buttons and Pixmaps problem

  • Thread starter Fulko van Westrenen
  • Start date
F

Fulko van Westrenen

Hello,

I use pyGTK in a program with ToggleButton and Pixmap.
The problem I try top solve is changing the pixmap for the
two states of the button. Can it be done? (should be possible),
and someone provide me with working code?

The code I use now is (python-2.2, gtk-1.2):

button = gtk.GtkToggleButton()
button.connect("clicked", do_my_thing)
button.show()
pix,mask = gtk.create_pixmap_from_xpm(window,None,'nice.xpm')
pixmap = gtk.GtkPixmap(pix,mask)
pixmap.show()
button.add(pixmap)


Can someone tell me how to make it work?

Thanks,
Fulko
 
D

David M. Cook

Fulko van Westrenen said:
Hello,

I use pyGTK in a program with ToggleButton and Pixmap.
The problem I try top solve is changing the pixmap for the
two states of the button. Can it be done? (should be possible),
and someone provide me with working code?

The code I use now is (python-2.2, gtk-1.2):

button = gtk.GtkToggleButton()
button.connect("clicked", do_my_thing)

For a toggle button, you want to handle the "toggle" signal. Also, for
getting the icon to change between states I think you want to look at the
IconSet and IconSource APIs:

http://www.gnome.org/~james/pygtk-docs/class-gtkiconset.html

Dave Cook
 
F

Fulko van Westrenen

wrote: [...]

For a toggle button, you want to handle the "toggle" signal.
OK

Also, for
getting the icon to change between states I think you want to look at the
IconSet and IconSource APIs:

http://www.gnome.org/~james/pygtk-docs/class-gtkiconset.html

Dear Dave,
Thank you for your hint. I read this forward and back again, but I can't
figure how to apply this. Is there example-code somewhere that shows a
changing image when pushing the button?
Best,
Fulko
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top