473,545 Members | 2,081 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

output

Hi folks,

I have a sript that runs very well. I do my output to the python shell
with the print command. That works well, too.
print 'Error occured ' + str(i+1)

No I want to have my output into a textctrl frame in a window. I start
my script by pushing a button in my window. It starts fine but I can't
see any output. For test purposes I added the following code to the
event handler of the button:
self.textCtrl1. WriteText('TEST \n')
This produces output to my text ctrl window. So I replaced all 'print'
commands in my script with 'self.textCtrl1 .WriteText ...' Unfortunately
it still doesn't work. I don't get any output from my script. I always
get an error saying self is unknown. That's why I replaced it with the
name of the file of the window and so on and so on. Nothing worked. Can
you help me telling me how I have to write my code to get an output?

Thank you very much.
Henry

Jul 18 '05 #1
2 3510
H.S. Art wrote:
I have a sript that runs very well. I do my output to the python shell
with the print command. That works well, too.
print 'Error occured ' + str(i+1)

No I want to have my output into a textctrl frame in a window. I start
my script by pushing a button in my window. It starts fine but I can't
see any output. For test purposes I added the following code to the
event handler of the button:

self.textCtrl1. WriteText('TEST \n')

This produces output to my text ctrl window. So I replaced all 'print'
commands in my script with 'self.textCtrl1 .WriteText ...'


someone else will have to sort the variable scoping issues for you [1],
but in the meantime, you could try the following little trick.

1) at the top of your program, import the "sys" module:

import sys

2) in the event handler, add the following redirection code:

# redirect output to my window
class redirect:
def __init__(self, window):
self.write = window.WriteTex t
sys.stdout = redirect(self.t extCtrl1)

</F>

1) the following links might be somewhat helpful:

http://www.python.org/doc/current/tu...00000000000000
http://www.python.org/doc/current/ref/naming.html (technical)


Jul 18 '05 #2
Thank you for your answer!
That "little" trick works perfect for me. :-)

Fredrik Lundh wrote:
H.S. Art wrote:
I have a sript that runs very well. I do my output to the python shell
with the print command. That works well, too.
print 'Error occured ' + str(i+1)

No I want to have my output into a textctrl frame in a window. I start
my script by pushing a button in my window. It starts fine but I can't
see any output. For test purposes I added the following code to the
event handler of the button:

self.textCtrl 1.WriteText('TE ST\n')

This produces output to my text ctrl window. So I replaced all 'print'
commands in my script with 'self.textCtrl1 .WriteText ...'


someone else will have to sort the variable scoping issues for you [1],
but in the meantime, you could try the following little trick.

1) at the top of your program, import the "sys" module:

import sys

2) in the event handler, add the following redirection code:

# redirect output to my window
class redirect:
def __init__(self, window):
self.write = window.WriteTex t
sys.stdout = redirect(self.t extCtrl1)

</F>

1) the following links might be somewhat helpful:

http://www.python.org/doc/current/tu...00000000000000
http://www.python.org/doc/current/ref/naming.html (technical)



Jul 18 '05 #3

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

Similar topics

4
8123
by: Mark Wilson CPU | last post by:
This must be easy, but I'm missing something... I want to execute a Perl script, and capture ALL its output into a PHP variable. Here are my 2 files: ------------------------------------- test3.pl ------------------------------------- print "PERL Hello from Perl! (plain print)<br>\n"; print STDERR "PERL This is text sent to STDERR<br>\n";...
3
2774
by: edgekaos | last post by:
Is method 2 valid? Method 1: wstring input = L"STRING"; wstring output = input; transform(output.begin(), output.end(), output.begin(), towupper); Method 2: wstring input = L"STRING"; wstring output;
4
15040
by: Kevin Mansel via .NET 247 | last post by:
Ok, basically this is my problem. I'm building a console app tocall a dos program. So i'm using the Shell command to call theprogram, now depending on what happens, I want to read theoutput that this program returns. I'm just missing the stepshere. I know that I can set the Shell command to an integer,but this only returns a 0 to me telling me...
24
2666
by: kalamantina | last post by:
#include "stdafx.h" #include <stdio.h> #define output( x ) printf( #x "\r\n" );fflush( stdout ) class CMyBase { public: CMyBase() { output( CMyBase() ); f(*this);
0
2053
by: newbie | last post by:
i'm a newbie of c language. can anyone help me to implement the code so that I can get the ciphertext from the output. thanks. #ifndef _3DES_H #define _3DES_H #ifndef uint8 #define uint8 unsigned char #endif
32
2739
by: spibou | last post by:
Is the output of the C preprocessor deterministic ? What I mean by that is , given 2 compilers which conform to the same standard, will their preprocessors produce identical output given as input the same file ? If not then how much variation is allowed ? Is it just a bit more or less white space here and there or could could there be larger...
3
2613
by: MatsL | last post by:
Hi, This is seriously driving me crazy, could anyone explain to me why neither of these doesn't produce XHTML compliant output (it is being called in Render() btw): output.WriteLine("<img src=\"" + vars + " />"); output.AddAttribute(HtmlTextWriterAttribute.Src, (string)vars); output.RenderBeginTag(HtmlTextWriterTag.Img);
3
4649
by: undshan | last post by:
I am writing a code that needs to open a file, create an output file, run through my function, prints the results to the output file, and closes them within a loop. Here is my code: #include <stdlib.h> #include <stdio.h> #include <math.h> #include <string.h> #include "util.h" //Main Loop
5
3315
by: amit.uttam | last post by:
Hey everyone, I've recently jumped big time into python and I'm working on a software program for testing automation. I had a question about proper logging of output. What I would like is: 1. a function syslog (to log output to log file only) 2. a function stdout (to log output to stdout only) 3. a function sslog (to log output to both...
2
3364
by: gabosom | last post by:
Hi! I've been breaking my head trying to get the output variables from my Stored Procedure. This is my SP code CREATE PROCEDURE GetKitchenOrderDetail( @idService int, --outPut Variables @idUser int OUTPUT,
0
7468
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7401
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7808
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7423
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7757
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5972
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5329
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
1
1014
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
704
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.