[PyQt] Getting a segfault when I close my program
dizou
di_zou at yahoo.com
Thu Mar 11 19:41:57 GMT 2010
This code will recreate the problem:
Main.py:
#!/usr/bin/env python
import sys
from PyQt4 import QtGui
from MainWindow import *
app = QtGui.QApplication(sys.argv)
widget = MainWindow()
widget.resize(250, 150)
widget.show()
sys.exit(app.exec_())
MainWindow.py:
#!/usr/bin/env python
from PyQt4 import QtCore
from PyQt4 import QtGui
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4.QtCore import SIGNAL, SLOT, QDir, QFile
from PyQt4.QtGui import QApplication, QMainWindow, QMenu, QMessageBox, \
QWidget, qApp, QAction, QFileDialog, QPushButton
from MainWidget import *
class MainWindow(QMainWindow):
def __init__(self):
QMainWindow.__init__(self)
self.main = MainWidget()
#print dir(MainWidget)
#print self.__dict__
#self.CreateActions()
#self.CreateMenus()
self.setCentralWidget(self.main)
self.statusBar = self.statusBar()
MainWidget.py:
#!/usr/bin/env python
import math
from PyQt4 import QtCore
from PyQt4 import QtGui
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4.QtCore import SIGNAL, SLOT, QDir, QFile
from PyQt4.QtGui import QApplication, QMenu, QMessageBox, \
QWidget, qApp, QAction, QFileDialog, QPushButton, QGraphicsItem
class MainWidget(QWidget):
def __init__(self):
QWidget.__init__(self)
self.tree = QTreeWidget(self)
self.display = QGraphicsScene(self)
self.view = QGraphicsView(self.display)
self.view.show()
self.newButton = QToolButton()
self.openButton = QToolButton()
self.saveButton = QToolButton()
self.addButton = QToolButton()
self.deleteButton = QToolButton()
self.editButton = QToolButton()
self.copyButton = QToolButton()
self.pasteButton = QToolButton()
self.viewParentButton = QToolButton()
self.viewChildrenButton = QToolButton()
self.view3DButton = QToolButton()
self.playButton = QToolButton()
self.stopButton = QToolButton()
self.stepForwardButton = QToolButton()
self.stepBackwardButton = QToolButton()
self.updateButton = QToolButton()
self.stepLabel = QLabel("Movement Index:")
self.stepLineEdit = QLineEdit()
self.stepSizeLabel = QLabel("Movement Step Size:")
self.stepSizeSlider = QSlider(Qt.Horizontal)
self.stepSizeLineEdit = QLineEdit()
self.rightSpacer = QSpacerItem(10, 0, QSizePolicy.Expanding)
self.newButton.setToolTip("New")
self.openButton.setToolTip("Open")
self.saveButton.setToolTip("Save")
self.addButton.setToolTip("Add Element")
self.deleteButton.setToolTip("Delete Element")
self.editButton.setToolTip("Edit Element")
self.copyButton.setToolTip("Copy Element")
self.pasteButton.setToolTip("Paste Element")
self.viewParentButton.setToolTip("View Parent Element")
self.viewChildrenButton.setToolTip("View Child Element")
self.view3DButton.setToolTip("3D View")
self.playButton.setToolTip("Play")
self.stopButton.setToolTip("Stop")
self.stepForwardButton.setToolTip("Step Forward")
self.stepBackwardButton.setToolTip("Step Backward")
self.updateButton.setToolTip("Update")
treeControlLayout = QGridLayout()
treeControlLayout.addWidget(self.newButton, 0, 0)
treeControlLayout.addWidget(self.openButton, 0, 1)
treeControlLayout.addWidget(self.saveButton, 0, 2)
treeControlLayout.addWidget(self.addButton, 0, 3)
treeControlLayout.addWidget(self.deleteButton, 0, 4)
treeControlLayout.addWidget(self.editButton, 0, 5)
treeControlLayout.addWidget(self.copyButton, 0, 6)
treeControlLayout.addWidget(self.pasteButton, 0, 7)
treeControlLayout.addItem(self.rightSpacer, 0, 8)
viewControlLayout = QGridLayout()
viewControlLayout.addWidget(self.stepBackwardButton, 0, 0,
Qt.AlignCenter)
viewControlLayout.addWidget(self.playButton, 0, 1, Qt.AlignCenter)
viewControlLayout.addWidget(self.stepForwardButton, 0, 2,
Qt.AlignCenter)
viewControlLayout.addWidget(self.stopButton, 0, 3, Qt.AlignCenter)
viewControlLayout.addWidget(self.updateButton, 0, 4, Qt.AlignCenter)
viewControlLayout.addWidget(self.viewParentButton, 0, 5,
Qt.AlignCenter)
viewControlLayout.addWidget(self.viewChildrenButton, 0, 6,
Qt.AlignCenter)
viewControlLayout.addWidget(self.view3DButton, 0, 7, Qt.AlignCenter)
viewControlLayout.addItem(self.rightSpacer, 0, 8)
viewInfoLayout = QGridLayout()
viewInfoLayout.addWidget(self.stepLabel, 0, 6)
viewInfoLayout.addWidget(self.stepLineEdit, 0, 7)
viewInfoLayout.addWidget(self.stepSizeLabel, 0, 8)
viewInfoLayout.addWidget(self.stepSizeSlider, 0, 9)
viewInfoLayout.addWidget(self.stepSizeLineEdit, 0, 10)
gridLayout = QGridLayout()
gridLayout.addLayout(treeControlLayout, 0, 0)
gridLayout.addWidget(self.tree, 1, 0)
gridLayout.addLayout(viewControlLayout, 0, 1)
gridLayout.addWidget(self.view, 1, 1)
gridLayout.addLayout(viewInfoLayout, 2, 1)
self.setLayout(gridLayout)
--
View this message in context: http://old.nabble.com/Getting-a-segfault-when-I-close-my-program-tp27799395p27868777.html
Sent from the PyQt mailing list archive at Nabble.com.
More information about the PyQt
mailing list