Attached one possible implementation. Am Freitag, den 18.01.2008, 14:19 +0530 schrieb kartikay malhotra: > Thank you all for your feedback. > > Dear Carlos, how do I make use of the '.' key as a TAB (\t) key? Using > the tutorial, I am able to print a TAB on the console. But I want to > use '.' key as a TAB in the GUI. > > Thanks > Kartikay > > On Jan 17, 2008 11:09 PM, Carlos Pereira <carlao2005@xxxxxxxxx> wrote: > Hello, > > Chapter 11 of the excellent book "Foundations of GTK+ > Development" (Andrew Krause, Apress) shows how to create a > custom widget with the functionality you want. > > There is source code available in www. gtkbook.com > > Best regards! > > Carlos > > > 2008/1/15 kartikay malhotra <kartikay.malhotra@xxxxxxxxx >: > > > Dear All, > > I am making an IP address bar in GTK. It would > function as 123 . 445 . 521 . 444. > > Now friends, I am facing 2 problems: > > 1) How to ensure that only numbers are pressed. I > don't want the user to enter alpha characters. > 2) How to draw points in GTK, without using GNOME? > > Many Thanks for your consideration. > > -- > Best Regards > Er. Kartikay Malhotra > > > > _______________________________________________ > gtk-list mailing list > gtk-list@xxxxxxxxx > http://mail.gnome.org/mailman/listinfo/gtk-list > > > > > > -- > ============================================= > Prof. Carlos José de Almeida Pereira > Universidade Estadual de Santa Cruz > Ilhéus - Bahia - Brasil > > "Quem agora conhece a antiga linguagem da Lua ? > Quem agora fala com a Deusa ? ... > Só as pedras agora se recordam do que a Lua nos disse há muito > tempo, > e o que nós aprendemos com as árvores, e as vozes das ervas e > dos > cheiros das flores... " > (Tony Kelly, "Pagan > Musings" 1970) > > http://www.sam.paganfederation.org/index.php?id=13&lang=pt > > > > -- > Best Regards > Er. Kartikay Malhotra > > > > "Sure I am this day we are masters of our fate, that the task which > has been set before us is not above our strength; that its pangs and > toils are not beyond our endurance. As long as we have faith in our > own cause and an unconquerable will to win, victory will not be denied > us." --Winston Churchill > _______________________________________________ > gtk-list mailing list > gtk-list@xxxxxxxxx > http://mail.gnome.org/mailman/listinfo/gtk-list -- Mathias Hasselmann <mathias.hasselmann@xxxxxx> Openismus GmbH: http://www.openismus.com/ Personal Site: http://taschenorakel.de/
#!/usr/bin/python import gtk def cycle_entry(widget): box = widget.get_parent() position, = box.child_get(widget, 'position') position = (position + 2) % 8 sibling = box.get_children()[position] sibling.grab_focus() return sibling def key_press_event_cb(widget, event): keyval = gtk.gdk.keyval_name(event.keyval) # allow backspace, arrows and friends... if not event.string: return False # allow digits... if event.string in '0123456789': value = int(widget.get_text() + event.string) # cycle when value would become too large, and no text selected if (value > 255 and not widget.get_selection_bounds()): sibling = cycle_entry(widget) sibling.set_text(event.string) sibling.set_position(1) return True # insert the text return False # cycle on dot... if event.string in '.': if len(widget.get_text()): cycle_entry(widget) return True # reject all other return True hbox = gtk.HBox(False, 0) for i in range(4): if i: hbox.pack_start(gtk.Label('.'), False, True) entry = gtk.Entry(3) entry.set_width_chars(3) entry.connect('key-press-event', key_press_event_cb) hbox.pack_start(entry, True, True) window = gtk.Window() window.add(hbox) window.show_all() window.connect('destroy', gtk.main_quit) gtk.main()
Attachment:
signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil
_______________________________________________ gtk-list mailing list gtk-list@xxxxxxxxx http://mail.gnome.org/mailman/listinfo/gtk-list