[PyKDE] 4.0 (snapshot-20031202-SIP4-132)
    Gerard Vermeulen 
    gvermeul at grenoble.cnrs.fr
       
    Wed Dec  3 22:10:01 GMT 2003
    
    
  
Phil, the next little program is a stripped down example from PyQwt.
It crashes PyQt with 3 mouse clicks:
- click the main window to bring up the ConfigDiag
- click the dismiss button
- click the dismiss button
Output on the terminal:
[packer at venus junk]$ ./CurveDemo3.py
Loading required GL library /usr/X11R6/lib/libGL.so.1.3.401
TypeError: insufficient number of arguments to QPushButton.mouseReleaseEvent()
Segmentation fault
[packer at venus junk]$
There is some interaction with the timer, but I am feeling hungry .... 
---------------------------------------------------------------------------------
#!/usr/bin/env python
import sys
from qt import *
class ConfigDiag(QDialog):
    def __init__(self, parent = None, name = None):
        QDialog.__init__(self, parent, name)
        layout = QGridLayout(self, 1, 1, 11, 6)
        self.ctSpeed = QSpinBox(20, 2000, 20, self)
        layout.addWidget(self.ctSpeed, 0, 0) 
        btDismiss = QPushButton("Dismiss", self)
        layout.addWidget(btDismiss,1,0)
        self.connect(btDismiss, SIGNAL("clicked()"), self.accept)
        self.connect(self.ctSpeed, SIGNAL("valueChanged(int)"), self.chgTSpeed)
    # slots
    def setTSpeed(self, t):
        self.ctSpeed.setValue(t)
    def chgTSpeed(self, t):
        self.emit(PYSIGNAL("tSpeedChg"), (t,))
class CurveDemo(QFrame):
    def __init__(self, *args):
        apply(QFrame.__init__, (self,) + args)
        self.setCaption("Click my window to configure me")
        # timer config
        self.cfg = ConfigDiag()
        self.connect(self.cfg, PYSIGNAL("tSpeedChg"), self.setTSpeed)
        # start timer
        self.tid = None
        self.setTSpeed(100)
        self.cfg.setTSpeed(100)
    def mousePressEvent(self, e):
        if not self.cfg.isVisible():
            self.cfg.show()
        else:
            self.cfg.hide()
    def setTSpeed(self, milliseconds):
        if self.tid:
            self.killTimer(self.tid)
        self.tid = self.startTimer(int(milliseconds * 1.0)) 
    def drawContents(self, painter):
        r = self.contentsRect()
    def timerEvent(self, event):
        self.newValues()
        self.repaint()
        
    def newValues(self):
        pass
if __name__ == '__main__':
    app = QApplication(sys.argv)
    demo = CurveDemo()
    demo.resize(300, 300)
    demo.show()
    app.setMainWidget(demo)
    app.exec_loop()
---------------------------------------------------------------------------------
Gerard
    
    
More information about the PyQt
mailing list