I have a piece of code that generates a number of wx.TextCtrl entries where that number depends on a variable input, and that's why I need to use a 'for' loop to generate every entry, the code looks more or less like this:
class multentries(wx.Frame):
def __init__(self,parent,id,title):
wx.Frame.__init__(self,None,-1,title="Information", size=(300,100))
panel2=wx.Panel(self,-1,size=(300,300))
okbutton=wx.Button(panel2,-1,"OK")
self.Bind(wx.EVT_BUTTON,self.Close2,okbutton)
alist=str.splitlines(myfile)
for variable in alist:
label=wx.StaticText(self,-1,variable)
self.entry=wx.TextCtrl(self,-1," ", size=(40,-1))
def Close2(self,event):
# And here is where I can't figure out how to retrieve all the entries derived from self.entry
self.Close(True)
I am sure the solution is simple, but I can't seem to find it. I would appreciate some help.
I have a piece of code that generates a number of wx.TextCtrl entries where that number depends on a variable input, and that's why I need to use a 'for' loop to generate every entry, the code looks more or less like this:
class multentries(wx.Frame):
def __init__(self,parent,id,title):
wx.Frame.__init__(self,None,-1,title="Information", size=(300,100))
panel2=wx.Panel(self,-1,size=(300,300))
okbutton=wx.Button(panel2,-1,"OK")
self.Bind(wx.EVT_BUTTON,self.Close2,okbutton)
alist=str.splitlines(myfile)
for variable in alist:
label=wx.StaticText(self,-1,variable)
self.entry=wx.TextCtrl(self,-1," ", size=(40,-1))
def Close2(self,event):
# And here is where I can't figure out how to retrieve all the entries derived from self.entry
You are re-assigning self.entry to a different text control each time through the loop so it will only point to the last one made. You could either keep them in a list (i.e self.entry = list(); self.entry.append(wx.TextCtrl(...)) ) or you could also look them up when you need them.
for child in self.GetChildren():
if isinstance(child, wx.TextCtrl):
do something...