Newbie -- how can "Hello, world" crash?

Greetings, everyone,

I'm a research biologist. Nine years ago I worked for a medical
instrumentation company where my duties included some programming. We
were developing a data acquisition environment for Windows 3.1. After
devoting nine years to programming the most troublesome computers of
all, namely living cells, I have taken an interest in programming
silicon again. I asked some questions about the newest generation of
high-level programming languages, and ultimately ended up selecting
Python. I am very pleased with my choice, in no small measure due to
the great user community.

I've spent the last two months getting my feet wet with text-only
applications. I have written several utility programs in Python 2.2.2,
and I'm using the default shell for Windows, namely IDLE 0.8. It was
always my intention to return to GUI programming. I've made my first
attempts with wxWindows, and it's clear that I have to fix something
very basic before I can go anywhere.

Here's the bonehead-simple code. You've probably seen it on the
WxPython tutorial page.

···

----------

from wxPython.wx import *

class MyApp(wxApp):
    def OnInit(self):
        frame = wxFrame(NULL, -1, "Hello from wxPython")
        frame.Show(true)
        self.SetTopWindow(frame)
        return true

app = MyApp(0)
app.MainLoop()

----------

I load this code into IDLE, as I have done with all of my text-only
applications. Up pops a window, so far so good. You can resize it and
close it using the default wxFrame methods.

Now, I know that what I'm about to describe is irrelevant to this
particular application, but bear with me. In another GUI program I'm
writing, I'm (temporarily) using stdout to report event information,
which means that I tend to want to rearrange the windows a bit.

If, after my window comes up, I shift the focus to an IDLE window and
try to move or resize it, the whole IDLE environment crashes. Up pops
a dialog box which reads: "Microsoft Visual C++ Runtime Library /
Runtime Error! / Program C:\Python22\pythonw.exe / abnormal program
termination".

This only happens when I try to adjust an IDLE window which is clipped
by my application window. If I move or resize windows owned by other
applications, or if I've resized the IDLE windows so that they do not
clip my application window prior to executing the script, then
everything behaves gracefully.

WxWindows comes with these two applications called PyCrust and
PyShell. They look and feel as if should somehow substitute for IDLE.
But I'll be darned if I can figure out how to actually run a script...
the menu bar doesn't include an "open" selection, and the help files
appear to be a Python language reference, rather than a reference to
the shell itself.

Is my crash the result of a conflict between Tkinter and wxWindows?
Will moving to another shell fix this problem?

Thanks for your help!

--
John J. Ladasky Jr., Ph.D.
Department of Biology
Johns Hopkins University
Baltimore MD 21218
USA
Earth

Yes, this is no doubt the problem. Tkinter and wxPython do not
play well together. The way I usually test my wxPython code is
simply to invoke it from a C:/> command line. Then when my stuff
crashes I get a helpful traceback.

Kind regards,

···

--- JOHN LADASKY LADASKY <john.ladasky@comcast.net> wrote:

Is my crash the result of a conflict between Tkinter and
wxWindows? Will moving to another shell fix this problem?

=====
Donnal Walter
Arkansas Children's Hospital

Yep, you can't run a GUI script "in-process" it needs to be run outside the
editor/shell environment. This can be done a variety of ways from the shell
or within a Python program. Wing IDE and Komodo and I believe the new
version of IDLE (IDLEfork to be included with Python 2.3) all run scripts
correctly. Pythonwin and the current IDLE do not.

The PythonCard codeEditor works as well.

  codeEditor tool

I don't have time to go into the details right now, but if you look at the
runScript method in codeEditor.py you'll see how os.spawnv is used to launch
a script in the right directory with or without the -i (use interpreter)
option. The -i option means that even if you have a syntax error or other
traceback, the command prompt window won't disappear so you can debug the
problem.

ka

···

-----Original Message-----

Is my crash the result of a conflict between Tkinter and wxWindows?
Will moving to another shell fix this problem?

As another newbie, I have found Scite absolutely sensational for working with wxPython files - press F5 to run the current active file, as well as being a good ( & free!) editor. (http://www.scintilla.org/SciTE.html)

PyCrust & PyShell are similarly indispensible to my way of working, but I embed them in the app, rather than the other way around. See attached app.

Worth a look.

Chris.

PyCrustApp.py (2.63 KB)

···

----- Original Message -----
From: JOHN LADASKY LADASKY
To: wxpython-users@lists.wxwindows.org
Sent: Monday, March 24, 2003 5:48 AM
Subject: [wxPython-users] Newbie -- how can "Hello, world" crash?

Greetings, everyone,

I'm a research biologist. Nine years ago I worked for a medical
instrumentation company where my duties included some programming. We
were developing a data acquisition environment for Windows 3.1. After
devoting nine years to programming the most troublesome computers of
all, namely living cells, I have taken an interest in programming
silicon again. I asked some questions about the newest generation of
high-level programming languages, and ultimately ended up selecting
Python. I am very pleased with my choice, in no small measure due to
the great user community.

I've spent the last two months getting my feet wet with text-only
applications. I have written several utility programs in Python 2.2.2,
and I'm using the default shell for Windows, namely IDLE 0.8. It was
always my intention to return to GUI programming. I've made my first
attempts with wxWindows, and it's clear that I have to fix something
very basic before I can go anywhere.

Here's the bonehead-simple code. You've probably seen it on the
WxPython tutorial page.

----------

from wxPython.wx import *

class MyApp(wxApp):
    def OnInit(self):
        frame = wxFrame(NULL, -1, "Hello from wxPython")
        frame.Show(true)
        self.SetTopWindow(frame)
        return true

app = MyApp(0)
app.MainLoop()

----------

I load this code into IDLE, as I have done with all of my text-only
applications. Up pops a window, so far so good. You can resize it and
close it using the default wxFrame methods.

Now, I know that what I'm about to describe is irrelevant to this
particular application, but bear with me. In another GUI program I'm
writing, I'm (temporarily) using stdout to report event information,
which means that I tend to want to rearrange the windows a bit.

If, after my window comes up, I shift the focus to an IDLE window and
try to move or resize it, the whole IDLE environment crashes. Up pops
a dialog box which reads: "Microsoft Visual C++ Runtime Library /
Runtime Error! / Program C:\Python22\pythonw.exe / abnormal program
termination".

This only happens when I try to adjust an IDLE window which is clipped
by my application window. If I move or resize windows owned by other
applications, or if I've resized the IDLE windows so that they do not
clip my application window prior to executing the script, then
everything behaves gracefully.

WxWindows comes with these two applications called PyCrust and
PyShell. They look and feel as if should somehow substitute for IDLE.
But I'll be darned if I can figure out how to actually run a script...
the menu bar doesn't include an "open" selection, and the help files
appear to be a Python language reference, rather than a reference to
the shell itself.

Is my crash the result of a conflict between Tkinter and wxWindows?
Will moving to another shell fix this problem?

Thanks for your help!

--
John J. Ladasky Jr., Ph.D.
Department of Biology
Johns Hopkins University
Baltimore MD 21218
USA
Earth

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org

Hi John,

You might want to have a look at Boa - Boa Constructor - wxPython GUI Builder download | SourceForge.net, note that if you use very recent version of wxPython (2.4x) you need to download from CVS. I am using python 2.2.2 and wxPython 2.3.4.2 with Boa 0.2.0.

See you
Werner

JOHN LADASKY LADASKY wrote:

···

Greetings, everyone,

I'm a research biologist. Nine years ago I worked for a medical instrumentation company where my duties included some programming. We were developing a data acquisition environment for Windows 3.1. After devoting nine years to programming the most troublesome computers of all, namely living cells, I have taken an interest in programming silicon again. I asked some questions about the newest generation of high-level programming languages, and ultimately ended up selecting Python. I am very pleased with my choice, in no small measure due to the great user community.

I've spent the last two months getting my feet wet with text-only applications. I have written several utility programs in Python 2.2.2, and I'm using the default shell for Windows, namely IDLE 0.8. It was always my intention to return to GUI programming. I've made my first attempts with wxWindows, and it's clear that I have to fix something very basic before I can go anywhere.

Here's the bonehead-simple code. You've probably seen it on the WxPython tutorial page.

----------

from wxPython.wx import *

class MyApp(wxApp):
   def OnInit(self):
       frame = wxFrame(NULL, -1, "Hello from wxPython")
       frame.Show(true)
       self.SetTopWindow(frame)
       return true

app = MyApp(0)
app.MainLoop()

----------

I load this code into IDLE, as I have done with all of my text-only applications. Up pops a window, so far so good. You can resize it and close it using the default wxFrame methods.

Now, I know that what I'm about to describe is irrelevant to this particular application, but bear with me. In another GUI program I'm writing, I'm (temporarily) using stdout to report event information, which means that I tend to want to rearrange the windows a bit.

If, after my window comes up, I shift the focus to an IDLE window and try to move or resize it, the whole IDLE environment crashes. Up pops a dialog box which reads: "Microsoft Visual C++ Runtime Library / Runtime Error! / Program C:\Python22\pythonw.exe / abnormal program termination".

This only happens when I try to adjust an IDLE window which is clipped by my application window. If I move or resize windows owned by other applications, or if I've resized the IDLE windows so that they do not clip my application window prior to executing the script, then everything behaves gracefully.

WxWindows comes with these two applications called PyCrust and PyShell. They look and feel as if should somehow substitute for IDLE. But I'll be darned if I can figure out how to actually run a script... the menu bar doesn't include an "open" selection, and the help files appear to be a Python language reference, rather than a reference to the shell itself.

Is my crash the result of a conflict between Tkinter and wxWindows? Will moving to another shell fix this problem?

Thanks for your help!

--
John J. Ladasky Jr., Ph.D.
Department of Biology
Johns Hopkins University
Baltimore MD 21218
USA
Earth

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org

Yep, IDLEFork runs the program you are editing in a separate
process. Note that you don't need to upgrade to the Python
2.3 alpha to use it today. IDLEFork can be downloaded from
http://idlefork.sourceforge.net/ and installed with Python 2.2.

···

At 11:40 2003-03-23 -0800, Kevin Altis wrote:

I believe the new
version of IDLE (IDLEfork to be included with Python 2.3) [all] run scripts
correctly.

--
Magnus Lycka, Thinkware AB
Alvans vag 99, SE-907 50 UMEA, SWEDEN
phone: int+46 70 582 80 65, fax: int+46 70 612 80 65
http://www.thinkware.se/ mailto:magnus@thinkware.se

JOHN LADASKY LADASKY <john.ladasky@comcast.net> writes:

WxWindows comes with these two applications called PyCrust and
PyShell. They look and feel as if should somehow substitute for IDLE.
But I'll be darned if I can figure out how to actually run a script...
the menu bar doesn't include an "open" selection, and the help files
appear to be a Python language reference, rather than a reference to
the shell itself.

PyCrust (and PyShell) are Python shells. They are not editors, nor do
they allow you to open a .py file and run it. I may do this some day,
but I'm not in a big hurry. The focus of the PyCrust package is on
the runtime environment. If you need an editor, use Emacs. If you
need to run your programs, do so from the command line. If you want
to inspect your wxPython program while it's running, use PyCrust. :wink:

···

--
Patrick K. O'Brien
Orbtech http://www.orbtech.com/web/pobrien
-----------------------------------------------
"Your source for Python programming expertise."
-----------------------------------------------