Hello dear wxpython community:
I have been struggling for a couple of now, trying to figure out how to extract a value from a very nested function that is in my application. Here is my very simplified code:
class MyFrame(wx.Frame):
def __init__(self,parent,id, title):
wx.Frame.__init__(self,parent,id,title='An application',size=(900,750))
menuBar=wx.MenuBar()
#some menus
def opendir(self, event):
dlg=wx.DirDialog(self,"Choose directory",defaultPath=os.getcwd())
if dlg.ShowModal() == wx.ID_OK:
self.path=dlg.GetPath()
self.namedir=os.path.basename(self.path)
self.maindir=os.path.dirname(self.path)
if "_" in self.namedir:
small=i.split("_")
else:
small=value
for ine,elem in enumerate(small):
if re.search("day",elem,re.I):
fii=ine
lelem=len(elem)
if lelem==4:
### THIS IS THE VALUE I NEED TO PASS TO OTHER CLASSES
pival=elem[3]
else:
inn=small[fii+1]
pival=elem[fii+1]
print pival
class MyApp(wx.App):
def OnInit(self):
myframe=MyFrame(None,-1,"")
myframe.CenterOnScreen()
myframe.Show(True)
return True
app=MyApp(0)
app.MainLoop()
I have tried defining pival (within a function) as a global, but I probably haven't placed the function at the right place. I would appreciate very much any help.
Thank you!
Judith