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

List:       pykde
Subject:    [PyQt] Pb understanding painter
From:       "Jean-Baptiste BUTET" <ashashiwa () gmail ! com>
Date:       2007-12-22 8:58:48
Message-ID: 233976e40712220058r3909299fm8a17aa41e916b76d () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


Hi all :)

I am trying to draw a cross in a label with coordinates.

I've think (surely false ;) ) make a a widget, place it on coodinates and
paint it with my cross Image.

here is this code :
class point(QtGui.QWidget):

    def __init__(self, x, y, parent):
        print "parti"
        QtGui.QWidget.__init__(self, parent)
        self.x = x
        self.y = y
    def paintEvent(self, event):
        print "parti_"

        painter = QtGui.QPainter(self)
        print "painter_ok"
        painter.setPen(QtCore.Qt.black)
        painter.drawImage(QtCore.QPoint(self.x,self.y), QtGui.QImage("
croix.png"))


I call my widget with : point_draw = point(x,y,
self.ui.label_where_to_draw_my_widget)

When I do this, I could see my paintEvent is launched (print "parti_") but
nothings happens on my label.

Why ?

Thanks.

JB

-- 
http://astrolix.org
association des linuxiens astronomes

[Attachment #5 (text/html)]

Hi all :)<br><br>I am trying to draw a cross in a label with \
coordinates.<br><br>I&#39;ve think (surely false ;) ) make a a widget, place it on \
coodinates and paint it with my cross Image.<br><br>here is this code : <br>class \
point( QtGui.QWidget):<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; def \
__init__(self, x, y, parent):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print \
&quot;parti&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
QtGui.QWidget.__init__(self, parent)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
self.x = x<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.y = \
y<br>&nbsp;&nbsp;&nbsp; def paintEvent(self, event): \
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print \
&quot;parti_&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; painter = \
QtGui.QPainter(self)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print \
&quot;painter_ok&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
painter.setPen(QtCore.Qt.black)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
painter.drawImage(QtCore.QPoint(self.x ,self.y), \
QtGui.QImage(&quot;croix.png&quot;))<br clear="all"><br><br>I call my widget with : \
point_draw = point(x,y,self.ui.label_where_to_draw_my_widget)<br><br>When I do this, \
I could see my paintEvent is launched (print &quot;parti_&quot;) but nothings happens \
on my label. <br><br>Why ?<br><br>Thanks.<br><br>JB<br><br>-- <br><a \
href="http://astrolix.org">http://astrolix.org</a><br>association des linuxiens \
astronomes



_______________________________________________
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