PyQT-application crash when shutting down

Albert Hofkamp hat at se-46.wpa.wtb.tue.nl
Tue Jan 21 17:34:49 CET 2003


Hello all,

I am writing an animation application using PyQt at a Redhat 7.2 machine
(RPM: PyQt-devel-3.1-2).
The application seems to be working fine, but when I press the 'Quit'
button (which sends a 'clicked' signal to the 'quit' slot of the main
application), I get a "segmentation fault".
Below is a stripped-down application that demonstrates the problem (at
least at my machine):

#!/usr/bin/python1.5
#
import sys
from qt import *

class QuitButton(QPushButton):
    def __init__(self,*args):
	apply(QPushButton.__init__,(self,)+args)
	self.setText("Quit")


class AnimationWidget(QWidget):
    def __init__(self,*args):
	apply(QWidget.__init__,(self,)+args)

	# Set default background
	self.setBackgroundMode(QWidget.PaletteBase)

    def paintEvent(self,ev):
	pen = QPen()
	pen.setWidth(1)
	pen.setColor( QColor(125,253,32) )

	painter=QPainter(self)
	painter.setPen(pen)
	painter.drawRect(50,50,50,30)


class ApplicationWindow(QFrame):
    def __init__(self,*args):
	apply(QFrame.__init__,(self,)+args)

	self._quit=QuitButton(self)
	self._animation=AnimationWidget(self)

	self._grid=QGridLayout(self,2,2)	# 2rows, 2 columns
	self._grid.setColStretch(1,2)
	self._grid.setRowStretch(0,2)
	self._grid.addWidget(self._quit,1,0)   # quit button at row 1, col 0
	self._grid.addMultiCellWidget(self._animation,0,0,0,1)
		# animation widget in row 0, columns 0 and 1


if __name__ == '__main__':
    app=QApplication(sys.argv)
    aw=ApplicationWindow()
    app.setMainWidget(aw)
    app.connect(aw._quit,SIGNAL("clicked()"),app,SLOT("quit()"))
    aw.show()
    app.exec_loop()

I don't understand why this happens. If the application is closed with the
'close window' button, it exits without problems.

Any ideas?


Albert
-- 
Unlike popular belief, the .doc format is not an open publically available format.




More information about the Python-list mailing list