Hi, Werner,
Hi Igor,
Anybody?
It still frezes and I have no clue where and what I'm doing wrong...
No idea, but have you looked at:
LongRunningTasks - wxPyWiki
No, I didn't.
But today I looked more closely at the code in the section:
"Redirecting text from stdout to wx.TextCtrl".
What happen in my case is this:
I have wx.Wizard based dialog which after completion starts a
DOS-based script on which I don't have any control.
It's been developed by someone else and right now it is frozen for development.
This script spawns couple of python threads which produce some logging
messages and some debug messages/errors.
Now it used to be that when the wx.Wizard is finished my GUI starts
the wx.Progress dialog and starts running that external script in
background. AFAIU, progress dialog is itself run on the different
thread and it calls wx.Yield to let the GUI process messages.
Now, my GUI is getting rid of the progress dialog and instead we want
the logging be put in text control which is shown inside wx.Dialog.
The redirection of the messages works fine. The problem comes from the
fact that somewhere in the middle of the processing of that DOS-based
script' thread the GUI freezes. Text control is not updated and no GUI
events are processed.
The old code was like this:
def menu_create_file(self, event):
wizard = MyWizard(self)
if wizard.run():
options = wizard.options
else:
return
self.statusBar.SetStatusText("Creating File...",0)
def after_completion(args):
self.progressDialog.Destroy()
if args:
#we have an error. Report it to the user
else:
#display successful message
def run_creation(args):
#set the parameters and call the external script
self.progressDialog = wx.ProgressDialog()
self.progressDialog.Pulse()
self.progressDialog.Show(true)
self.worker = WorkerThread(self, run_creation, None, after_completion)
where WorkerThread is a simple wrapper around the python Thread class
(not the wx.Thread).
Now what I did is this:
class Executor(wx.Dialog):
#this class is to display the dialog with the text control logger
and start the external process
def __init__(self, parent, id, title):
#create text control and bind the update log event
def OnShowExecutor(self, logLevel):
#redirect logging
try:
self.Show()
#set the parameters and call external script
except Exception as e:
print e
def menu_create_file(self, event):
wizard = MyWizard(self)
if wizard.run():
options = wizard.options
else:
return
self.statusBar.SetStatusText("Creating File...",0)
def after_completion(args):
self.dlg.Destroy()
if args:
#we have an error. Report it to the user
else:
#display successful message
def run_creation(args):
self.dlg = Executor(self,-1, "my_title", options)
self.dlg.OnShowExecutor()
self.worker = WorkerThread(self, run_creation, None, after_completion)
And this new code, while successfully perform logging freezes the GUI part.
Now as I said before I don't have control over the base script - the
one that my GUI starts after the wizard.
As far as I can tell I'm missing a simple call to wx.Yield() to let
the system process GUI messages.
I just don't know where to put it.
The pseudo-code I put in here is from the wx.Frame based class (TLW).
Does anybody sees any issues with what I'm trying to do?
Thank you.
···
On Mon, Jun 16, 2014 at 11:15 PM, Werner <wernerfbd@gmx.ch> wrote:
On 6/17/2014 7:32, Igor Korot wrote:
Werner
--
You received this message because you are subscribed to the Google Groups
"wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to wxpython-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.