Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Unsolved add delay in python

    Language Bindings
    4
    5
    3101
    Loading More Posts
    • 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.
    • D
      Dl10 last edited by

      how i adding delay in python? i using PyQt5.
      my intent is function style time.sleep but Other.
      help!
      tnx

      JonB 1 Reply Last reply Reply Quote 0
      • JonB
        JonB @Dl10 last edited by

        @Dl10
        The usual "Qt style" is to do this via (single-shot) QTimer instead of "delaying", which means redesigning the way your code works. Depends on your usage.

        1 Reply Last reply Reply Quote 0
        • Pablo J. Rogina
          Pablo J. Rogina last edited by Pablo J. Rogina

          @Dl10 if you want your application to "pause" for some period of time, I'd say use Python's time.sleep(delay).
          What @JonB suggested is using a "single-shot" timer which let's you do something once the timer goes off.
          So these two approaches are slightly different.

          Upvote the answer(s) that helped you solve the issue
          Use "Topic Tools" button to mark your post as Solved
          Add screenshots via postimage.org
          Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

          JonB 1 Reply Last reply Reply Quote 0
          • JonB
            JonB @Pablo J. Rogina last edited by JonB

            @Pablo-J.-Rogina
            It's difficult to guess what the OP means, but he says:

            my intent is function style time.sleep but Other.

            but it seems he is aware of Python time.sleep(delay) but doesn't want to use it...! :)

            1 Reply Last reply Reply Quote 0
            • W
              windsorperma last edited by

              Sleep() function actually suspends the processing of the thread in which it is called by the operating system, allowing other threads and processes to execute while it sleeps. With multiple threads and processes, sleep() suspends your thread - it uses next to zero processing power.

              1 Reply Last reply Reply Quote 0
              • First post
                Last post