PyQt GUI doesn't appear at Raspberry Pi startup
-
Hey Guys,
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 ?
-
Hey,
thanks for you reply.
Yes I have the x server running.
I am using auto-login at desktop. -
Hi,
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)
regards