[PyQt] QPainter again

lucaberto at libero.it lucaberto at libero.it
Fri Dec 14 08:14:44 GMT 2007


Hello i have do as follow:

  def on_pushButton_5_clicked(self):
        """
        Slot documentation goes here.
        """
        # TODO: not implemented yet
        #raise NotImplementedError
        gra = QtGui.QPainter(self.miaPictureFrame.immagine)
        import math
        from time import sleep
        nome_cal = self.lineEdit.text()
        if nome_cal =='':
            while 2 :
                dlg_line = QtGui.QMessageBox.warning(self,'Pls Attention',  'You must insert a name for the calibration', QtGui.QMessageBox.Cancel)
                break
        else :
            pen = QtGui.QPen()
            pen.setWidth(1)
        #disegno contorno grafico
            gra.setPen(pen)
            gra.drawText(30, 35, '50 daN/mm')
            gra.drawText(395, 30, nome_cal)
            gra.drawText(30, 430, '0')
            gra.drawText(30, 240, '25')
            gra.drawText(816,430, '0')
            gra.drawText(816, 240, '90')
            gra.drawText(806, 35, 'Deg 180')
            gra.drawText(395, 480, 'Frequency Hz')
            gra.drawText(55, 445, '0')
            gra.drawText(796, 445, '120')
            gra.drawLine(60,40,60,430)
            gra.drawLine(60, 40, 801, 40)
            gra.drawLine(801, 40, 801, 430)
            gra.drawLine(60, 430, 801, 430)
            self.frame1.updtate()
  #here i simulate a real time graph.
            sleep(3)
            gra.drawText(30,50,'blabla')
            self.frame1.update()

then i have write this class that for my understanding is called every frame1.update:

class PictureFrame(QtGui.QFrame):

    def __init__(self, parent):
        QtGui.QFrame.__init__(self, parent)
        self.setGeometry(QtCore.QRect(0,0, 961, 601))
        self.immagine = QtGui.QPicture()
     
    def paintEvent(self, event):
        gr = QtGui.QPainter(self)
        gr.drawPicture(0, 0, self.immagine) 

the problem now is that the graph is show only at the second update whit all texts and lines inside, and not after the first and then after the second update.

How i can solve the problem

Regards

Luca

Thanks Luca




More information about the PyQt mailing list