Frédéric | 13 Jul 11:00

Re: Change state of a button

On samedi 12 juillet 2008, Casey McGinty wrote:

> > On vendredi 11 juillet 2008, Casey McGinty wrote:

> > > So you want to see the button go in and then out, like in real time?
> > > I don't think you can do this with a gtk.Button. Maybe you could rig
> > > a gtk.ToggleButton to emulate the button press. I would think that
> > > if you change the button state from active, to inactive, without
> > > adding any delay, it will happen too fast for you you to see it on
> > > the screen.
> >
> > The problem if I use a ToggleButton is that I will have to press it
> > twice to release it; and I don't want to, as it will drive a panoramic
> > head; it can be dangerous if the motor stay on...
>
> What if you make the callback logic in the Togglebutton to unset the
> ToggleButton after it is set? Then it should behave like a standard
> button. I've never done this, but I would think that this could be done
> easily.

Ok, I finally made it work with a ToggleButton. First, lets say that I use 
the 'pressed' and 'released' events, the first to start a motor move, the 
second to stop the motor move. I do no need the 'clicked' event.

Here is what I did:

1) I binded the 'pressed' and 'released' events of the toggle button.

2) I binded the 'pressed' and 'released' events of the associated key.

(Continue reading)


Gmane