the Shelter wrote:
However, now I face a strange problem even before I build an app bundle. the
mainfile.py runs perfect when launched alone.
But when run via main.py it hangs when Upload button is presses.
hmmm - it really should hang in either case....
I susspect either wx.callback or the thread-
I do think that's it. You can't use wx GUI calls form a different thread
than wx was started in (usually the main thread). See the wxPython Wiki
under "long running tasks", plus various discussions on the
wxpython-users list.
def OnStartUpload(self,evt):
thread.start_new(self.FtpUp,())
this is running FtlUp in a new thread.
def FtpUp(self):
#start pulsing the gauge
self.g1.Pulse()
#disable the Upload button
self.start_upload_button.Enable(False)
#the progress dialog
#connect to the ftp server
ftp = FTP("192.168.0.1")
ftp.login("username", "password")
trans_file = open(pdffile)
print trans_file
#FTPprogress = FTPProgressDialog(filename)
ftp.newstorbinary("STOR " + serial + "_" + fo_choice + "_" +
tail1, trans_file, callback=self.wxcallback)
trans_file.close()
ftp.close()
#set gauge to 100% caus it hangs at 99.9% although 100%
self.g1.SetValue(230)
self.t8.SetLabel("Percent: 100.00")
self.t9.SetLabel("Kb: " + str(self.filesize) + " of " +
str(self.filesize))
and here you are making wx calls. That does cause problems.
What you need to do is wrap up these calls in a method, say
self.UpdateProgress(), and call that method with:
wx.CallAfter(self.UpdateProgress)
that should do it. There are other ways that you can read about if this
isn't going to work for you.
-Chris
--
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
[EMAIL PROTECTED]
_______________________________________________
Pythonmac-SIG maillist - Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig