Planned maintenance: From Sunday 8th December 10:00 CET there will be changes to try and solve the caching issues that have been experienced. If anyone has a problem connecting after this period then please PM @AndyS or any of the moderators.
PyQt GUI doesn't appear at Raspberry Pi startup
PyQtN00b last edited by
I am trying to get this running for days.
I created a simple PyQt-Script With two buttons and a label.
When I start it on my Raspberry Pi via consolse it works fine.
I edited the rc.local file on my Pi to make it running ont startup.
(btw I also tried all the other possibilities like .desktop-file or editing autostart file in lxsession)
When I reboot the Pi (autologin on desktop) the GUI doesnt appear.
But the python-script was executed (I know it, because it's also writing the time in a file)
And when I try the same with a simple py-script using kivy it works perfectly.
Do you have any suggestions what I do wrong?
Thanks in advance!
btw. I am using a Raspberry Pi 2 B with Raspbian Jessie on an original Raspberry Pi 7" Touchscreen.
here is my python script:
#!/usr/bin/python # always seem to need this import sys from time import * # This gets the Qt stuff import PyQt5 from PyQt5.QtWidgets import * # This is our window from QtCreator import mainwindow_auto # create class for our Raspberry Pi GUI class MainWindow(QMainWindow, mainwindow_auto.Ui_MainWindow): # access variables inside of the UI's file def __init__(self): super(self.__class__, self).__init__() self.setupUi(self) # gets defined in the UI file # I feel better having one of these def main(): # a new app instance lt = localtime() zeitnow = strftime("Es ist: %H:%M:%S", lt) print (zeitnow) file = open("/home/pi/loggerfile.txt","w") file.write(zeitnow) file.close app = QApplication(sys.argv) form = MainWindow() form.show() # without this, the script exits immediately. sys.exit(app.exec_()) # python bit to figure how who started This if __name__ == "__main__": main()
Hi and welcome to devnet,
Do you already have the Xorg server running before starting your application ?
PyQtN00b last edited by
thanks for you reply.
Yes I have the x server running.
I am using auto-login at desktop.
@PyQtN00b You could try to redirect standard output and error output to a file when start your app:
PATH_TO_APP 2>&1 1 > PATH_TO_A_FILE
Then check the content of that file.
sieciech last edited by
Suggestion: check the order of execution, and dependencies in execution script. Maybe you are trying to execute your app too soon, before drivers/configurations of display is set (To be honest, i don't know how does Linux handles loading of display drivers)
mvuori last edited by
Another thing related to being executed too soon -- I would try adding a delay to the beginning of the script, say, like 5 seconds, to make sure the environment is ready.