[pygtk] Clock Widget - some issues
Shandy Brown
sbrown at vmware.com
Fri May 4 02:00:38 WST 2007
Hi all.
I'm trying to write a Clock widget. I have some constraints - I'm using
Glade and can't use GNOME, so this is just plain GTK.
What I've done so far is make 5 GtkEntry widgets side by side (00, :,
00, :, 00). Then beside those, I've put a GtkSpinButton whose width is
exactly the size of the up/down arrows, so that you can't see the text
part. See the attached image.
Surrounding all those is an unlabeled frame just for esthetics.
First of all - does anyone see anything fundamentally wrong with this
construction approach?
Ok, so my first challenge is getting the focus to change from one "00"
GtkEntry to the next. When I type "1234", I want to see 12:34:00.
Similarly for "12<tab>34".
So I'm listening for the insert_text event, and then doing a check,
widget.get_position() >= widget.get_max_length()
If that is true, I try to emit a key press event to tab over to the next
GtkEntry. But this isn't working for me. Here's the code I've got so
far:
event = gdk.Event( gdk.KEY_PRESS )
event.keyval = TAB_KEYVAL
event.window = widget.get_parent_window()
widget.emit( 'key-press-event', event )
I'm not sure what I'm supposed to be using for TAB_KEYVAL. I'm also not
sure if this is the right approach to advancing focus. Any advice?
sjbrown
-------------- next part --------------
A non-text attachment was scrubbed...
Name: example_clock.png
Type: image/png
Size: 545 bytes
Desc: not available
Url : http://www.daa.com.au/pipermail/pygtk/attachments/20070503/3e70f119/example_clock.png
More information about the pygtk
mailing list