Simple windows wxpython script won't run

Hello all --

  I've developed a sizable db-frontend application on Linux (debian/
sarge) which, while still in an early state, is ready for preliminary
deployment on some users' MS-windows boxes. Problem is, the application
crashes the python interpreter, with the sole message:
  "This program has performed an illegal operation and will be
  shut down. ..."
subsequently referring to pythonwin.exe as the guilty party.

Is it reasonable to assume that the python interpreter installation (or
something it calls ... perhaps part of the wxWin package) is at fault here?
If it helps, here's an enormously stripped down dialog box that exhibits
the same problem:

# -------- start
#!/usr/bin/python

from wxPython.wx import *
word=None

class WhatsTheWord(wxFrame):
    def __init__(self) :
        global word
        word= None
        wxFrame.__init__(self, NULL, -1, "Simple dialog",
            style = wxDEFAULT_FRAME_STYLE | wxNO_FULL_REPAINT_ON_RESIZE )
        self.dlg = wxTextEntryDialog(self, "Give me the word")
        if self.dlg.ShowModal() == wxID_OK :
            word= self.dlg.GetValue()
        self.dlg.Close(true)

if __name__ == "__main__" :
    WhatsTheWord()
    print "Received word ", word
# -------- end

This fragment runs fine on Linux, but crashes on my test Win98 box.
It appears to crash (stepping via debugger) in the "apply" that is
reached within 'wxTextEntryDialog(...)'.

I'm using pythonwin32-2.4.0.7-Py22 with python2.2 (same crash w/ 2.4.0.2).

Any thoughts or recommendations would be welcome... don't be bashful,
tell me what stupidity I've committed.

  -frank

Frank Miles wrote:

Hello all --

I've developed a sizable db-frontend application on Linux (debian/
sarge) which, while still in an early state, is ready for preliminary
deployment on some users' MS-windows boxes. Problem is, the application
crashes the python interpreter, with the sole message:
"This program has performed an illegal operation and will be
shut down. ..."
subsequently referring to pythonwin.exe as the guilty party.

You're using pythonwin.exe? That would imply that you're trying to test it from inside the PythonWin IDE, correct? That may be the problem. GUI apps frequently don't play well with one another, and trying to run wxPython code from inside PythonWin (or IDLE) can cause problems. Try running your app from a command prompt, using plain python.exe.

Jeff Shannon
Technician/Programmer
Credit International

Frank Miles wrote:

from wxPython.wx import *
word=None

class WhatsTheWord(wxFrame):
    def __init__(self) :
        global word
        word= None
        wxFrame.__init__(self, NULL, -1, "Simple dialog",
            style = wxDEFAULT_FRAME_STYLE | wxNO_FULL_REPAINT_ON_RESIZE )
        self.dlg = wxTextEntryDialog(self, "Give me the word")
        if self.dlg.ShowModal() == wxID_OK :
            word= self.dlg.GetValue()
        self.dlg.Close(true)

if __name__ == "__main__" :
    WhatsTheWord()
    print "Received word ", word
# -------- end

This fragment runs fine on Linux, but crashes on my test Win98 box.
It appears to crash (stepping via debugger) in the "apply" that is
reached within 'wxTextEntryDialog(...)'.

You have no wxApp object. Also, you probably shouldn't ShowModal a dialog from within the wxFrame's constructor. There probably isn't any technical reason not to do it, but it's just plain silly.

···

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

Thanks to Jeff and Chuck for rightly pointing out my idiocy in using
pythonwin. That wasn't the problem, however... it crashed with other forms
of the interpreter as well. Shouldn't have used the NULL, either, that
should have been None. That stupidity was a cross breed between too much
C/C++/SQL programming, combined with the C/C++ based wxWindows documents.
What's most amazing about that is it running under Linux at all, the
interpreter presumably substituting a None value for the undefined NULL.
Pychecker didn't pick up that error, either.

There was a reason for it, however silly as it may appear. Separating the
wxTextEntryDialog from the frame/constructor eliminates the spurious frame
appearance. Robin, you are definitely on to something -- it's worse than
silly, because once the constructor is separated from the wxTextEntryDialog,
it runs without crashing.

A bit of an explanation for this seeming madness -- the original script from
which this was extracted -- occurs before the main application is run. It
gets a few parameters from the user which guide the main application
constructor and subsequent operation. I was trying to simplify the code,
and trying to reduce user confusion by eliminating the blank frame behind the
dialog box. At this point it's becoming clearer that the dialog boxes that
are so clean and simple (running in the demo code) aren't appropriate for
"stand-alone" use. I guess there's no real short-cut for the equivalent to
a dialog box outside of a full-blown application. It's not that involved,
I was trying to be too 'clever' about it I guess.

Thanks again for all your help!

  -frank

···

On Sat, 26 Apr 2003, Robin Dunn wrote:

Frank Miles wrote:
>
> from wxPython.wx import *
> word=None
>
> class WhatsTheWord(wxFrame):
> def __init__(self) :
> global word
> word= None
> wxFrame.__init__(self, NULL, -1, "Simple dialog",
> style = wxDEFAULT_FRAME_STYLE | wxNO_FULL_REPAINT_ON_RESIZE )
> self.dlg = wxTextEntryDialog(self, "Give me the word")
> if self.dlg.ShowModal() == wxID_OK :
> word= self.dlg.GetValue()
> self.dlg.Close(true)
>
> if __name__ == "__main__" :
> WhatsTheWord()
> print "Received word ", word
> # -------- end
>
> This fragment runs fine on Linux, but crashes on my test Win98 box.
> It appears to crash (stepping via debugger) in the "apply" that is
> reached within 'wxTextEntryDialog(...)'.
>

You have no wxApp object. Also, you probably shouldn't ShowModal a
dialog from within the wxFrame's constructor. There probably isn't any
technical reason not to do it, but it's just plain silly.