Re: Changing pixmap



>I'm starting to program with gtk+ and glade. I want to do the following
>thing: I have an hbox with two entries: the right entry is a toggle
>button, and the left entry is a pixmap, say "pix1". I got this far with
>glade, I built and compiled the program and all is well. What I want now,
>is to change pix1 to another pixmap "pix2" when the button is toggled. I
>know how to determine if the button is active or not, but how do I replace
>"pix1" with "pix2"? Do I create both pixmaps from the beginning and pack
>either one with the toggle button into the hbox and display the whole
>thing each time the buttonn is toggled?
>
>The idea is to simulate a led: show some dark color when inactive, and a
>bright color when active.

this is more complex than you might be imagining. i have my own Gtk--
multicolor LED objects, and they are not implemented in the way you
describe at all.  the best you might be able to do with a "naive"
implementation is to add and remove the relevant pixmaps on receipt of
the toggle signal.

i believe that to do this correctly, you need to use a drawing area
packed next to the button. then on receipt of the toggled signal, you
need to use the low level GDK drawing functions to redraw the relevant
pixmap for the current state. you'd also need to handle expose
signals for the drawing area as well.

--p




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]