Overview:
I am using wxPython to make an “App store”. Basically, I am putting a
panel in a frame, adding a horizontal sizer to the panel, adding a column of buttons on the left, and then adding app panels on the right. The app panels are being imported dynamically from a shared directory. When the user clicks on a button I .hide() the current visible app then .show() the one the user clicked on.
Problem:
Everything works great until a long running process gets initiated by one of the app panels. I would like to spawn each panel in a new thread during import. Would this be possible? I don’t mind if the app panels get hung in a long running process. I would like for the buttons on the left and all the other apps to not freeze though. Unless they spawn a long running process.
This is the code I use to import the panels dynamically:
for i, file in enumerate(os.listdir(path)):
if file.endswith(".py"):
try:
app_name = file[:file.rfind('.')]
self.tool = imp.load_source('myPanel_%s'%i, path + "\\" + file)
self.stp1 = self.tool.myPanel(self.panel)
self.hbox.Add(self.stp1, 7, wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM, border=9)
self.apps[app_name] = self.stp1
self.show_flags[app_name] = False
self.stp1.Hide()
except:
print "You do not have access to the %s App."%app_name
Anyone see a easy way to start this line of code in a new thread?
imp.load_source(‘myPanel_%s’%i, path + “\” + file)