-   Programming (
-   -   Python/PyQt4 - Newbie Structure question (

ocularb0b 01-28-2008 10:42 AM

Python/PyQt4 - Newbie Structure question
Ok i've been playing with PyQt4
i have made the following app that works fine:


#!/usr/bin/env python

import sys
import time
from PyQt4 import QtGui, QtCore

class MainWindow(QtGui.QWidget):
    def __init__(self):
    def buildWindow(self, parent=None):
            QtGui.QWidget.__init__(self, parent)
        self.setGeometry(150, 100, 800, 600)
        self.setWindowTitle('::System Log::')
        quitBtn = QtGui.QPushButton('close', self)
        quitBtn.setGeometry(720, 550, 60, 40)
        self.connect(quitBtn, QtCore.SIGNAL('clicked()'),
            QtGui.qApp, QtCore.SLOT('quit()'))
        self.logwidget = QtGui.QTextEdit('', self)
        self.logwidget.setGeometry(5, 5, 790, 540)
        self.logwidget.append('Welcome Jerks!')

    def LogParse(self):
        logfile = open('/var/log/syslog', 'r')
        for line in logfile:

app = QtGui.QApplication(sys.argv)
mainwindow = MainWindow()

However im confused about how it is exectued. I would like see the main window and then run 'LogParse()' to fill the QTextEdit widget. As is the main window doesn't appear until after 'LogParse' runs. Ultimately i want 'LogParse' inside a 'while' loop with a sleep() to update the contents of the QTextEdit widget every few seconds.
I've missed something fundamental here and cant seem to rearange things to work this way.
Can someone show me what that might look like?
Thanks in advance

All times are GMT -5. The time now is 07:43 AM.