#1
  1. Wacky hack
    Devshed Novice (500 - 999 posts)

    Join Date
    Apr 2001
    Location
    London, England
    Posts
    513
    Rep Power
    14

    PyQT/gui programming prob with updating widgets


    I've just started working with PyQt, which is so much nicer to work with than Tk, especially with Qt designer But these questions might also be answered by PyTk people, as it's probably a general GUI toolkit problem, not PyQt specific (hmmm).

    Anyway, I've got a few questions:

    1. I've got a function which scans the DVD drive with a seperate process for each track, getting length and chapter information. After each track is scanned, it prints out the results to the shell and puts the result into a QListView. The odd thing is that it prints the text out as it goes along, but only updates the QListView at the end. How can I make it so entries are put into QListView as it goes along?

    [php]
    Pseudo-Code:

    print "Scanning DVD..."

    for i in numtracks:
    popen scanning programs, chop out info

    item = QListViewItem(self.dvdTracks,None)
    item.setText(0,title_label)
    item.setText(1,self.tr(time_label))
    print "Track %s: %s" % (i, time_label)

    print "Finished"
    [php]

    And related to this is that I'd like to change the text on the button that is connected to the function when the function stars and ends, so while it's scanning, the button reads "Scanning...", and then is set back. Again, what seems to happen is that it only changes the button text when it reaches the end of the function.

    Any hints/answers are most welcome
    Last edited by telex4; February 24th, 2003 at 11:59 AM.
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Posts
    2
    Rep Power
    0
    Did you ever figure out how to do that?

    I'm trying to pipe the output of a shell command to a QTextEdit to show the output in real time and I can't figure out a good way of doing it.
  4. #3
  5. Wacky hack
    Devshed Novice (500 - 999 posts)

    Join Date
    Apr 2001
    Location
    London, England
    Posts
    513
    Rep Power
    14
    Yes, you need to do this:

    app.processEvents()

    Where app is the application object you created from QApplication

    Call that in the loop in which you process the data from the pipe and the GUI will update itself in the loop
  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Posts
    2
    Rep Power
    0
    thanks, i'll give that a try. i wasnt actually processing the output and therefore i have no loop but i'll try to make something up...

IMN logo majestic logo threadwatch logo seochat tools logo