wx.Timer and wx.py.shell. Where does print output go?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

wx.Timer and wx.py.shell. Where does print output go?

bradcan
I'm struggling to understand what's going on with my wxpython application containing a py.shell in a panel and some wx.Timer instances.

Here's the scenario:

I have a separate  module containing a class which inherits from wx.Timer. Obviously,  it must import wx otherwise wx is undefined when my module is imported.

I import my timer module into the py.shell and instantiate a timer to which I pass some local (to the shell) test function. This function just prints some messages does some counting and stops the timer, but the messages DON'T appear. Why? I know the timer is running and calling the function because on completion the counting has executed.

If on the other hand I import my module to my main wx then exactly the same test in the shell prints the messages, but to the terminal from which the application was started, not the shell.

The ultimate purpose of the timer module is a bit complicated, but essentially to manage binding to the passed in functions, doing some counting and finally unbinding.

Obviously the solution is to import to main, but I want to understand what's going on. Again obviously, the indirect import of wx into the py.shell is a no no. So Two questions:

  In the first case, where does the print output go?
  In the second, why is the output going to the evoking terminal and not to the py.shell?
  Actually 3 - what happens if the application is run without a terminal using #!/usr/bin/python

I'm running under Linux if that has any bearing. The  module and test code is attached.

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

post.txt (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: wx.Timer and wx.py.shell. Where does print output go?

bradcan
 This is deeply curious if I append this snippet to my test code in the shell:

while timer.IsRunning():
     t = wx.Yield()

Then bizarrely the print output appears in the shell. How does that work?

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: wx.Timer and wx.py.shell. Where does print output go?

Robin Dunn
[hidden email] wrote:
>  This is deeply curious if I append this snippet to my test code in
> the shell:
>
> while timer.IsRunning():
>      t = wx.Yield()
>

IIRC, while the shell is running a line or block of Python code then the
sys.stdout and sys.stderr are directed to the editor window. When it's
sitting there waiting for input then the output files are reset to
whatever they were when the shell was started.


--
Robin Dunn
Software Craftsman
http://wxPython.org

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Loading...