[pygtk] Signal Blocking
Shandy Brown
sjbrown at vmware.com
Thu Nov 29 04:34:40 WST 2007
I didn't get a response to this question regarding the right way to
block a signal. I have reworked my example to be much much smaller so
that hopefully it garners some eyeballs.
Again, if my approach is fundamentally wrong, please let me know.
To reiterate the problem: I basically want two widgets to affect each
other's values. But if I do this naievely, like so...
Spinbutton
on_value_changed:
Entry.set_text()
Entry
on_changed:
Spinbutton.set_value()
That causes an infinite loop. My idea is to block the signals before
calling set_text() or set_value(), but, as the attached example will
show, I get an error (min_clock.py:29: Warning: gsignal.c:1695: instance
`0xb25840' has no handler with id `46')
Any guidance would be appreciated.
Shandy
On Tue, 2007-11-20 at 11:03 -0800, Shandy Brown wrote:
> I'm trying to write a clock widget. I want it to look nice and to
> behave in a friendly manner.
>
> * It should show colons between the hours, minutes, and seconds
> * typing the time should "skip" over the colons
>
> I've tried to implement this by 5 sequential text entry widgets, each
> without a frame so they look like they're part of the same widget, laid
> out like this:
>
> +----+---+----+---+----+
> | hh | : | mm | : | ss |
> +----+---+----+---+----+
>
> if the time is 10:20, I want focus to default to the hours, and the user
> can type in "1020".
>
> The best way I can think of doing this is by detecting that on the
> keypress for "2", the number is out of bounds, then blocking the signals
> for the minute text entry, and setting it's value to 2.
>
> However, sometimes when I try to block the signals, I get the message
>
> Warning: gsignal.c:1695: instance `0xaf6800' has no handler with id `115'
>
> Which doesn't make sense to me, because I 115 definitely exists, as I
> stored it previously.
>
> I've attached the code which will exhibit the behaviour. Just type
> "python clock.py"
>
> Any suggestions? Anyone know why signal 115 disappears?
>
> -sjbrown
> _______________________________________________
> pygtk mailing list pygtk at daa.com.au
> http://www.daa.com.au/mailman/listinfo/pygtk
> Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: min_clock.py
Type: text/x-python
Size: 9010 bytes
Desc: not available
Url : http://www.daa.com.au/pipermail/pygtk/attachments/20071128/cd6a58b7/min_clock-0001.py
More information about the pygtk
mailing list