By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,379 Members | 3,035 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,379 IT Pros & Developers. It's quick & easy.

Output to a text window

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.