Author Topic: GUI with gauges in python  (Read 20399 times)

0 Members and 6 Guests are viewing this topic.

Offline voltsandjolts

  • Supporter
  • ****
  • Posts: 3755
  • Country: gb
Re: GUI with gauges in python
« Reply #25 on: October 22, 2025, 10:09:29 am »
I avoid working on embedded gui's if I can, I just find them to be massive time sinks and feel I'm much more productive doing other stuff. After you've created your gui, you get a dozen different opinions and change requests from a dozen people. You're left to figure out what the balance is, and actually implement it, which with an embedded system is never as quick as a PC application gui adjustment of course. Then after a couple of years the display goes obsolete and yet more time is wasted sourcing an alternative that physical fits and can also be accomodated in the electrical sense. I find I'm always grumpy when having to do embedded gui stuff.

If it's at all possible to do the gui/hmi on a PC, then do that, just build the embedded stuff as the data source. This has the added benefit that you can pass the buck to the software engineer :P. Unless that is also you ;D
« Last Edit: October 22, 2025, 10:13:38 am by voltsandjolts »
 

Offline SimonTopic starter

  • Global Moderator
  • *****
  • Posts: 18889
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: GUI with gauges in python
« Reply #26 on: October 22, 2025, 10:19:05 am »
No I don't use git, I have never version controlled my code other than to date the project and take a copy if I want to go off in a new direction, on micro-controllers that is, this is my first attempt at a program that runs on an OS.
 

Online tggzzz

  • Super Contributor
  • ***
  • Posts: 23122
  • Country: gb
  • Numbers, not adjectives
    • Having fun doing more, with less
Re: GUI with gauges in python
« Reply #27 on: October 22, 2025, 10:21:29 am »
I am wary of letting something write me a load of code that I don't understand myself so first step is to get a basic understanding.

Oh how old fashioned; no vibe coding for you! Good :)

Quote
As great as gauges look I don't think they are what I should use.

Always consider what an operator needs to see in an interface.

Gauges are good where the operator needs to quickly scan an interface either to check nothing has changed or to get a feel for how things are changing.

An example of the first is an old aircraft cockpit where similar needles should point at the same angle (e.g. all engine temperatures should be the same). Examples of the second are aircraft artificial horizons and analogue multimeters (e.g. continuity checking by spotting how fast a needle starts to swing).

If a history is required, then a rolling line/bar graph is useful.
There are lies, damned lies, statistics - and ADC/DAC specs.
Glider pilot's aphorism: "there is no substitute for span". Retort: "There is a substitute: skill+imagination. But you can buy span".
Having fun doing more, with less
 

Online tggzzz

  • Super Contributor
  • ***
  • Posts: 23122
  • Country: gb
  • Numbers, not adjectives
    • Having fun doing more, with less
Re: GUI with gauges in python
« Reply #28 on: October 22, 2025, 10:25:40 am »
After you've created your gui, you get a dozen different opinions and change requests from a dozen people.

Yes, it is worth quickly sketching the GUI without any real content behind it. That forces strongly encourages the users to think about what they really want and need, and can shape the entire application.

But they can deceive themselves into thinking GUI==application, and that it is 80% complete. To avoid that I've used Napkin Look and Feel: the GUI works but "handwriting on a paper napkin" visually emphasises that it is empty :)

Example:

« Last Edit: October 22, 2025, 10:28:16 am by tggzzz »
There are lies, damned lies, statistics - and ADC/DAC specs.
Glider pilot's aphorism: "there is no substitute for span". Retort: "There is a substitute: skill+imagination. But you can buy span".
Having fun doing more, with less
 
The following users thanked this post: xvr

Offline SimonTopic starter

  • Global Moderator
  • *****
  • Posts: 18889
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: GUI with gauges in python
« Reply #29 on: October 22, 2025, 10:31:19 am »
We have things like speed and force, a bar graph is just as good as a gauge and I find easier to appreciate visually how far up the scale you are on a bar. You can physically see the remaining headroom at a glance and the proportion of used over total and used versus unused at a glance more easily.

There is indeed a desire for a readout over time of values with a graph which is precisely why I would save the space wasted by the gauges and use it for a graph plot. but actual values now still need to be shown so it's either a number with an icon or name or a bar if.
 

Offline SimonTopic starter

  • Global Moderator
  • *****
  • Posts: 18889
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: GUI with gauges in python
« Reply #30 on: October 22, 2025, 10:38:38 am »
After you've created your gui, you get a dozen different opinions and change requests from a dozen people.

Yes, it is worth quickly sketching the GUI without any real content behind it. That forces strongly encourages the users to think about what they really want and need, and can shape the entire application.

But they can deceive themselves into thinking GUI==application, and that it is 80% complete. To avoid that I've used Napkin Look and Feel: the GUI works but "handwriting on a paper napkin" visually emphasises that it is empty :)


Yes. so at first I want to design a GUI that is for me, so that I have a custom view on the CAN buses. At the moment I use the basic kvaser can king and it's so clunky and even with DBC files it's hard to see what I want to see at a glance. So my first project will be for developing, sniff the buses and show the values I choose. That will give people a chance to get familiar with the idea and express opinions that are not directed at something in development that they think they are going to sell.

 

Online Psi

  • Super Contributor
  • ***
  • Posts: 12598
  • Country: nz
Re: GUI with gauges in python
« Reply #31 on: October 22, 2025, 11:37:07 am »
I avoid working on embedded gui's if I can, I just find them to be massive time sinks and feel I'm much more productive doing other stuff. After you've created your gui, you get a dozen different opinions and change requests from a dozen people.

You hand off the design to the graphic designer to figure out how to make a 1inch 128x128 pixel UI look good (including pixel based font design) and watch them cry.
If you're nice you give them a prototype they can upload BMPs to so they can see what things look like on the screen
 
But seriously yes, if you let the graphics designer do the hard work and only then write the code to implement the bmp pages/fonts they give you then you save time and end up making less changes.

But seriously it really makes them cry going from their normal toolset to working with 128x128 and no vector fonts.
Greek letter 'Psi' (not Pounds per Square Inch)
 

Offline SimonTopic starter

  • Global Moderator
  • *****
  • Posts: 18889
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: GUI with gauges in python
« Reply #32 on: October 22, 2025, 12:09:44 pm »
Well I seem to have come full circle a year later. Your wall of text would probably be very useful but I can't even start to try and run your example as I can't work out how to install PySide2.
What's your exact OS?

Typically, you'd install Python 3 first, then PIP (https://pip.pypa.io/en/stable/installation/), then use PIP to install PySide2 (pip3 install -U PySide2) and/or PyQt5 (pip3 install -U PyQt5).  That should also pull in the necessary Qt5 libraries, too.


I'm trying to do this on a raspberry pi 5, I was working from my windows laptop in VSC with an ssh connection to the pi but anything graphical won't launch as it can't find the screen. I expect that the libraries need to be on the target system anyway?

So pip3 install -U PySide2 gets me all sorts of errors. If I do it on the command line I am told that this is an externally managed package and I should use apt install. But that fails to find the python3-PySide2 package - I take it I have to type it like that not in all lower case?

If I try to run pip3 install..... from the python3 prompt I get told that it is invalid syntax and it seems to be pointing at the word install....

So close, yet so far. If I try to install anything from the desktop I can't find a thing for the absolute sea of results, I can see why people use the command line, I could not even find visual sudo code, much faster to just type "sudo apt install code"
 

Online tggzzz

  • Super Contributor
  • ***
  • Posts: 23122
  • Country: gb
  • Numbers, not adjectives
    • Having fun doing more, with less
Re: GUI with gauges in python
« Reply #33 on: October 22, 2025, 01:08:43 pm »
We have things like speed and force, a bar graph is just as good as a gauge and I find easier to appreciate visually how far up the scale you are on a bar. You can physically see the remaining headroom at a glance and the proportion of used over total and used versus unused at a glance more easily.

A bar graph is a linear gauge.

Remaining headroom (w.r.t. damage occurring) can be shown as orange/red backgrounds.
There are lies, damned lies, statistics - and ADC/DAC specs.
Glider pilot's aphorism: "there is no substitute for span". Retort: "There is a substitute: skill+imagination. But you can buy span".
Having fun doing more, with less
 

Online tggzzz

  • Super Contributor
  • ***
  • Posts: 23122
  • Country: gb
  • Numbers, not adjectives
    • Having fun doing more, with less
Re: GUI with gauges in python
« Reply #34 on: October 22, 2025, 01:12:21 pm »
But seriously it really makes them cry going from their normal toolset to working with 128x128 and no vector fonts.

It is good for the soul to concentrate on the information. Skeuomorphic GUIs are a pain.

Yes, Bauhaus philosophy rules :)
There are lies, damned lies, statistics - and ADC/DAC specs.
Glider pilot's aphorism: "there is no substitute for span". Retort: "There is a substitute: skill+imagination. But you can buy span".
Having fun doing more, with less
 

Offline Nominal Animal

  • Super Contributor
  • ***
  • Posts: 8349
  • Country: fi
    • My home page and email address
Re: GUI with gauges in python
« Reply #35 on: October 22, 2025, 02:16:06 pm »
I'm trying to do this on a raspberry pi 5
That would be Armbian (rebadged as "Raspberry Pi OS", because Broadcom and the Foundation abhor anything to do with GPL).

As it is a Debian derivative, just like Ubuntu and Mint and many others, these packages (Python, Qt, PySide2, PyQt5) are centrally managed as Debian packages.

Since you want to use graphical applications over an SSH connection, you need to have X11 client libraries on the Raspberry:
    sudo apt install libx11-6

(X11 client is the application; server is the one displaying things.)

You'll want to have python3, and pyside2 and/or pyqt5 installed, letting them pull in all dependencies:
    sudo apt install python3
    sudo apt install python3-pyqt5
    sudo apt install python3-pyside2.{qtcore,qtgui,qtsvg,qtuitools,qtwidgets}

Next, there are two different scenarios: a display connected to the Raspberry Pi that you want to use, or running the application on the Raspberry but showing the windows on your desktop machine.

In the former case, you'll need to start a graphical session on the Raspberry Pi, then "connect" to that session when you use SSH (typically by setting the DISPLAY environment variable, say by running export DISPLAY=:0).  The exact details vary depending on whether you want a full desktop session, autologin session, a simplified session with just a window manager but no other applications, a plain X11 server, or just run a single full-screen Qt application.

In the latter case, showing the actual windows on your desktop machine (but controlled by the code running on the Raspberry Pi):
In your SSH program, you need to enable X11 forwarding, so that the application running on the Raspberry can show its windows and widgets in your Windows machine.  In PuTTY, it's under Connection > SSH > X11.  For command-line ssh clients, use -Y or -X command-line option, noting the letter is in uppercase.

Before you open the SSH connection, your workstation needs to have an X11 server running.  WSL2 includes one, or you can use MobaXterm (for both SSH and X11 server), or Xming.

If you choose to use WSL2, then you can run the above apt commands to install Python 3, Qt 5, and PyQt5/PySide2 bindings to WSL2, so you can directly run Python3+Qt5 code in WSL2.  I don't have Windows myself, but as I understand it, that should work really well too.
 

Offline SimonTopic starter

  • Global Moderator
  • *****
  • Posts: 18889
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: GUI with gauges in python
« Reply #36 on: October 22, 2025, 03:39:55 pm »

A bar graph is a linear gauge.

Remaining headroom (w.r.t. damage occurring) can be shown as orange/red backgrounds.

Yes that is the sort of thing I originally proposed. Instead the guy wanted to be flashy and used lvgl to do these needle dials that sure looked lovely but took up so much space for what they did.

I mean if it sells units I could have different UI layout options they can select but it's going to be done my way first.

@Nominal Animal I will try that tonight when I get home.
 

Online tggzzz

  • Super Contributor
  • ***
  • Posts: 23122
  • Country: gb
  • Numbers, not adjectives
    • Having fun doing more, with less
Re: GUI with gauges in python
« Reply #37 on: October 22, 2025, 06:18:34 pm »

A bar graph is a linear gauge.

Remaining headroom (w.r.t. damage occurring) can be shown as orange/red backgrounds.

Yes that is the sort of thing I originally proposed. Instead the guy wanted to be flashy and used lvgl to do these needle dials that sure looked lovely but took up so much space for what they did.

I mean if it sells units I could have different UI layout options they can select but it's going to be done my way first.

Quote time/money for the "difficult" the flash crap :)

A marketing director's artistic taste is a terrible way to design a GUI.

Give 5 ordinary users the GUI, watch them use it without guiding them. That will reveal most problems.
There are lies, damned lies, statistics - and ADC/DAC specs.
Glider pilot's aphorism: "there is no substitute for span". Retort: "There is a substitute: skill+imagination. But you can buy span".
Having fun doing more, with less
 

Offline SimonTopic starter

  • Global Moderator
  • *****
  • Posts: 18889
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: GUI with gauges in python
« Reply #38 on: October 22, 2025, 07:11:27 pm »
Oh this wasn't marketing, just an amateur we took on that was supposed to be keen to learn but rather just had lots of solutions and was looking for problems to apply them too. I mean it looked great but I won't spend time replicating that and I'm sure graph space will get people as existed for something that is useful.
 

Online tggzzz

  • Super Contributor
  • ***
  • Posts: 23122
  • Country: gb
  • Numbers, not adjectives
    • Having fun doing more, with less
Re: GUI with gauges in python
« Reply #39 on: October 22, 2025, 07:46:20 pm »
Oh this wasn't marketing, just an amateur we took on that was supposed to be keen to learn but rather just had lots of solutions and was looking for problems to apply them too. I mean it looked great but I won't spend time replicating that and I'm sure graph space will get people as existed for somBething that is useful.

Ah, yes. The man with a hammer, who dimly remembers something about screwdrivers, but can't see why/when they might be beneficial.

When interviewing people, I always asked questions designed to reveal such attitudes - and encouraged interviewees to think of other things. Most had difficulty.
There are lies, damned lies, statistics - and ADC/DAC specs.
Glider pilot's aphorism: "there is no substitute for span". Retort: "There is a substitute: skill+imagination. But you can buy span".
Having fun doing more, with less
 

Offline SimonTopic starter

  • Global Moderator
  • *****
  • Posts: 18889
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: GUI with gauges in python
« Reply #40 on: October 22, 2025, 08:36:44 pm »
Here is a tiny dialog example I wrote for this thread in March 2024, slightly edited.


So I tried running your example having got PySide2 and qts installed, actually only the QT5 stuff was not already on pi os. I have switched to my P400 as it's built in keyboard make it more portable even if it's a little less powerful.

Where do I put example.ui ? I tried in the same folder as the python file example but it can't open it.


EDIT:
OK so it runs if I launch it on the p400 itself but not via ssh from my windows laptop.
« Last Edit: October 22, 2025, 08:40:24 pm by Simon »
 

Offline SimonTopic starter

  • Global Moderator
  • *****
  • Posts: 18889
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: GUI with gauges in python
« Reply #41 on: October 23, 2025, 05:58:18 am »
Am I better off developing on the RPi itself?
 

Offline Jeroen3

  • Super Contributor
  • ***
  • Posts: 4564
  • Country: nl
  • Embedded Engineer
    • jeroen3.nl
Re: GUI with gauges in python
« Reply #42 on: October 23, 2025, 06:22:36 am »
iirc python will use the path used to call the main file as base.
Sometimes when your project has subfolders and you call `python .\subfolder\script.py` then it will search in `.\` while it needs to be in `.\subfolder\`.
You can deal with this in the script, or create custom launcher.

If you ask copilot it will look at your files and explain or create the file you need, it can even control vscode features if you allow it  ;)
« Last Edit: October 23, 2025, 06:25:06 am by Jeroen3 »
 

Offline SimonTopic starter

  • Global Moderator
  • *****
  • Posts: 18889
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: GUI with gauges in python
« Reply #43 on: October 23, 2025, 07:35:16 am »
Well that is what I was expecting, it worked when I ran it from the pi itself but not over ssh. I have a Pi500+ on order so I have a decent machine to develop on that is also the target platform. My hope is that I can also run on other SBC.
 

Offline Marco

  • Super Contributor
  • ***
  • Posts: 7742
  • Country: nl
Re: GUI with gauges in python
« Reply #44 on: October 23, 2025, 08:36:47 am »
Doesn't Qt have an embedded mode which doesn't require a windowing system?
 

Offline amwales

  • Regular Contributor
  • *
  • Posts: 135
  • Country: gb
Re: GUI with gauges in python
« Reply #45 on: October 23, 2025, 09:22:07 am »
Can I make a suggestion that you look at the license for Qt if you plan on using it commercially. When I looked last, a developer seat was something like $5k
 

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 22409
  • Country: gb
  • 0999
Re: GUI with gauges in python
« Reply #46 on: October 23, 2025, 09:50:10 am »
Can I make a suggestion that you look at the license for Qt if you plan on using it commercially. When I looked last, a developer seat was something like $5k
That's only true if you're going to use it to make closed source software. I believe in Simon's case the product is the hardware, rather than software. His company could make the source code available, if they wanted to avoid the cost of a licence. It isn't as though a competitor could use it, without the proprietary hardware.
 

Offline SimonTopic starter

  • Global Moderator
  • *****
  • Posts: 18889
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: GUI with gauges in python
« Reply #47 on: October 23, 2025, 10:10:03 am »
If the licence is a requirement then I will have to be using something else.

I'd not want to make the application itself available, one does have competitors and all it would need is a SBC with a CAN bus interface on it.

My understanding was that a license is required if I produce my own Qt libraries.
 

Offline amwales

  • Regular Contributor
  • *
  • Posts: 135
  • Country: gb
Re: GUI with gauges in python
« Reply #48 on: October 23, 2025, 10:34:16 am »
It looks like you are intending to make a device with an application embedded into it and dont want to provide the source.
Take a look at the FAQ https://www.qt.io/faq/qt-commercial-licensing

Quote
Do I need to have a distribution license to distribute my application with a hardware device?
To provide or distribute a Qt-based application on devices under Qt commercial license, distribution licenses are also required. This means if your device incorporates or integrates parts of the Qt software libraries or if the main functionality of the device depends on Qt’s products regardless of whether Qt’s products are distributed or not, then you need a distribution license.
 

Offline SimonTopic starter

  • Global Moderator
  • *****
  • Posts: 18889
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: GUI with gauges in python
« Reply #49 on: October 23, 2025, 10:46:51 am »
Yes then I need a licence or at least whoever I write the code for does :)
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf