473,505 Members | 13,805 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

wxPython: Terminal Output -> Scrollable Panel?

First, I'm very new to gui programming, so please go lightly on me :)

Ok, so far I've settled on wxPython, and what I'd like to do as a first
leap is *convert* a text program into a gui program. It would have a
few buttons as function controls and one main scrollable panel that
acts like a terminal window.

I want to make it so that clicking on a button that performs an
operation will output it to the scrollable wxpython terminal panel, and
(if possible) save that output as text (or maybe into a logfile).

Anyone know how to do this? Like a log window? I've seen something like
this in a program called 'nicotine' but have no idea how to implement
it myself.

-thanks

Jul 19 '05 #1
4 4053
flamesrock wrote:
I want to make it so that clicking on a button that performs an
operation will output it to the scrollable wxpython terminal panel, and
(if possible) save that output as text (or maybe into a logfile).


The example code includes something called "PyCrust" which does pretty
much this. (The logging part is fairly trivial, so I won't mention it.)
I'm sure you could look in the source to learn more. You can start by
running the demo, and finding that particular one, playing with it a
bit, and then seeing how the demo code invokes PyCrust. Then find the
source for PyCrust in the wxPython folder (under your lib/site-packages
folder in c:\python24) and start reading.

-Peter
Jul 19 '05 #2
Thanks much for your response.

I looked at PyCrust, and while its given me a few cool ideas, I may
have described the problem incorrectly. What I really need is not
something that takes input, but merely redirects the 'print' statements
to something like a terminal window.

Is this even possible without entering the function calls directly into
a pycrust like terminal? Maybe I'm trying to do the wrong thing.

Thanks

Peter Hansen wrote:
flamesrock wrote:
I want to make it so that clicking on a button that performs an
operation will output it to the scrollable wxpython terminal panel, and
(if possible) save that output as text (or maybe into a logfile).


The example code includes something called "PyCrust" which does pretty
much this. (The logging part is fairly trivial, so I won't mention it.)
I'm sure you could look in the source to learn more. You can start by
running the demo, and finding that particular one, playing with it a
bit, and then seeing how the demo code invokes PyCrust. Then find the
source for PyCrust in the wxPython folder (under your lib/site-packages
folder in c:\python24) and start reading.

-Peter


Jul 19 '05 #3
flamesrock wrote:
I looked at PyCrust, and while its given me a few cool ideas, I may
have described the problem incorrectly. What I really need is not
something that takes input, but merely redirects the 'print' statements
to something like a terminal window.

Is this even possible without entering the function calls directly into
a pycrust like terminal? Maybe I'm trying to do the wrong thing.


PyCrust would show you a mechanism to get lines of text into a "terminal
window". Actually capturing those lines of output is a different story.
Here's one approach, if you have control over the print statements:

class Redirector:
def __init__(self, infoAboutTerminal):
# store "infoAboutTerminal" in local attributes

def write(self, text):
'''output lines of text to terminal window'''
# here you do whatever PyCrust does to get output to its window
# using the info stored in the constructor

Assuming you have a PyCrust-like terminal window open somewhere,
you would create a Redirector and pass it whatever info about the
terminal window that it might need.

terminal = Redirector(infoAboutPyCrustLikeWindow)

Then just send your prints to this location using the >> syntax sugar:

print >>terminal, 'This line of text goes to the GUI window.'
print >>terminal, 'So does all this\neven multiple lines...'

If you *don't* have the ability to change the print statements like
this, then you can install a Redirector in place of sys.stdout, but that
will affect all prints, including those in standard library modules and
elsewhere.

HTH
-Peter
Jul 19 '05 #4
Exactly what I'm looking for! Thanks

Jul 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1303
by: Russell Reagan | last post by:
I installed wxPython 2.4.2.4 from the prebuilt binary for Windows. I am using the Cygwin version of Python 2.3.2. After installing wxPython, I ran the minimal window script:...
15
3092
by: Polerio Babao Jr.II | last post by:
Please correct me if im wrong. I have depended much on python and wxpython gui apps. After a year of using python apps I was able to do good application written entirely in python. One big problem...
13
4551
by: Peter Maas | last post by:
Recently I replaced Win2k with Linux on my desktop computer. Using mostly multi-platform software I thought this would be easy. It was not as easy as expected getting wxPython to work. There seemed...
2
4020
by: Grzegorz | last post by:
Hello, I'm using eclipse with pydev plugin, I'm working on a program using wxpython . When I'm executing that application standard error output does not show in eclipse console window - wxpython...
16
2682
by: John Salerno | last post by:
Here's my new project: I want to write a little script that I can type at the terminal like this: $ scriptname package1 where scriptname is my module name and any subsequent arguments are the...
4
5123
by: 7stud | last post by:
Hi, I'm using an intel imac which came with python 2.3.5 pre-intstalled on OS 10.4.7. I was able run a hello world wxPython script in Terminal by typing: $pythonw wxPythonTest.py ...
13
4584
by: sayansayan | last post by:
two threads are running in a prog i need the output of one thread in a new terminal which the prog will create and the output of other thread in the old terminal
44
4948
by: bg_ie | last post by:
Hi, I'm in the process of writing some code and noticed a strange problem while doing so. I'm working with PythonWin 210 built for Python 2.5. I noticed the problem for the last py file...
4
2175
by: Timothy Smith | last post by:
Not sure exactly what I need to do to get wxPython to work on either of my Macs. (One's a notebook running Tiger (OS X 10.4.11), the other a Mac Pro running Leopard (10.5.1.)) I downloaded what...
2
1585
by: David | last post by:
Hi list. I've never used unicode in a Python script before, but I need to now. I'm not sure where to start. I'm hoping that a kind soul can help me out here. My current (almost non-existant)...
0
7213
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7298
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7366
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7471
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5610
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3187
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1526
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
754
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
406
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.