[PyQt] Qpainter last question

lucaberto at libero.it lucaberto at libero.it
Tue Dec 18 09:33:57 GMT 2007


I promise is my last question.

In the book is write that repaint force the update of the widget.

so i try this :

from PyQt4.QtGui import QWidget
from PyQt4.QtCore import pyqtSignature
from PyQt4 import  *
from PyQt4 import Qt
import sip
import sys
from ds_egno import PictureFrame
app = QtGui.QApplication(sys.argv)



from Ui_form import Ui_Form

class Form(QWidget, Ui_Form):
    """
    Class documentation goes here.
    """
    def __init__(self, parent = None):
        """
        Constructor
        """
        QWidget.__init__(self, parent)
        self.setupUi(self)
        self.miaPictureFrame = PictureFrame(self.frame1)
        self.radioButton.setChecked(True)
        self.tabWidget.setCurrentIndex(0)
        self.inizio()


@pyqtSignature("")
def on_pushButton_5_clicked(self):
"""
Slot documentation goes here.
"""
# TODO: not implemented yet
#raise NotImplementedError
from time import sleep
gra = QtGui.QPainter(self.miaPictureFrame.immagine)
pen = QtGui.QPen()
pen.setWidth(1)
gra.setPen(pen)
gra.drawText(30, 35, '50 daN/mm')
self.frame1.repaint()
sleep(3)
gra.drawText(395, 30, nome_cal)
gra.drawText(30, 430, '0')
self.frame1.repaint() 

my Class is:

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)          


Nothing is paint can you explain me why?

Sorry for my stupid question 

Luca




More information about the PyQt mailing list