Printing in the absence of console windows

This is an ugly situation: I've got a wxPython-based Windows app.

Now on to the really ugly part...

The Python code spits out diagnostic info via print statements.
Normally, these would never be seen by users, but when we are
developing they are invaluable. We have special glue to create a
Windows console when given a particular command line option so
this is what we use during development.

However, running without the console window causes the application
to crash when certain particular print statements are encountered.
We have absolutely no idea how to diagnose this one. Why does
Windows not just ignore these statements (/dev/null them)? Is there
a way to make it ignore them?

···

-------------------------------------------------------------------------------------
Jeff Kotula Systems Architecture Manager
Vital Images jkotula@vitalimages.com

Renunciation is not giving up the things of this world,
but accepting that they go away.
    -- Suzuki Roshi

Is there any reason why I can't call super() on a wxPython derived class?
here's two code snippets, one in Python, one with wxPython. The super() call
works in straight Python, but in wxPython, I get the following error:

Traceback (most recent call last):
  File "./MyApp.py", line 28, in ?
    app = MyApp(0)
  File "/usr/lib/python2.2/site-packages/wxPython/wx.py", line 1705, in
__init__
    _wxStart(self.OnInit)
  File "./MyApp.py", line 12, in OnInit
    self.panel.TestSuper()
  File "./MyApp.py", line 25, in TestSuper
    super(MyPanelB, self).TestSuper()
TypeError: super() argument 1 must be type, not class

--------PYTHON CODE------------
#!/usr/bin/python

class MyApp(object):
        def __init__(self):
                obj = MyClassB()
                obj.TestSuper()

class MyClassA(object):
        def __init__(self):
                pass
        def TestSuper(self):
                print "Superclass"

class MyClassB(MyClassA):
        def __init__(self):
                MyClassA.__init__(self)
        def TestSuper(self):
                super(MyClassB, self).TestSuper()
                print "Subclass"

app = MyApp()

--------wxPYTHON CODE------------
#!/usr/bin/python

from wxPython.wx import *

class MyApp(wxApp):
        def OnInit(self):
                self.mainframe = wxFrame(NULL, -1, "My Test App",
wxDefaultPosition, wxSize(640, 480))
                self.mainparent = self.mainframe
                self.panel = MyPanelB(self.mainparent)
                self.mainframe.Show()
                self.panel.TestSuper()
                return true

class MyPanelA(wxPanel):
        def __init__(self, parent):
                wxPanel.__init__(self, parent, -1, wxPoint(0,0), wxSize(640,
480))
        def TestSuper(self):
                print "Superclass"

class MyPanelB(MyPanelA):
        def __init__(self, parent):
                MyPanelA.__init__(self, parent)
        def TestSuper(self):
                super(MyPanelB, self).TestSuper()
                print "Subclass"

app = MyApp(0)
app.MainLoop()

Does this have to do with the fact that the wx* objects are not derived from
"object" at its highest levels?

-D

I'd think this is a result of the SWIG interface. You're not really using
wxPanel, instead youre using wxPanelPtr (the internal class that is SWIG
generated). Maybe this leads the super() call to the (from your perspective)
wrong object.

···

On Friday 22 November 2002 01:20 pm, Dave Kelly wrote:

Is there any reason why I can't call super() on a wxPython derived class?
here's two code snippets, one in Python, one with wxPython. The super()
call works in straight Python, but in wxPython, I get the following error:

Traceback (most recent call last):
  File "./MyApp.py", line 28, in ?
    app = MyApp(0)
  File "/usr/lib/python2.2/site-packages/wxPython/wx.py", line 1705, in
__init__
    _wxStart(self.OnInit)
  File "./MyApp.py", line 12, in OnInit
    self.panel.TestSuper()
  File "./MyApp.py", line 25, in TestSuper
    super(MyPanelB, self).TestSuper()
TypeError: super() argument 1 must be type, not class

--------PYTHON CODE------------
#!/usr/bin/python

class MyApp(object):
        def __init__(self):
                obj = MyClassB()
                obj.TestSuper()

class MyClassA(object):
        def __init__(self):
                pass
        def TestSuper(self):
                print "Superclass"

class MyClassB(MyClassA):
        def __init__(self):
                MyClassA.__init__(self)
        def TestSuper(self):
                super(MyClassB, self).TestSuper()
                print "Subclass"

app = MyApp()

--------wxPYTHON CODE------------
#!/usr/bin/python

from wxPython.wx import *

class MyApp(wxApp):
        def OnInit(self):
                self.mainframe = wxFrame(NULL, -1, "My Test App",
wxDefaultPosition, wxSize(640, 480))
                self.mainparent = self.mainframe
                self.panel = MyPanelB(self.mainparent)
                self.mainframe.Show()
                self.panel.TestSuper()
                return true

class MyPanelA(wxPanel):
        def __init__(self, parent):
                wxPanel.__init__(self, parent, -1, wxPoint(0,0),
wxSize(640, 480))
        def TestSuper(self):
                print "Superclass"

class MyPanelB(MyPanelA):
        def __init__(self, parent):
                MyPanelA.__init__(self, parent)
        def TestSuper(self):
                super(MyPanelB, self).TestSuper()
                print "Subclass"

app = MyApp(0)
app.MainLoop()

Does this have to do with the fact that the wx* objects are not derived
from "object" at its highest levels?

-D

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

--
  UC

--
Open Source Solutions 4U, LLC 2570 Fleetwood Drive
Phone: +1 650 872 2425 San Bruno, CA 94066
Cell: +1 650 302 2405 United States
Fax: +1 650 872 2417