A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-list/2005-September/331800.html below:

Managing events

Managing events Managing eventscantabile cantabile.03 at wanadoo.fr
Sat Sep 3 13:03:33 EDT 2005
Hi,

I have a class (a gui) with buttons and other controls. A button, for 
example, has a callback method, so that writing

    b = Button(label, OnClick)

will call the global OnClick method.

Now, if I want the OnClick method to call some of my main class methods, 
I need to write:

     UI = None
     ...
     class MainClass:
         ...
         global UI = self


Then,
def OnClik(button):
    UI.do_something(button.get_label())

Is this the correct way to do it in Python ? Isn't there a potential 
flaw in declaring my MainClass instance as a global variable ?

More information about the Python-list mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4