4
votes

I'm making a program for my raspberry pi in python and pyqt4. Now I'm starting the program on my raspberry and it gives errors and it doesn't show the buttons I have made. I have designed into qtdesinger, it shows the window but nothing on it.

This is the error i have:

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

This my python code from the qtdesigner:

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$

and this my file to show the window: 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_())

Does have annybody a solution for me? I googled the error but found no answers for my problem.

Thanks...

2
It's it possible that the problem real VNC is? I want to start the program into a vnc session. On the internet they say that the problem maybe real vnc is? Could it be possible?Stijnb

2 Answers

1
votes

I have the same problem with a python app.

I have found the following:

  1. Using VNC, login to Gnome desktop as myself and run application as myself, works 100%
  2. While logged into desktop as myself, run xhost +
  3. Sudo switch user to another user and the application fails
  4. As the new user, export DISPLAY=hostname:
  5. Run the app and now it works 100%

This started happening with a python update which included newer versions of pyqt and libqt.

As a side test, I am eable to run "eyes" and "firefox" perfectly (without exporting display variable)

The problem appears to sit when pyqt atempts to "fill in" an X11 window when using "/unix" MIT-MAGIC-COOKIE-1 .....the same routines work when using "hostname:instance" MIT-MAGIC-COOKIE-1

1
votes

I found similar problem with Unetbootin. It requires root privileges, and when X-server is started from user, e.g. using startx command, it gives the same error.

Solution is to use display manager, like lxdm, gdm and such.

My guess is that QT can't elevate permission to access some shared memory, because X is running with user privileges. And with desktop manager it runs with root privileges.