Re: gtk3 + python : lookup_widget



   The "lookup_widget()" paradigm comes from a very old time when we
had very poor
tools and actually it originates from people using generated code from
the original Glade
tool (Glade versions 1 and 2).

Ideally, as specially as you are using python, your application should
be modular.

Perhaps you have an Application object which owns the main widgetry created
by GtkBuilder after having parsed a Glade file initially, this is
different from a global
variable.

Ideally you can use you object constructor as an entry point to load
your GtkBuilder
and assign the pointers you need later on to the members you define on your
Application object.

After that you simply have to pass your Application object to all the callbacks
which originate from the user interface, giving you access to everything you
need when you need it.

This concept can be further extended to be more modular, for instance if
you have a preferences dialog/window... it can be defined by a separate
python class/GtkBuilder file and reused at will throughout your program.

Cheers,
                 -Tristan

On Mon, Aug 20, 2012 at 1:10 PM, Patrick Shirkey
<pshirkey boosthardware com> wrote:
Hi,

I'm having a little trouble finding examples online of using the
equivalent of lookup_widget() with gtk3 + python.

For example in the following code what is the best way to modify the
"message" label after the "commandline" callback is sent?

Should I be using globals or a glade file or is there a way to dynamically
lookup the "message" widget ?



def create_gtkEntry():

    commandline = Gtk.Entry()
    commandline.connect("activate", command_entered, 1)

    messages = Gtk.Label('TEST')



def command_entered(self, *args):

    cmi_command = self.get_text()
    messages.set_text(cmi_command)
    print "command entered: ", args[0]



--
Patrick Shirkey
Boost Hardware Ltd
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]