我正在用 python 和 pyqt4 为我的树莓派制作一个程序。现在我在我的树莓上启动程序,它给出了错误,它没有显示我制作的按钮。我已经设计成qtdesinger,它显示了窗口,但上面什么也没有。
这是我的错误:
X Error: BadAccess (attempt to access private resource denied) 10
Extension: 129 (MIT-SHM)
Minor opcode: 1 (X_ShmAttach)
Resource id: 0x2800001
X Error: BadShmSeg (invalid shared segment parameter) 128
Extension: 129 (MIT-SHM)
Minor opcode: 5 (X_ShmCreatePixmap)
Resource id: 0x280000a
X Error: BadDrawable (invalid Pixmap or Window parameter) 9
Major opcode: 62 (X_CopyArea)
Resource id: 0x280000b
X Error: BadDrawable (invalid Pixmap or Window parameter) 9
Major opcode: 62 (X_CopyArea)
Resource id: 0x280000b
X Error: BadDrawable (invalid Pixmap or Window parameter) 9
Major opcode: 62 (X_CopyArea)
Resource id: 0x280000b
这是来自 qtdesigner 的我的 python 代码:
try:
_fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
_fromUtf8 = lambda s: s
class Ui_Form(object):
def setupUi(self, Form):
Form.setObjectName(_fromUtf8("Form"))
Form.resize(480, 640)
self.pushButton = QtGui.QPushButton(Form)
self.pushButton.setGeometry(QtCore.QRect(120, 140, 83, 24))
self.pushButton.setObjectName(_fromUtf8("pushButton"))
self.toolButton = QtGui.QToolButton(Form)
self.toolButton.setGeometry(QtCore.QRect(350, 250, 27, 20))
self.toolButton.setObjectName(_fromUtf8("toolButton"))
self.buttonBox = QtGui.QDialogButtonBox(Form)
self.buttonBox.setGeometry(QtCore.QRect(150, 280, 156, 24))
self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDia$
self.buttonBox.setObjectName(_fromUtf8("buttonBox"))
self.commandLinkButton = QtGui.QCommandLinkButton(Form)
self.commandLinkButton.setGeometry(QtCore.QRect(160, 230, 168, 41))
self.commandLinkButton.setObjectName(_fromUtf8("commandLinkButton"))
self.checkBox = QtGui.QCheckBox(Form)
self.checkBox.setGeometry(QtCore.QRect(130, 380, 84, 19))
self.checkBox.setObjectName(_fromUtf8("checkBox"))
self.toolButton_2 = QtGui.QToolButton(Form)
self.toolButton_2.setGeometry(QtCore.QRect(160, 470, 27, 20))
self.toolButton_2.setObjectName(_fromUtf8("toolButton_2"))
self.listView = QtGui.QListView(Form)
self.listView.setGeometry(QtCore.QRect(60, 460, 256, 192))
self.listView.setObjectName(_fromUtf8("listView"))
self.retranslateUi(Form)
QtCore.QMetaObject.connectSlotsByName(Form)
def retranslateUi(self, Form):
Form.setWindowTitle(QtGui.QApplication.translate("Form", "Form", None, QtG$
self.pushButton.setText(QtGui.QApplication.translate("Form", "Lamp", None,$
self.toolButton.setText(QtGui.QApplication.translate("Form", "...", None, $
self.commandLinkButton.setText(QtGui.QApplication.translate("Form", "Comma$
self.checkBox.setText(QtGui.QApplication.translate("Form", "CheckBox", Non$
self.toolButton_2.setText(QtGui.QApplication.translate("Form", "...", None$
这是我的文件来显示窗口: import sys from PyQt4 import QtCore, QtGui from test import Ui_Widget
class StartQT4(QtGui.QMainWindow):
def __init__(self, parent=None):
QtGui.QWidget.__init__(self, parent)
self.ui = Ui_Widget()
self.ui.setupUi(self)
if __name__ == "__main__":
app = QtGui.QApplication(sys.argv)
myapp = StartQT4()
myapp.show()
sys.exit(app.exec_())
有没有人为我提供解决方案?我用谷歌搜索了这个错误,但没有找到我的问题的答案。
谢谢...