Running a Thread in wxWizard

Hi,

I am trying to start a thread in my wxWizard application that will update a database and post events to update wxProgressDialog, but I keep getting the following error when I try to start the thread.

  File "C:\Python22\Lib\site-packages\wxPython\cmndlgs.py", line 389, in __init

···

_
    self.this = apply(cmndlgsc.new_wxProgressDialog,_args,_kwargs)
wxPyAssertionError: C++ assertion "wxThread::IsMain()" failed in e:\projects\wx
src\msw\app.cpp(870): only the main thread can process Windows messages

I have a class that extends wxApp and within OnInit, I create the wxWizard instance and then call the following method

def Run(self):
    self.wizard.RunWizard(self.decisionPage)
    self.wizard.Destroy()
    self.MainLoop()

The whole application is started by

if __name__ == '__main__':
   prg = MainProgram(0)

Does the way I start the wizard cause the error message I am getting?

Thanks
Ryan

Ryan Scott wrote:

Hi,

I am trying to start a thread in my wxWizard application that will update a database and post events to update wxProgressDialog, but I keep getting the following error when I try to start the thread.

File "C:\Python22\Lib\site-packages\wxPython\cmndlgs.py", line 389, in __init
_
   self.this = apply(cmndlgsc.new_wxProgressDialog,_args,_kwargs)
wxPyAssertionError: C++ assertion "wxThread::IsMain()" failed in e:\projects\wx
src\msw\app.cpp(870): only the main thread can process Windows messages

Looks like you are creating the progress dialog from the worker thread, rather than the main thread. The main thread is defined as the one that was active when the core wxPython module was first imported.

I have a class that extends wxApp and within OnInit, I create the wxWizard instance and then call the following method

def Run(self):
   self.wizard.RunWizard(self.decisionPage)
   self.wizard.Destroy()
   self.MainLoop()

The whole application is started by

if __name__ == '__main__':
  prg = MainProgram(0)

Does the way I start the wizard cause the error message I am getting?

Which thread is Run called from?

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!