[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    [PyQt] Re: processEvents on QlistWidget operations does nothing
From:       Andreas Pakulat <apaku () gmx ! de>
Date:       2008-01-28 9:53:57
Message-ID: 20080128095357.GG316 () morpheus ! apaku ! dnsalias ! org
[Download RAW message or body]

On 28.01.08 09:58:20, P. Mathé wrote:
> Thank you Scott for your answer, but unnless I didn'y understand you correctly, it \
> does not work : the timer singleshot is fired only after the loop ends.

Unfortunately you didn't understand correctly. What Scott meant was
that the slot connected to the singleshot should download the stuff with
urllib, then update the listwidget and then return control to the event
loop (and if jours is not empty schedule another singleshot timer).

Something like this should work:

class radioProgDialog(QDialog, radioUi):
    def __init__(self):
        QDialog.__init__(self)
        # Set up the user interface 
        self.setupUi(self)
        self.connect(self.btnGo,SIGNAL("clicked()"),self.extraire)
        #

    def updateGui(self):
        d=self.d
        jour = self.jours.last()
        self.jours.removeAll( jour )
        next_url=url % jour
        p=urllib.urlopen(next_url).read()
        self.d=DateFromTicks(jour)
        logText=u'téléchargement %02d/%02d/%d' % (d.day,d.month,d.year)
        self.log.insertItem(0, QListWidgetItem(logText))
        self.progressBar.setValue(self.progressBar.value() + 1) 
        print logText
        if( self.jours.isEmpty() ):
           QTimer.singleShot(0, self.updateGui)
            
        
        
    def extraire(self):
        self.url='http://www.radiofrance.fr/francevivace/prog/index.php?time=%u'
        # 
        self.jours=[(int((now() + (j * oneDay)).ticks())) for j in range(0, 4)]
        self.progressBar.setMaximum(len(jours))
        self.progressBar.setValue(0)
        print 'maxi', self.progressBar.maximum()
        QTimer.singleShot(0, self.updateGui)
        print 'fini Vivace'

Andreas

-- 
Tomorrow will be cancelled due to lack of interest.
_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic