I'm also fed up with running wxPython programs that briefly
flash the window at me and quit with no error messages.
Is there some way to run wxPython programs where the errors in the code
are identified?
There is, in section 2.3.2, a discussion of wxPython's convention of
redirecting stdout to a separate window - by turning off this redirect you
can have all error messages/stack traces/etc written to the console instead
of the separate window. Or - you can choose to have this information
written into a file. I do agree that this convention is annoying until you
discover how to control it.
There is, in section 2.3.2, a discussion of wxPython's convention of
redirecting stdout to a separate window - by turning off this redirect you
can have all error messages/stack traces/etc written to the console instead
of the separate window. Or - you can choose to have this information
written into a file. I do agree that this convention is annoying until you
discover how to control it.
-jdc
I tried your suggestion, but if I change MyApp like this:
class MyApp(wx.App):
def __init__(self, fname):
self.fname = fname
wx.App.__init__(self, True)
where fname is something like "
log.txt"… Then run the script. After it has flashed at you, open the log.txt file in the directory where the script was run and you will see the error report…
That's because "True" means "redirect stdout and stderr to a window".
This can be very convenient when you're working with an application,
but it's a problem for beginners because if the app doesn't start up
(like what happens here) you lose the error information. You need to
read the docs more carefully - the docstring for wx.App.__init__
explains the keyword args.
···
On 4/20/07, 7stud <bbxx789_05ss@yahoo.com> wrote:
John Clark <clajo04 <at> mac.com> writes:
> There is, in section 2.3.2, a discussion of wxPython's convention of
> redirecting stdout to a separate window - by turning off this redirect you
> can have all error messages/stack traces/etc written to the console instead
> of the separate window. Or - you can choose to have this information
> written into a file. I do agree that this convention is annoying until you
> discover how to control it.
>
> -jdc
>
I tried your suggestion, but if I change MyApp like this:
class MyApp(wx.App):
def __init__(self, fname):
self.fname = fname
wx.App.__init__(self, True)
That's because "True" means "redirect stdout and stderr to a window".
This can be very convenient when you're working with an application,
but it's a problem for beginners because if the app doesn't start up
(like what happens here) you lose the error information. You need to
read the docs more carefully - the docstring for wx.App.__init__
explains the keyword args.
Well, my initial excitement over downloading the wxPython docs
and playing around with the wxDocsViewer was tempered by the
fact that I couldn't find any entries for wx.App.__init__. So, I had and
still have no API reference for wx.App.__init__.
Darn! Somewhere I read that the default value for 'redirect'
is False. However, when I explicitly use False, the error messages
go to my console window. Thanks!
Well, my initial excitement over downloading the wxPython docs
and playing around with the wxDocsViewer was tempered by the
fact that I couldn't find any entries for wx.App.__init__. So, I
had and still have no API reference for wx.App.__init__.
That's because "True" means "redirect stdout and stderr to a window".
This can be very convenient when you're working with an application,
but it's a problem for beginners because if the app doesn't start up
(like what happens here) you lose the error information. You need to
read the docs more carefully - the docstring for wx.App.__init__
explains the keyword args.
Well, my initial excitement over downloading the wxPython docs and playing around with the wxDocsViewer was tempered by the fact that I couldn't find any entries for wx.App.__init__. So, I had and still have no API reference for wx.App.__init__.
It has a Python docstring, so it will be in the Python-specific docs:
:param redirect: Should ``sys.stdout`` and ``sys.stderr`` be
redirected? Defaults to True on Windows and Mac, False
otherwise. If `filename` is None then output will be
redirected to a window that pops up as needed. (You can
control what kind of window is created for the output by
resetting the class variable ``outputWindowClass`` to a
class of your choosing.)
:param filename: The name of a file to redirect output to, if
redirect is True.
:param useBestVisual: Should the app try to use the best
available visual provided by the system (only relevant on
systems that have more than one visual.) This parameter
must be used instead of calling `SetUseBestVisual` later
on because it must be set before the underlying GUI
toolkit is initialized.
:param clearSigInt: Should SIGINT be cleared? This allows the
app to terminate upon a Ctrl-C in the console like other
GUI apps will.
:note: You should override OnInit to do applicaition
initialization to ensure that the system, toolkit and
wxWidgets are fully initialized.
···
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!
Darn! Somewhere I read that the default value for 'redirect'
is False. However, when I explicitly use False, the error messages
go to my console window. Thanks!
It depends on platform. It's False on wxGTK because people are typically launching from a console window there, at least during development. On Windows and Mac it defaults to True because folks are a little more likely to launch with a double click of the .py[w] file.
···
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!
Is there a global way to change the default for all scripts run on a particular computer?
Kevin Horton
Ottawa, Canada
···
On 20 Apr 2007, at 20:11, Robin Dunn wrote:
7stud wrote:
Right - I am pretty sure what you want is:
wx.App.__init__(self, False)
Darn! Somewhere I read that the default value for 'redirect'
is False. However, when I explicitly use False, the error messages
go to my console window. Thanks!
It depends on platform. It's False on wxGTK because people are typically launching from a console window there, at least during development. On Windows and Mac it defaults to True because folks are a little more likely to launch with a double click of the .py[w] file.
:param redirect: Should ``sys.stdout`` and ``sys.stderr`` be
redirected? Defaults to True on Windows and Mac, False
otherwise.
Just a note: is it possible at this point to change the default? I think we'd get a lot fewer confused newbies if the default was NOT to re-direct.
-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
I agree 100%. I wasted many hours trying to troubleshoot errors without being able to see the Python traceback, as I had not yet learned that I needed to set redirect to False. I made much quicker progress once I could see where my errors were coming from. As I understand it, the arguement to have the Windows and Mac default to True, is the belief that in most cases a console window will not be open. This may be true when an app is being used by the end user. But it certainly isn't true when a newbie is working on his first few apps.
If an app is being used by an end user, and a console window is not open, what is the harm to have redirect set to False?
Kevin Horton
Ottawa, Canada
···
On 23 Apr 2007, at 13:06, Christopher Barker wrote:
Robin Dunn wrote:
:param redirect: Should ``sys.stdout`` and ``sys.stderr`` be
redirected? Defaults to True on Windows and Mac, False
otherwise.
Just a note: is it possible at this point to change the default? I think we'd get a lot fewer confused newbies if the default was NOT to re-direct.
:param redirect: Should ``sys.stdout`` and ``sys.stderr`` be
redirected? Defaults to True on Windows and Mac, False
otherwise.
Just a note: is it possible at this point to change the default? I think we'd get a lot fewer confused newbies if the default was NOT to re-direct.
I'll consider it for 2.9. I think 2.8 should not change this since it is a stable version.
I agree 100%. I wasted many hours trying to troubleshoot errors without being able to see the Python traceback, as I had not yet learned that I needed to set redirect to False. I made much quicker progress once I could see where my errors were coming from. As I understand it, the arguement to have the Windows and Mac default to True, is the belief that in most cases a console window will not be open. This may be true when an app is being used by the end user. But it certainly isn't true when a newbie is working on his first few apps.
If an app is being used by an end user, and a console window is not open, what is the harm to have redirect set to False?
I'm not sure if it is still the case, but at one point in time on windows if you output a lot of stuff to the real stdout and there was no console window to write it to, then eventually the buffer would fill up and the program would be suspended until the buffer was emptied. If somebody wanted to try and reproduce this on win2k, XP and Vista to see if it is still an issue I would appreciate it.
···
On 23 Apr 2007, at 13:06, Christopher Barker wrote:
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!