Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. PyQt GUI doesn't appear at Raspberry Pi startup
Forum Updated to NodeBB v4.3 + New Features

PyQt GUI doesn't appear at Raspberry Pi startup

Scheduled Pinned Locked Moved Mobile and Embedded
6 Posts 5 Posters 3.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    PyQtN00b
    wrote on 9 Dec 2016, 10:10 last edited by
    #1

    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()
    
    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 9 Dec 2016, 22:37 last edited by
      #2

      Hi and welcome to devnet,

      Do you already have the Xorg server running before starting your application ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • P Offline
        P Offline
        PyQtN00b
        wrote on 12 Dec 2016, 11:09 last edited by
        #3

        Hey,

        thanks for you reply.
        Yes I have the x server running.
        I am using auto-login at desktop.

        J 1 Reply Last reply 12 Dec 2016, 11:26
        0
        • P PyQtN00b
          12 Dec 2016, 11:09

          Hey,

          thanks for you reply.
          Yes I have the x server running.
          I am using auto-login at desktop.

          J Offline
          J Offline
          jsulm
          Lifetime Qt Champion
          wrote on 12 Dec 2016, 11:26 last edited by
          #4

          @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.

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          2
          • S Offline
            S Offline
            sieciech
            wrote on 2 Jan 2017, 10:13 last edited by
            #5

            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

            1 Reply Last reply
            0
            • M Offline
              M Offline
              mvuori
              wrote on 2 Jan 2017, 11:01 last edited by
              #6

              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.

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved