Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. how to show the ui and then run a loop?
Forum Updated to NodeBB v4.3 + New Features

how to show the ui and then run a loop?

Scheduled Pinned Locked Moved Solved Qt for Python
6 Posts 2 Posters 676 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.
  • A Offline
    A Offline
    adrian88888888
    wrote on last edited by
    #1

    Hi!

    I want to make a loop that analyzes files

    Inside each iteration I want to log stuff in the ui

    The problem is that I don't know where to put the loop in the code

    Doesn't matter where i put it, when I run the code always starts the loop and then shows the ui

    But I want the reverse: to see the ui first, and then see the loop logging in the ui

    This is the bulk of the ui code, where i should put the loop?:

    *lots of imports*
    *lots of imports*
    *lots of imports*
    
    class MainWindow(QMainWindow):
        def __init__(self):
            QMainWindow.__init__(self)
            self.ui = Ui_MainWindow()
            self.ui.setupUi(self)
            ...
            ...
            ...
    
    if __name__ == "__main__":
        app = QApplication(sys.argv)
        window = MainWindow()
        window.show()
        sys.exit(app.exec_())
    

    the simplified loop looks something like this:

    for each_file in files:
        log(each_file)
    

    Thanks!

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      If you want to do heavy processing you should consider using QtConcurrent to avoid blocking your GUI

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

      A 2 Replies Last reply
      1
      • SGaistS SGaist

        Hi,

        If you want to do heavy processing you should consider using QtConcurrent to avoid blocking your GUI

        A Offline
        A Offline
        adrian88888888
        wrote on last edited by
        #3

        @SGaist Thanks! I will read about that

        1 Reply Last reply
        0
        • SGaistS SGaist

          Hi,

          If you want to do heavy processing you should consider using QtConcurrent to avoid blocking your GUI

          A Offline
          A Offline
          adrian88888888
          wrote on last edited by adrian88888888
          #4

          @SGaist So you were suggesting multiprocessing? That makes sense
          I know how to do that with the standard module in python: threading
          That should work too?
          I'm not that experienced in programming and I don't know if using the module(I guess it's called module) QtConcurrent from Qt its obligatory or not, it is?

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            It's not obligatory but it will be better integrated and also easier to get you started since as you wrote you are new to programming.

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

            A 1 Reply Last reply
            0
            • SGaistS SGaist

              It's not obligatory but it will be better integrated and also easier to get you started since as you wrote you are new to programming.

              A Offline
              A Offline
              adrian88888888
              wrote on last edited by
              #6

              @SGaist Thanks a lot!

              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