I’m trying to do something with a wx element from outside the class:
def doStuff(uselessVariableIsUseless):
myListbox.Set(myList)
class myWindow(wx.Frame):
def __init__(self, parent, id):
myListbox = wx.ListBox(parent = self, pos = (320, 30), size = (300, 500))
I’ve also tried globalizing myListbox inside def __init__(), and using myWindow.myListbox, etc, but I still get NameError: global name 'myListbox' is not defined. What’s the right way to do this?
You need to assign to
self.myListboxto make it a property of the instance. You can then pass the instance to thedoStuffmethod and access it via<object>.myListbox: