progressbar python
Python hosting: Host, run, and code Python in the cloud!
In this article we will demonstrate how to use the progressbar widget. The progressbar is different from the other widgets in that it updates in time.
Related course:
QT4 Progressbar Example
Let’s start with the code:
#! /usr/bin/env python |
The instance bar (of class QProgBar) is used to hold the value of the progressbar. We call the function setValue() to update its value. The parameter w is given to attach it to the main window. We then move it to position (0,20) on the screen and give it a width and height.
To update the progressbar in time we need a QTimer(). We connect the widget with the timer, which calls the function increaseValue(). We set the timer to repeat the function call every 400 milliseconds. You also see the words SLOT and SIGNAL. If a user does an action such as clicking on a button, typing text in a box - the widget sends out a signal. This signal does nothing, but it can be used to connect with a slot, that acts as a receiver and acts on it.
Result:

Leave a Reply:
hello, frank nice tutorials, Im really a beginner in python, but I use python on windows with arduino, I see on internet son gauge dial similar to this: https://developers.google.c..., I see this example for do one dial with pyqt: http://stackoverflow.com/qu..., Can you finished this example with numbers, and put published here. A question where are You from??
Hi Jahir, I'm from the netherlands. This is how to create a gauge dial with set and get value:
The background:
https://pythonspot.com/wp-content/uploads/2015/07/bg.png
It will tell the value of the gauge and you can set it on the scale of 0 to 1. Is this what you had in mind?
OK, Fantastic, But How I put the label values for scale on graphic. (0, 0.1, 0.2, 0.3 .. ....1), I see a beautiful gauges indicators in PYQT
qt-apps.org/content/show.ph...
But the code was writed for QT on C++, Is possible pass the code for use in PYQT windows??
Hi, it's possible to put these programatically but it looks much better if you simply modify the pixmap. As far as I know these C++ widgets are not ported. I saw this version uses a textfont pixmap that is put on top of the gauge. This is one possibility but I don't know the advantage as to simply changing the background pixmap.
If you want to put a label on a pixmap programatically, you can do something like this:
However, I recommend changing the background image itself because it's more slick. If I get some more time today I may look into it deeper. I hope that helps :-)
Great..!! Perfect, last thing, Please see this project: http://www.mon-club-elec.fr...
I download and modify some lines for use in windows, I want put this gauge in up position of slider, and the text label gauge in center of gauge, for read analog input.
Do you are teacher in School?? You have a lot of patience to teach..
Looking into it
Hi Jahir, sorry for the delay has been hectic here. You can download these files and open them in a program named QTCreator. With this program you can drag & drop widgets. No, I'm just a 27 year old software developer :-)