C
cantabile
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 ?
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 ?