Separate logscreen under Windows

Hi List,

First of I wish you all a happy newyear!

Probably a stupid question, but here it is. I developed an application that
runs OK under Linux, but using windows a separate logscreen appears that
closes when the application ends.

The application uses the logging module (new in Python 2.3), and I do not want
the separate window to appear, I want the output that is displayed in the
separate window to be processed by the logging module.

I have experimented with wxLog, but it doesn't do the things I want.

Cheers,

···

--

D.J. Kniep
Lindix BV

Hi D.J.

Probably a stupid answer, but I have a utility class:

···

~~~~~~~~~~~~~~~~~~

class StreamRedirector :
    def __init__( self, old_stream, text_ctrl ) :
        self.is_open = True
        self.old_stream = old_stream
        self.text_ctrl = text_ctrl

    # def read !

    def write( self, data ) :
        if self.is_open :
            self.text_ctrl.AppendText( data )

    def flush( self ) :
        pass

    def close( self ) :
        self.is_open = False

    def previous_stream( self ) :
        return self.old_stream
        
~~~~~~~~~~~~~~~~~~

which I use thus:

        # redirect standard output
        sys.stdout = utilswx.StreamRedirector( sys.stdout, self.Log )

where self.Log is a TextCtrl.

In message <200312271336.35863.dick.kniep@lindix.nl>, Dick Kniep <dick.kniep@lindix.nl> writes:

Hi List,

First of I wish you all a happy newyear!

Probably a stupid question, but here it is. I developed an application that
runs OK under Linux, but using windows a separate logscreen appears that
closes when the application ends.

The application uses the logging module (new in Python 2.3), and I do not want
the separate window to appear, I want the output that is displayed in the
separate window to be processed by the logging module.

I have experimented with wxLog, but it doesn't do the things I want.

Cheers,
--

D.J. Kniep
Lindix BV

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

--
Pythonologist

Hi Pythonologist,

Thanks, I have checked your solution, but by simply using the proper
statements in the logging module itself it worked already. So I simply was a
moron :wink:

However I am still curious why there is a difference between Windows and
Linux. Probably because the streams stderr and stdout are treated differently
under Windows and Linux.

Thanks anyway

Cheers
D.J

Dick Kniep wrote:

Hi Pythonologist,

Thanks, I have checked your solution, but by simply using the proper statements in the logging module itself it worked already. So I simply was a moron :wink:

However I am still curious why there is a difference between Windows and Linux. Probably because the streams stderr and stdout are treated differently under Windows and Linux.

The default value of the first parameter to wxApp.__init__ is dependent on platform. On Windows and Mac it will be True which will cause the redirection of sys.stdout and sys.stderr to a file like object that opens a window when there is data written to either of those files. On Unix the default is False and so there is no redirection.

···

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