473,406 Members | 2,369 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Output to a text window

Hi,

I'm going around in circles so I'm asking for help. I want to read a
simple text file and output the contents to a GUI window when I click
on a button. I have written a small python program to read the
contents of a file when a button is clicked but can only output this
to a console window. I'm using the pygtk binding with glade for the
gui.

I know it must be quiet simple but a mental block has rapidly
descended.

Any help would be appreciated.

Feb 17 '07 #1
3 6794
go****@orcon.net.nz wrote:
Hi,

I'm going around in circles so I'm asking for help. I want to read a
simple text file and output the contents to a GUI window when I click
on a button. I have written a small python program to read the
contents of a file when a button is clicked but can only output this
to a console window. I'm using the pygtk binding with glade for the
gui.

I know it must be quiet simple but a mental block has rapidly
descended.

Any help would be appreciated.
What does your code look like? What are you using to print? Are you
writing to the GUI or using the 'print statement?'

j

--
Joshua Kugler
Lead System Admin -- Senior Programmer
http://www.eeinternet.com
PGP Key: http://pgp.mit.edu/ Â*ID 0xDB26D7CE

--
Posted via a free Usenet account from http://www.teranews.com

Feb 17 '07 #2
On Feb 17, 1:25 pm, "Joshua J. Kugler" <jos...@eeinternet.comwrote:
goo...@orcon.net.nz wrote:
Hi,
I'm going around in circles so I'm asking for help. I want to read a
simple text file and output the contents to a GUI window when I click
on a button. I have written a small python program to read the
contents of a file when a button is clicked but can only output this
to a console window. I'm using the pygtk binding with glade for the
gui.
I know it must be quiet simple but a mental block has rapidly
descended.
Any help would be appreciated.

What does your code look like? What are you using to print? Are you
writing to the GUI or using the 'print statement?'

j

--
Joshua Kugler
Lead System Admin -- Senior Programmerhttp://www.eeinternet.com
PGP Key:http://pgp.mit.edu/ ID 0xDB26D7CE

--
Posted via a free Usenet account fromhttp://www.teranews.com
This is the code, it was adapted from code I found on the net. Code as
follows,

#!/usr/bin/python

import pygtk
import gtk
import gtk.glade
import string
import os
import gobject

class gui:
def __init__(self):
self.wTree=gtk.glade.XML('dansgui.glade')
dic = { "on_Read_File": self.on_Read_File,
"on_cancel": (gtk.main_quit)}
self.wTree.signal_autoconnect(dic)
self.count = 0
self.win = self.wTree.get_widget("window1")
self.win.connect("delete_event", self.on_delete_event)
self.win.show()

def on_Read_File(self, widget):
print "Opening Dansguardian bannedsitelist file for reading..."
print; print
lineoftext = open('/etc/dansguardian/lists/bannedsitelist', 'r')
myarray = []
lnum = 0
for line in lineoftext:
line = line.rstrip('\n')
line = line.rstrip( )
lnum = lnum + 1
print lnum , line
myarray.append(line);
lineoftext.close( )

def on_delete_event(self, widget, event):
self.win.set_sensitive(False)
dialog = gtk.MessageDialog(self.win,
gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
gtk.MESSAGE_INFO, gtk.BUTTONS_YES_NO, None)
dialog.set_markup('<big><b>Are you sure you want to quit?</
b></big>')
dialog.connect("destroy", lambda w:
self.win.set_sensitive(True))
answer = dialog.run()
if answer == -8:
dialog.destroy()
return False

if answer == -9:
dialog.destroy()
return True

app = gui()
gtk.main()

Feb 17 '07 #3
Hi,

http://spinecho.ifrance.com/frmouter...2-wxpy2621.zip

I use this gui windows written by jean marie fauth, which is very
easy: printing to stdout or stderr (gui windows written in wxpython).

You have only to translate frmouterr in pygtk.

ph DALET

FRANCE




On 17 fév, 01:19, goo...@orcon.net.nz wrote:
Hi,

I'm going around in circles so I'm asking for help. I want to read a
simple text file and output the contents to a GUI window when I click
on a button. I have written a small python program to read the
contents of a file when a button is clicked but can only output this
to a console window. I'm using the pygtk binding with glade for the
gui.

I know it must be quiet simple but a mental block has rapidly
descended.

Any help would be appreciated.

Feb 17 '07 #4

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

Similar topics

2
by: H.S. Art | last post by:
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...
4
by: flamesrock | last post by:
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....
2
by: Magesh | last post by:
Hi, I am trying to do the following 1. On form submit, open a window with three frames 2. Set the target as one of the frames 3. Set the action for the frame It is working properly in...
1
by: noleander | last post by:
Hi. I've got a C++ program written in Visual C++ 2003. The program is trivial, created with the Program-creation wizard: used the .NET "Form" template. The program has a trivial...
6
by: Roy Chastain | last post by:
I have the following simple aspx page hosted on a Win2k server with version 1.0 of the framework <%@ Page Language="C#" debug="true" %> <script runat="server" language="C#"> void Page_Load...
4
by: astromac | last post by:
I'm new to php and was wondering if the following was possible... I would like to have a list of items loaded from a text file, process each item in the list and then return the processed result...
0
by: ptek | last post by:
Hi, I'm using Vstudio 2005 and I did a Windows Application project where I also want to read arguments from command line and output some text when appropriate (for example, typing the correct...
3
by: TC | last post by:
I'm trying to debug a console application, but I can't see the console output. I've seen many references which say that console output is supposed to appear on the Output window when the...
14
by: =?Utf-8?B?R2lkaQ==?= | last post by:
Hi, In my windows applicationm, i need to excute a batch file. this batch file throws some text and questions to the screen, i need to catch the standard Output, check if it's a question, in...
3
by: Curious | last post by:
I''ve created a simple Console Application in C#.NET (.NET 2.0), and I have the following code: Console.WriteLine("Now let us begin!"); However, the string, "Now let us begin!", never shows up...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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
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
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...
0
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...

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.