Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. MainWindow takes 8 seconds to launch, PyQt on OsX
Forum Updated to NodeBB v4.3 + New Features

MainWindow takes 8 seconds to launch, PyQt on OsX

Scheduled Pinned Locked Moved General and Desktop
11 Posts 3 Posters 5.2k 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.
  • S Offline
    S Offline
    syr123
    wrote on last edited by
    #1

    I'm used to developing with Qt and PyQt on Linux, but am now creating a hello world on OsX 10.7

    My example, plus all those in the demos folder, take about 8 seconds to launch after run - a rocket icon for Python bounces in the dock for those 8 seconds before the form shows.

    The rocket reports Qt 4.8.2. I am launching example from the terminal. Any tips? This delay is no good for quick development..

    1 Reply Last reply
    0
    • C Offline
      C Offline
      ChrisW67
      wrote on last edited by
      #2

      Where is the slow down; starting python, loading PyQt, or running your application?

      How long does it take to start python from the command prompt?
      If that doesn't take the 8 seconds, then how long does "import PyQt4" or "from PyQt4 import QtGui, QtCore" take?

      1 Reply Last reply
      0
      • S Offline
        S Offline
        syr123
        wrote on last edited by
        #3

        All three of those are imperceptibly quick - milliseconds. I had initially thought it might have been the imports, but it seems to just be a slowdown in bringing up the window, somehow...

        1 Reply Last reply
        0
        • C Offline
          C Offline
          ChrisW67
          wrote on last edited by
          #4

          Do you have an example program?

          1 Reply Last reply
          0
          • S Offline
            S Offline
            syr123
            wrote on last edited by
            #5

            It's happening with any PyQt 4 app, including all the examples..

            The mainwindow launch is just this:

            @def main():
            app = QApplication(sys.argv)
            form = SensorDiagnostics()
            form.show()
            app.exec_()

            if name == "main":
            main()@

            Invoking that by:

            @python sensor_diagnostics.py@

            1 Reply Last reply
            0
            • C Offline
              C Offline
              ChrisW67
              wrote on last edited by
              #6

              So if you make your form a basic QWidget() does it start faster?

              @
              from PyQt4.QtGui import *

              def main():
              app = QApplication(sys.argv)
              form = QWidget()
              form.show()
              app.exec_()

              if name == "main":
              main()
              @

              1 Reply Last reply
              0
              • S Offline
                S Offline
                syr123
                wrote on last edited by
                #7

                No, just tried it, same delay...

                1 Reply Last reply
                0
                • C Offline
                  C Offline
                  ChrisW67
                  wrote on last edited by
                  #8

                  Must be some Apple-flavoured magic required. You may need to wait for someone with more OSX/Python/PyQt experience.

                  1 Reply Last reply
                  0
                  • D Offline
                    D Offline
                    DerManu
                    wrote on last edited by
                    #9

                    I'm not that familiar with python, but when you said that the imports are fast, is it possible that they are delayed until you actually use something from the import? So when you imported PyQt4.QtGui but never used anything from there, python just ignored the import?

                    //EDIT: another thing. When you write:
                    @ app = QApplication(sys.argv)
                    form = QWidget()
                    form.show()
                    app.exec_()
                    app = QApplication(sys.argv)
                    form = QWidget()
                    form.show()
                    app.exec_()@
                    does it take 16 seconds?

                    1 Reply Last reply
                    0
                    • S Offline
                      S Offline
                      syr123
                      wrote on last edited by
                      #10

                      Doesn't seem to take 16 seconds, and I don't think the delayed import thing is it.

                      Any other ideas?

                      1 Reply Last reply
                      0
                      • D Offline
                        D Offline
                        DerManu
                        wrote on last edited by
                        #11

                        [quote author="syr123" date="1345443996"]Doesn't seem to take 16 seconds, and I don't think the delayed import thing is it.[/quote]

                        But that exactly is the indicator that it probably is the delayed import. If it wasn't, every call of those main functions should take 8 seconds. But as you see, only the first round takes that long, any subsequent ones go faster.

                        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