[pygtk] set focus in dialog
craf
pyclutter at gmail.com
Sat Nov 19 00:18:46 WST 2011
Hi Andrew
Works very well!
Thank you very much.
Best Regards.
Cristian
>-----Mensaje original-----
>De: Andrew Steele <andrew.steele at gmx.com>
>Para: craf <pyclutter at gmail.com>
>Cc: Pygtk <pygtk at daa.com.au>
>Asunto: Re: [pygtk] set focus in dialog
>Fecha: Fri, 18 Nov 2011 15:23:20 +0000
>#!/usr/bin/env python
>import gtk
>class Dialog:
> def __init__(self):
> dialog = gtk.Dialog("Dialog Example", None, 0,
>(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OK, gtk.RESPONSE_OK))
> dialog.set_default_size(250, 300)
> label = gtk.Entry()
>
> buttonbox = dialog.get_action_area()
> buttons = buttonbox.get_children()
> dialog.set_focus(buttons[0])
>
> dialog.vbox.pack_start(label, True, True, 0)
> dialog.show_all()
>
> response = dialog.run()
>
> if response == gtk.RESPONSE_OK:
> print "OK"
> elif response == gtk.RESPONSE_CANCEL:
> print "CANCEL"
>
> dialog.destroy()
>
>Dialog()
>The above is the easiest and quickest way I can think of. Essentially, you access the ButtonBox which holds the buttons specified when constructing the Dialog and retrieve the Button. This allows you to set the focus before the Dialog is shown.
>I have a feeling there is a better way, though it's not obvious to me at the moment.
>On Thu, 17 Nov 2011 12:42:36 -0300
>craf <pyclutter at gmail.com> wrote:
> Hi.
>
> Is there any way to the OK button, keep the focus to start the program,
> and not the entry control?
>
> Here Code:---------------------------------
>
> #!/usr/bin/env python
>
> import gtk
>
> class Dialog:
> def __init__(self):
> dialog = gtk.Dialog("Dialog Example", None, 0,
> (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OK, gtk.RESPONSE_OK))
> dialog.set_default_size(250, 300)
> label = gtk.Entry()
>
> dialog.vbox.pack_start(label, True, True, 0)
> dialog.show_all()
>
> response = dialog.run()
>
> if response == gtk.RESPONSE_OK:
> print "OK"
> elif response == gtk.RESPONSE_CANCEL:
> print "CANCEL"
>
> dialog.destroy()
>
> Dialog()
>
>
> Thanks in advance!
>
> Regards.
>
> CRAF
>
> _______________________________________________
> pygtk mailing list pygtk at daa.com.au
> http://www.daa.com.au/mailman/listinfo/pygtk
> Read the PyGTK FAQ: http://faq.pygtk.org/
More information about the pygtk
mailing list