Python Forum
How can I measure progress and display it in the progress bar in the interface?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How can I measure progress and display it in the progress bar in the interface?
#1
Hello. I created a graphic interface using QtDesigner, which, when you press the OK button, runs a script that sequentially runs many programs.
The script is run by the subprocess.call command and contains many of these commands that execute all scripts from the project in sequence. The time it takes to execute all commands is long (about 20min), therefore you need a command bar in the interface. How can I measure the progress of scripting and how can I pass that progress to the progress bar in the interface?
Reply
#2
Is there any to know your total progress as it's running? Like, when it completes one script and moves to the next?

If so, my first thought is to draw a rectangle as your progress bar and when it goes from one script to the next have a line that modifies the "width" of rectangle to the value that reflects where in the sequence it is. It won't move smoothly, but I've never seen one that did anyway. lol
Reply
#3
First and foremost the fact that you are using the Designer to create your Gui is just going to be fraught with much development pain continuously. This if for 2 reasons (1) Its black-box untouchable code and this should be avoided as much as possible in a coding situation and only when absolutely necessary and never self-inflicted which is what you do when you use the Designer (2) The process of learning to use the Designer correctly actually takes more time than learning to use Python-Qt correctly (be it PyQt5, PySide2 or any other flavor) (3) Once you learn how to use Python-Qt as it was meant to be used it is nearly as fast initially as the Designer and definitely a lot faster later on -- when you go to make changes and such.

Okay that being said as @michael1789 eludes to you will need to be able to denote to your parent (that handles the progress bar) the status of its child (or children) as to their current state. I would suggest perhaps looking into QThreading the sub-processes and having the Signal back to the Parent at specific intervals as I think that might be the most straight-forward and perhaps best way to handle this -- not I am not saying its the easiest because unless you have played with QThreads before you might have them a bit tricky especially since the how to in the Qt Documentation is wrong (old Python-Qt4 docos vs current Python-Qt5) which is to say you do not, and let me repeat you do not -- sub-class a QThread in Python-Qt5

If you need more help on this and/or want help on how to learn proper Python-Qt just shoot out another question I have no problems helping teach others how to properly use Python-Qt and I, in fact, run a free Discord classroom for this very purpose.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [PyQt] Generate Progress Bar while executing a task maiya 7 7,749 Aug-10-2022, 10:05 AM
Last Post: mfitzp
Photo [PyQt] Connecting progress bars to sensors anastejzja 1 1,122 May-28-2022, 09:09 AM
Last Post: Axel_Erfurt
  Which GUI toolkit creating tool to measure distance/area on image kboortz 1 3,396 Aug-29-2020, 11:34 AM
Last Post: Larz60+
  [Tkinter] tkinter progress bar for decending number justaloser 1 2,585 Nov-10-2019, 12:31 AM
Last Post: Larz60+
  [Tkinter] Progress Bar While Sending an Email maxtimbo 3 3,999 Oct-09-2019, 09:13 PM
Last Post: woooee
  Progress Bar While Sending an Email maxtimbo 0 2,086 Oct-08-2019, 02:13 PM
Last Post: maxtimbo
  Need help setting up a PySimpleGUI progress bar that I can maually update in script Soundtechscott 1 10,043 Jun-10-2019, 06:14 AM
Last Post: Soundtechscott
  Display and update the label text which display the serial value jenkins43 5 8,990 Feb-04-2019, 04:36 AM
Last Post: Larz60+
  Display more than one button in GUI to display MPU6000 Sensor readings barry76 4 3,834 Jan-05-2019, 01:48 PM
Last Post: wuf
  GUI Progress Bar Anysja 6 6,532 Aug-29-2018, 02:34 PM
Last Post: swetanjali

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020