EEVblog Electronics Community Forum

Products => Computers => Programming => Topic started by: RoGeorge on June 07, 2022, 10:40:09 am

Title: GUI for Python?
Post by: RoGeorge on June 07, 2022, 10:40:09 am
Any recommendation from your personal experience?  What GUI to use for Python?

- would like to be something "python-esque", easy to use for non-programmers, just like Python is easier to use for amateurs than, say, C++ would be.
- has to have a drag&drop graphic editor to add controls and design the GUI, designing the layout by writing code is not productive for me
- preferably open source and definitely free, it's for hobby and non-commercial projects
- for my level of skills, the old VB5 was just right, with drag and drop buttons and auto generated code, then all you have to do was to populate the empty template with code for the desired actions, would prefer an equivalent for that VB5 style, if there is any
- multiplatform preferably, Linux is a must



Googled already, and tried so far a couple of them:

1. Qt and its "Qt Designer" - (that was some time ago, IIRC the wrapper module was called PyQt), thought I remember it as very cumbersome, hard to learn and also Qt is not entirely free (depending on the type of license one need/choose), certainly not FOSS

2. PySimpleGUI - that was the simplest to use so far, but there's no GUI designer for PySimpleGUI, only some unbaked attempts to import XML ui produced by Qt Designer, which import tool seems abandoned and doesn't work any more

3. DearPyGui - it's very "Windows-ish" (has a registry for its GUI no matter the OS), thought it's open source and with MIT license.  The main drawback (for me) is that it's not really for preparing a GUI, but more for making/developing tools for 2D/3D games.  DearPyGui is based on ImGui, a C++ lib/engine for game devs, which ImGui is sponsored by big names like Blizzard or Ubisoft.  The Python wrapper is very impressive and working, yet it is too recent, the video tutorials from 1-2 years ago are almost not applicable to current version.  And still doesn't have a drag and drop designer.



They are all great Python GUI programs, yet none are just right for me.  The GUI part feels to me like a dragging or a chore task, maybe it's just me, or maybe I have wrong expectation, IDK.  :-//

Been looking for something easy, to use for small project/single developer.  For example to slap a GUI on a small board I make, or to control an existing devboard, or an instrument around the lab, things like that.  For example adding a GUI for a data logger from a COM port, or a GUI for an SCPI tool to automate repeated measurements, or other small Python programs like that.  I'm using mostly Linux/KDE (Kubuntu).


What did you guys are using for that, or seen and liked, when it comes to making a GUI, or what do you think I should try?
Title: Re: GUI for Python?
Post by: GeorgeCh on June 07, 2022, 10:56:35 am
Hi,
    I've tried a number of things but in the end Qt Designer and PyQt seemed more usable and more baked. Yes, at first its hard and cumbersome, but for simple GUIs will be fast and hassle free enough to be worth it.
    I use it from time to time for the exact same purpose -> simple GUI for whatever project I'm working at that moment.


G

PS: If you need to create graphs take a look at PyQtGraph
Title: Re: GUI for Python?
Post by: emece67 on June 07, 2022, 11:07:50 am
.
Title: Re: GUI for Python?
Post by: RoGeorge on June 07, 2022, 05:52:24 pm
In this case back to square one, I guess, thank you both.  Meaning back to Qt, will put some extra effort into learning more Qt.  Its Qt Designer is very good, indeed.
Title: Re: GUI for Python?
Post by: GeorgeCh on June 08, 2022, 05:40:53 am
As will all python things, you will make rapid progress in your application. You can take comfort in this at least.

G
Title: Re: GUI for Python?
Post by: Ed.Kloonk on June 08, 2022, 06:06:27 am
Any recommendation from your personal experience?  What GUI to use for Python?

- would like to be something "python-esque", easy to use for non-programmers, just like Python is easier to use for amateurs than, say, C++ would be.
- has to have a drag&drop graphic editor to add controls and design the GUI, designing the layout by writing code is not productive for me
- preferably open source and definitely free, it's for hobby and non-commercial projects
- for my level of skills, the old VB5 was just right, with drag and drop buttons and auto generated code, then all you have to do was to populate the empty template with code for the desired actions, would prefer an equivalent for that VB5 style, if there is any
- multiplatform preferably, Linux is a must



Googled already, and tried so far a couple of them:

1. Qt and its "Qt Designer" - (that was some time ago, IIRC the wrapper module was called PyQt), thought I remember it as very cumbersome, hard to learn and also Qt is not entirely free, certainly not FOSS

2. PySimpleGUI - that was the simplest to use so far, but there's no GUI designer for PySimpleGUI, only some unbaked attempts to import XML ui produced by Qt Designer, which import tool seems abandoned and doesn't work any more

3. DearPyGui - it's very "Windows-ish" (has a registry for its GUI no matter the OS), thought it's open source and with MIT license.  The main drawback (for me) is that it's not really for preparing a GUI, but more for making/developing tools for 2D/3D games.  DearPyGui is based on ImGui, a C++ lib/engine for game devs, which ImGui is sponsored by big names like Blizzard or Ubisoft.  The Python wrapper is very impressive and working, yet it is too recent, the video tutorials from 1-2 years ago are almost not applicable to current version.  And still doesn't have a drag and drop designer.



They are all great Python GUI programs, yet none are just right for me.  The GUI part feels to me like a dragging or a chore task, maybe it's just me, or maybe I have wrong expectation, IDK.  :-//

Been looking for something easy, to use for small/single person projects.  For example to slap a GUI on a small board I make, or to control an existing devboards, or an instruments around the lab, things like that.  For example adding a GUI for a data logger from a COM port, or a GUI for an SCPI tool to automate repeated measurements, or other small Python programs like that.  I'm using mostly Linux/KDE (Kubuntu).


What did you guys are using for that, or seen and liked, when it comes to making a GUI, or what do you think I should try?

As a long-time non-gui C guy, what I have been using recently is Glade. I don't know if you'll find anything as seamless as VB. Glade does a pretty good job if you spend the time and watch any of the 20-video series tutorials on youtube. I recommend watching a series all or most of the way through to get a real feel for Glade.

I only use C though (not python) because I'm not a masochist.
[ducks for cover]

 :popcorn:

edit:  from the Glade Website:
Quote
By using GtkBuilder, Glade XML files can be used in numerous programming languages including C, C++, C#, Vala, Java, Perl, Python,and others.
Title: Re: GUI for Python?
Post by: RoGeorge on June 08, 2022, 07:01:44 am
Looks very eye candy, will give Glade a try, too, thanks.  :-+
Used C in the past, but now I prefer Python.  Python is more productive, and has modules for anything, from math to controlling an RTL-SDR.

For amateur programmers like me, this is how writing in Python feels:
(https://c.tenor.com/qqlA0It5cr8AAAAC/duck-yeah.gif)

 ;D
Title: Re: GUI for Python?
Post by: Ed.Kloonk on June 08, 2022, 07:19:26 am
Looks very eye candy, will give Glade a try, too, thanks.  :-+
Used C in the past, but now I prefer Python.  Python is more productive, and has modules for anything, from math to controlling an RTL-SDR.

For amateur programmers like me, this is how writing in Python feels:
 ;D

FWIW, I have given Python a few fair chances to woo me during 'the thing'. I set up the full IDE python dev suites and I had nothing but trouble. The crashes. The libs. The IDE's desire to engulf your whole little project and spam your directory with stupid config files..

I'm a simple man with simple needs. Geany and Glade. And C.   :-+

Maybe it works better on windows. But Python makes me stabby.
Title: Re: GUI for Python?
Post by: RoGeorge on June 08, 2022, 08:56:32 am
I have no idea what Python IDE full dev suite means.  :o

AFAIK Python is only the interpreter for the Python language.  Sometimes it came bundle with a very simple IDE called "IDLE" (mostly for Windows distributions).  Any text editor or preferred IDE can be used instead IDLE.  There is also an interactive mode, text only, where one can type Python in a terminal/cmd.

Usually Python is already present in Linux.  For Windows, I don't know.  In the past for Windows it used to be an Python.exe to download and double click/next/next/next for installing.  For something like a Debian flavour Linux it's
Code: [Select]
apt install python3
from a root terminal, or use sudo.

One of the Python mantras is "batteries included", so most of the basic stuff is ready to use.  However, to do something more weird, like plotting a 3D chart while controlling your favorite RTL-SDR usb radio, you'll need to add specialized Python modules (or write your own if you prefer).

To install Python modules, there is a command line tool, called "pip", and official Python "repositories" (PyPI) for additional Python modules, so all you have to do to install additional Python functionality (modules) is to write in a command line:
Code: [Select]
pip install matplotlib
pip install pyrtlsdr

Then open any text editor, write and save this as RTL-SDR.py
Code: [Select]
from pylab import *
from rtlsdr import *

sdr = RtlSdr()

# configure device
sdr.sample_rate = 2.4e6
sdr.center_freq = 95e6
sdr.gain = 4

samples = sdr.read_samples(256*1024)
sdr.close()

# use matplotlib to estimate and plot the PSD
psd(samples, NFFT=1024, Fs=sdr.sample_rate/1e6, Fc=sdr.center_freq/1e6)
xlabel('Frequency (MHz)')
ylabel('Relative power (dB)')

show()

To run it, in a terminal/cmd type
Code: [Select]
python RTL-SDR.py

And you'll get this
(https://warehouse-camo.ingress.cmh1.psfhosted.org/26111204485503f498f7d169bb55ca02fda568fa/68747470733a2f2f692e696d6775722e636f6d2f68466867382e706e67)
Source:  https://pypi.org/project/pyrtlsdr/

Same can be achieved in interactive mode, by typing it all directly in Python (in a terminal/cmd type "python", then at the >>> python prompt type the above text), thought usually a .py script is preferred.

It's that easy.  You just learned how to Python.  ;D

Joke aside, if you try to do the same plot in C, I'll bet it would be much harder, and will need a more complicated setup.
Title: Re: GUI for Python?
Post by: emece67 on June 08, 2022, 09:24:22 am
.
Title: Re: GUI for Python?
Post by: RoGeorge on June 08, 2022, 09:39:11 am
He, he, same preference here.  I'm using VS Codium (https://vscodium.com/), which is VS Code compiled without Microsoft's telemetry and alike options.

VS Code is one of the finest IDE out there, IMHO.  Saying that while I'm not a Microsoft fan.  Sometimes less known, VS Code / VS Codium is also free and open source, even if it's a software coming from Microsoft.
Title: Re: GUI for Python?
Post by: Ed.Kloonk on June 08, 2022, 09:40:38 am
I have no idea what Python IDE full dev suite means.  :o

Installing IDE environments consisting of Eclipse or PyCharm. Even tried Eric.

Quote

AFAIK Python is only the interpreter for the Python language. 

Yes. But I wanted to follow along with various youtube tutes and be able to also take advantage of run/stop features.

Nightmare.

I think it was eclipse, a vanilla install, wouldn't even open a new project without choking. Java something or other.
Title: Re: GUI for Python?
Post by: emece67 on June 08, 2022, 10:59:05 am
.
Title: Re: GUI for Python?
Post by: RoGeorge on June 08, 2022, 01:36:39 pm
Yep.
- Install VS Codium as instructed for your OS:  https://vscodium.com/
- Open Codium and from inside it, hit Ctrl+Shift+X, and search for Python, to install the VS Codium extension called "Python", the one from Microsoft, with all the autocomplete, syntax, debugging, Jupyter, etc.
- Close Codium then start it again, and that's it. 

Now inside VS Codium go to menu, File -> New file... and click Python File, and start typing your Python code:
Code: [Select]
print("B a z i n g a   !!!")
Hit Ctrl+F5 to Run it, or F5 to Debug run it.
You are now almost Python guru level. :D


Now, to get fancy and back to GUI, let's try a CPU % display with Tkinter, the default GUI framework coming with Python (batteries included is the Python mantra), GUI based on Tcl/Tk.  However, to read the CPU usage we'll need to install a new Python module called 'psutil', by typing in a terminal/cmd:
Code: [Select]
pip install psutil

Back to VS Codium and type this:
Code: [Select]
import psutil
import tkinter as tk

def update_label_2():               # a function to autoupdate the proc %
    cpu_percent = psutil.cpu_percent()
    label_2.config(text=str(cpu_percent))
    GUI.after(100, update_label_2)  # reschedule to run again after 100ms

GUI = tk.Tk()                       # create the top window of a GUI

label_1 = tk.Label(GUI, text=':o)   CPU %   :o)')  # create a label inside top window
label_1.pack()                      # render the label_1 label

label_2 = tk.Label(GUI, text='100') # a second label
label_2.pack()

btn = tk.Button(GUI, text='E X I T', command=GUI.quit) # an exit button
btn.pack()

GUI.after(0, update_label_2)        # schedule to call update_label_2 function at first run
tk.mainloop()                       # start the window loop
Hit Ctrl+F5 to Run it.  A window with live processor usage will open.

See?  It's hard to find an easier language.
You are now officially Knight level 14 in Python!  8)
Title: Re: GUI for Python?
Post by: Nominal Animal on June 08, 2022, 05:09:49 pm
I use both Gtk+ 3.0 (in C) and Qt 5 (in Python 3) quite a lot.

Both support defining user interfaces in an XML-based language, as .ui files.  In Gtk+, this is done using the GtkBuilder (https://docs.gtk.org/gtk3/class.Builder.html#gtkbuilder-ui-definitions-builder-ui) interface (better old documentation (https://developer-old.gnome.org/gtk3/stable/GtkBuilder.html)); in Qt, using the QUiLoader (https://doc.qt.io/qtforpython-5/PySide2/QtUiTools/QUiLoader.html) interface.

There are two different Python 3 bindings for Qt5: PyQt5 and PySide2.  There exists a compatibility layer, QtPy (https://github.com/spyder-ide/qtpy), which allows an application to use both.  A couple of years ago in a different thread here, I showed a minimal implementation (https://www.eevblog.com/forum/programming/pythonic-solution-for-accessing-class-properties/msg3327142/#msg3327142) providing the same – i.e., write your Python 3 and Qt 5 code in a way that works with either PyQt5 or PySide2, as long as at least one is installed.

Later on in that same thread, I showed an example (https://www.eevblog.com/forum/programming/pythonic-solution-for-accessing-class-properties/msg3328970/#msg3328970) of how to use the uic.py in the post linked to above, and an .ui file (that one can edit in Qt Designer), to talk to an USB-connected microcontroller on non-Windows machines (because it uses the POSIX termios for the USB Serial).

In general, I'm a heavy proponent of the approach of letting end users mess with the User Interface as much as they want, because I myself as an end user want that kind of power.  If there is any heavy computation or Secret Sauce, I put it in native code, in a dynamically loaded library, as interfacing to such is easy from Python.  And anything but trivial user interfaces are better described using an .ui file; nobody needs the hassle of maintaining code that implements one in the long term!

While my code is generally intended to be easily portable across all systems, I do not currently have a Windows machine (or a VM with Windows; I should set one up for exactly this reason!), so they often lack the quirks Windows need.  It is not an ideological choice; it's just that I'd rather be ready to write it when needed, instead of guessing and not testing it works, and possibly leading others astray.
Title: Re: GUI for Python?
Post by: paul@yahrprobert.com on June 09, 2022, 01:35:29 am
wxPython is alive and well and runs under python 3.x nowadays.  go to www.wxpython.org (http://www.wxpython.org) for details.  There are several tools for building a gui such as wxGlade and wxDesigner, though I prefer to write my code by hand using the "sizers" to lay out my widgets.  The coolest thing is that it comes with a comprehensive demo package that shows all the widgets and lets you steal code from them to build your own app.
Title: Re: GUI for Python?
Post by: RoGeorge on June 09, 2022, 06:13:49 am
I use both Gtk+ 3.0 (in C) and Qt 5 (in Python 3) quite a lot.

Tried Qt some time ago, following your advice here, thanks:  :-+
https://www.eevblog.com/forum/programming/python-becomes-the-most-popular-language/msg3763337/#msg3763337 (https://www.eevblog.com/forum/programming/python-becomes-the-most-popular-language/msg3763337/#msg3763337)
but I didn't try Gtk because back then I didn't like its general look/graphic design.

About Gtk 3, looked at it again yesterday and still don't like it.  It's graphic elements seems like Gtk3 was designed for a phone or a tablet.  I want something that looks like a desktop GUI, anything between Win95 and WinXP look, or KDE from Linux, would be great.  Gtk 2 looks a little better, but still not as nice as KDE, and since now there is Gtk 3, I expect Gtk 2 to be abandoned in the future.

In terms of programming easiness, at a brief browsing of its doc pages Gtk 3 looks to me about the same as any other in terms of number of lines per a given goal to achieve, but I wouldn't be able to identify if there are programming advantages when using Gtk3.

Given the fact that visually I prefer the Qt/KDE look over Gtk/Gnome, is there any programming advantage to make one choose Gtk3 over something else?



wxPython is alive and well and runs under python 3.x nowadays. go to www.wxpython.org (http://www.wxpython.org) for details.
Never tried wxPython before, because it seemed abandoned.  The latest news in the linked page is from the end of 2020, yet https://github.com/wxWidgets/Phoenix (https://github.com/wxWidgets/Phoenix) seems active, with last submit from yesterday.  :-//

Will test wxPython, too, thanks.
Title: Re: GUI for Python?
Post by: Nominal Animal on June 09, 2022, 09:54:15 am
Given the fact that visually I prefer the Qt/KDE look over Gtk/Gnome, is there any programming advantage to make one choose Gtk3 over something else?
If we are talking about programming in Python, no.

If we talk about programming in different languages, then Gtk+ is natively C, and Qt C++.  Other than that, I find them generally very similar in purpose and approach.

With Python 3, I do prefer Qt 5, but the reason has more to do with visuals and availability of documentation (for both PySide2 (https://doc.qt.io/qtforpython-5/) and PyQt5 (https://www.riverbankcomputing.com/static/Docs/PyQt5/module_index.html) bindings, noting that the main difference is between PySide2's QtUiTools (https://doc.qt.io/qtforpython-5/PySide2/QtUiTools/index.html) and PyQt5's uic (https://www.riverbankcomputing.com/static/Docs/PyQt5/api/uic/uic-module.html), which can be bridged with QtPy or the aforementioned uic.py from it) than anything else.

That said, there is "Python" documentation for Gtk+, too; namely, the Gtk+ 3.0 PyGObject reference (https://lazka.github.io/pgi-docs/Gtk-3.0/).  PyGObject is the Python interface to all glib (https://docs.gtk.org/glib/)-based libraries: GObject provides introspection files (see /usr/share/gir-*/*.gir; the format is XML-based, so human readable) directly from the C sources, that PyGObject (gi Python module, python3-gi Debian package) can generate the Python bindings for at run time.  That is, you only really need the runtime dynamic library files, the gobject introspection files, and interpreted languages like Python and Perl can generate the bindings for the libraries at run time.  Which is nice.

If I were already using gi in Python to interface to some library, I would then choose Gtk+ for the UI instead of Qt.  Thus, I guess there are situations where one would find it advantageous/easier to pick one instead of the other, but it really depends on the application one is implementing; and most of all, what other libraries one intends to use.

Serial port access is one of those complicated things.  I personally am comfortable using termios and low-level I/O (in both C and Python), but it isn't portable (to Windows).  The existing serial port Python libraries just can't deal with all possible use cases, and many make inane stupid assumptions (like write() syscall on a serial port never failing and never returning a short count) that leads me to trust them as much as I trust snake oil salesmen.  (And I cannot write a "better one" myself, because the built-in termios Python module suffices, and I don't know enough about Windows' serial port shenanigans to design a portable API.  Heck, I don't even like using the TTY layer in POSIXy systems for USB Serial, because it slows comms down at USB 2.0 High Speed (480 Mbit/s).  It's just easier to switch to USB bulk transfers than to try and get a new character device driver accepted upstream for stuff that already is supported, and only a bottleneck for a few very fast MCUs.)
Title: Re: GUI for Python?
Post by: PKTKS on June 09, 2022, 01:58:07 pm
Nominal  placed some interesting points about wrappers

All Python and PERL  ( not TCL ...)  GUIs are wrappers..

The only NATIVE  GUI builtin in around all these kits surprisingly hits the folks on FPC

the IDE https://www.lazarus-ide.org/ (https://www.lazarus-ide.org/) is a piece of cake and a TurboVision debugger is available.

Apart C and C++  there is no excuse to (also consider or) not use PASCAL
the pros list is long

and the typical whiners  claims are just whining ...

Paul
Title: Re: GUI for Python?
Post by: RoGeorge on June 09, 2022, 03:05:00 pm
Thanks for the link, there's a big collection there of how each GUI looks like under different OSs https://wiki.lazarus.freepascal.org/Screenshots

Used Turbo Pascal for a while, it's a nice language but I don't remember it as productive as Python.  And there is another (unfair) advantage Python has, and that's the abundance of its modules.  Because it is so popular, there is an already written module for almost anything you can imagine or need to do from Python.

To me software is yet another pair of pliers in the toolbox.  I'm an electronist, so all I know is I have to control some device in the lab, or to process a file, etc. and want to see that done.  For sure there is also beauty and elegance and quality in software, just that I know too little to notice all that.  When one is not a programmer there is only pragmatism, with no fanboy-ism and no attachment when it comes to which language or which software to use.  Whatever fits the bill.

I've read the above paragraph before posting, and realized I might be a "software sociopath".  ;D
 :scared:
Title: Re: GUI for Python?
Post by: PKTKS on June 09, 2022, 03:20:43 pm
Thanks for the link, there's a big collection there of how each GUI looks like under different OSs https://wiki.lazarus.freepascal.org/Screenshots

Used Turbo Pascal for a while, it's a nice language but I don't remember it as productive as Python.  And there is another (unfair) advantage Python has, and that's the abundance of its modules.  Because it is so popular, there is an already written module for almost anything you can imagine or need to do from Python.
(..)

Surprisingly  for anyone w bare minimal PASCAL skills...  today FPC offers the FULL *NIX ecosystem already ready ... if you spare some time to fuss around  you will find already made wrappers for X11, SQL, Postgres, sqlite, all modern toolkits... TurboVision..  GDB,,  and a whole lot more..

Impressive amount of progress for a veteran fast stable and predictable language..

With bare minimal skills  it will be  easier and much more robust than Python
Reason being: the  type safe compiler ...  lots of ready units...  no traceback shit

Support large projects with any modern GUI and inter operating systems

No excuses to not have it around
Paul
Title: Re: GUI for Python?
Post by: RoGeorge on June 10, 2022, 05:51:00 am
There is another interesting GUI called REMI (REMote Interface), which doesn't use any GUI framework.  Instead, REMI builds a webpage, and its GUI opens in a web browser.  REMI has an embedded webserver and a WISIWYG GUI editor, too.  There is a standalone option but I didn't try that yet (standalone as in no web browser needed?).

The developer doesn't need to know HTML or other web technology, only Python.

https://github.com/rawpython/remi (https://github.com/rawpython/remi)
https://github.com/rawpython/remi/tree/master/editor (https://github.com/rawpython/remi/tree/master/editor)

https://www.youtube.com/watch?v=2gWkRuj_CyQ (https://www.youtube.com/watch?v=2gWkRuj_CyQ)

A web GUI seems very appealing, especially when the Python application will run on a remote SBC, e.g. on a headless Raspberry Pi.  I like that.

Installed REMI last night and got an error from rhe REMI editor at saving the webgui.  It was early AM hours and probably I've missed some steps, will try again this weekend.
Title: Re: GUI for Python?
Post by: bd139 on June 10, 2022, 07:20:54 am
Built some large things in wxpython. Can recommend. As for IDE VSCode is where it’s at these days. When I say where it’s at, I mean that there is significant community attention to actually make it a nice place to be.

Really though when I build GUI applications these days I tend to build them in Go as an http server and write the UI in HTML/JS. That has the advantage of producing a single cross compiled binary with no dependencies per platform, strong typing throughout, very low footprint. Most importantly it’s actually possible to write a decent test suite against a browser application compared to other solutions.
Title: Re: GUI for Python?
Post by: Ed.Kloonk on June 10, 2022, 07:36:19 am
Built some large things in wxpython. Can recommend. As for IDE VSCode is where it’s at these days. When I say where it’s at, I mean that there is significant community attention to actually make it a nice place to be.

Really though when I build GUI applications these days I tend to build them in Go as an http server and write the UI in HTML/JS. That has the advantage of producing a single cross compiled binary with no dependencies per platform, strong typing throughout, very low footprint. Most importantly it’s actually possible to write a decent test suite against a browser application compared to other solutions.

Wow. Mind blown.

Do you know of a good tutorial where one could follow a hullo world example (and perhaps beyond) without too much install library hell?
Title: Re: GUI for Python?
Post by: bd139 on June 10, 2022, 07:53:35 am
Built some large things in wxpython. Can recommend. As for IDE VSCode is where it’s at these days. When I say where it’s at, I mean that there is significant community attention to actually make it a nice place to be.

Really though when I build GUI applications these days I tend to build them in Go as an http server and write the UI in HTML/JS. That has the advantage of producing a single cross compiled binary with no dependencies per platform, strong typing throughout, very low footprint. Most importantly it’s actually possible to write a decent test suite against a browser application compared to other solutions.

Wow. Mind blown.

Do you know of a good tutorial where one could follow a hullo world example (and perhaps beyond) without too much install library hell?

If you don't want to actually install it you can just write Go here: https://go.dev/play/

Download here: https://go.dev/dl/ ... follow install instructions

Hello world: https://gobyexample.com/hello-world

Tutorials here: https://gobyexample.com

Use VSCode as an IDE and it will automatically install language support, debugger etc.

This is NOT a scripting language for reference so expect to do some more legwork to get to the destination. It is also obtuse about doing things correctly. But the destination is less of a shit show than shipping dependency hell with your apps.
Title: Re: GUI for Python?
Post by: Karel on June 10, 2022, 08:04:06 am
1. Qt and its "Qt Designer" - (that was some time ago, IIRC the wrapper module was called PyQt), thought I remember it as very cumbersome, hard to learn and also Qt is not entirely free, certainly not FOSS

Qt is entirely and certainly FOSS. Pick your license: GPL or LGPL at your choice.

The fact that they also offer a commercial license doesn't make Qt "less FOSS".

If you say that software that's opensource and released under the GPL and/or LGPL isn't FOSS,
then many software will not be FOSS like for example the GTK toolkit.
Title: Re: GUI for Python?
Post by: RoGeorge on June 10, 2022, 08:39:02 am
Built some large things in wxpython. Can recommend.

Thank you, followed your advice and looked at it minutes ago.  Though I won't use wxPython because it is based on wxWidgets, which wxWidgets main webpage https://www.wxwidgets.org (https://www.wxwidgets.org) displays a banner with political declarations/sides/opinions/whatever.

I don't care and don't want to know who one is with, or against, or how righteous one might be, or not be, I just don't want activism/political endorsed software, no matter who's side it takes, and no matter how much technical merits that software might have.

I'm so full sick of any kind of propaganda.  Writing code is a part of my tinkering hobbies, and I want to enjoy the time spent with a hobby project.  I don't want to be reminded to worry about anything during that particular time frame.  That's the whole point of doing a hobby activity:  getting a refuge from the worries one might have because of the problems existing in the world, or in the own life.  Also, I don't like to be told who's side to take, or to be guilt-tripped for not taking any side, and so on.  Got enough propaganda trauma during Ceausescu's Romania, before 1989, and now (in the last decade) propaganda is at unbearable levels again, just like it was back then, except that now it's coming from other ideologies than back then.  Same shit, different flavors.
Title: Re: GUI for Python?
Post by: RoGeorge on June 10, 2022, 08:52:30 am
1. Qt and its "Qt Designer" - (that was some time ago, IIRC the wrapper module was called PyQt), thought I remember it as very cumbersome, hard to learn and also Qt is not entirely free, certainly not FOSS

Qt is entirely and certainly FOSS. Pick your license: GPL or LGPL at your choice.

My misunderstanding, sorry, and thanks for taking the time to explain.  Corrected my post with a text strike through.
Title: Re: GUI for Python?
Post by: Karel on June 10, 2022, 09:49:53 am
I don't care and don't want to know who one is with, or against, or how righteous one might be, or not be, I just don't want activism/political endorsed software, no matter who's side it takes, and no matter how much technical merits that software might have.

I'm so full sick of any kind of propaganda.  Writing code is a part of my tinkering hobbies, and I want to enjoy the time spent with a hobby project.  I don't want to be reminded to worry about anything during that particular time frame.  That's the whole point of doing a hobby activity:  getting a refuge from the worries one might have because of the problems existing in the world, or in the own life.  Also, I don't like to be told who's side to take, or to be guilt-tripped for not taking any side, and so on.  Got enough propaganda trauma during Ceausescu's Romania, before 1989, and now (in the last decade) propaganda is at unbearable levels again, just like it was back then, except that now it's coming from other ideologies than back then.  Same shit, different flavors.

I couldn't agree more.
Title: Re: GUI for Python?
Post by: bd139 on June 10, 2022, 09:58:34 am
Everyone has political, religious, social ideologies which are probably incompatible with yours. It doesn't mean we don't have to be in the same room as them. It's best to be objective and focused on the problem you are solving otherwise you will just end up walking round in circles trying to find people who agree with you and being disappointed.

I would suggest we keep this focused on technical merit.
Title: Re: GUI for Python?
Post by: RoGeorge on June 10, 2022, 01:35:22 pm
There is this big list of GUI software for Python.   :-+
https://wiki.python.org/moin/GuiProgramming

Adding it here just for the docs, and because it didn't pop in the previous searches.
Title: Re: GUI for Python?
Post by: mag_therm on June 10, 2022, 02:34:56 pm
As with RoGeorge, I am hobby linux user.
I have a license for Xojo but it is too cumbersome for a simple GUI.

There is a very basic editor called Gtkdialog that is maybe one step up from Zenity and Glade.
This is different from the more popular one using C, with a similar name.

Gtkdialog allows a persistent window populated with multi controls and tabs and can run as a parent for underlying bash or python scripts etc.
It is a bash script with a multiline command written in xml, that defines the window and controls.
A limitation is that (as far as I know) there is no way that an external process can update a field until a control action on the GUI.
Comms to and from the controls can be done by  files, as I use it.

With all its limitations (included sparse documentation) I was able to get a job done in short time with no problems
I put up a screenshots recently on the ham forum, here again:
https://app.box.com/s/v24an4ea1iiib9jvcpyeh49j9wx0518i  showing the simple layout, across and down in order of the xml lines
https://app.box.com/s/tf7936ph90rf4vljgbo427sevbtn6i85  showing how to get back data from a button press.

The best description I found so far:
https://pclosmag.com/html/Issues/201408/page07.html
Title: Re: GUI for Python?
Post by: PKTKS on June 10, 2022, 03:01:03 pm
There is this big list of GUI software for Python.   :-+
https://wiki.python.org/moin/GuiProgramming

Adding it here just for the docs, and because it didn't pop in the previous searches.


not really .... it is not like that... 

They are several implementations of the same thing...  most of them are wrappers over the same toolkit  GTK.. Qt ... Wx... and even Python itself...   that just mean that you will have problems to have a sane single wrapped ...

reason being...:
- unreliable newbie shit over others...
- same thing several times instead of a single framework well maintained..
- very fast obsolete versions leading to disaster next corner..

.. you consider a TOOLKIT?

First thing on the list is - WELL MAINTAINED
A wrapper?   it must be over a solid toolkit  done by clever skilled people w/long term sight.

Python reached a vast legion of newbies.. 
this result is very problematic

you should avoid these over and over wrappers...

Paul
Title: Re: GUI for Python?
Post by: bd139 on June 10, 2022, 03:03:10 pm
Ah PKTKS to fulfil those requirements it sounds like you're promoting something well maintained, stable and no wrapping at all. May I recommend win32 and c++ :-DD
Title: Re: GUI for Python?
Post by: PKTKS on June 10, 2022, 03:06:25 pm
Not at all..


Surprisingly  as I pointed above...  FPC as of today holds the most broad well maintained and supported UNITS  (they are really native API calls UNITS not just  wrappers)  over the main toolkits

GTK  Qt  Wx  Postgres MySQL sqlite.. and dozen others..  like TurboVision

There is no duplicated efforts  ..
no traceback shit

Definitively  not newbie work ...

Just confirm for yourself..

Paul
Title: Re: GUI for Python?
Post by: bd139 on June 10, 2022, 03:12:32 pm
I've written a fair bit of Pascal over the years. Just no.
Title: Re: GUI for Python?
Post by: PKTKS on June 10, 2022, 03:21:00 pm
I've written a fair bit of Pascal over the years. Just no.

I was introduced to PASCAL on  an Burroughs mainframe. Later on IBM mainframe...

Then over 90s/00s there was a shift to more "FAST/RAD" tools...

Nevertheless never really could spare PASCAL..

Recently over the last decade.. the progress of Object Oriented PASCAL made me gradually turn over and over to the fast stable and good finish of the whole thing...

I am using it today on regular base...  My BENCH inventory now is SQLite TurboVision  based..
and other tools keep being very well ported..  easier than C++

Paul
Title: Re: GUI for Python?
Post by: SiliconWizard on June 10, 2022, 05:51:46 pm
Modern Object Pascal is pretty good. You may have myriads of reasons for not using it (the ecosystem, too few potential developers available, very few compilers, not standardized AFAIK, you already have a large code base in other languages and want to reuse it, etc), but if you're a lone developer or a small team for which those points are not a problem, go for it.

Title: Re: GUI for Python?
Post by: PKTKS on June 10, 2022, 06:01:05 pm
Modern Object Pascal is pretty good. You may have myriads of reasons for not using it (the ecosystem, too few potential developers available, very few compilers, not standardized AFAIK, you already have a large code base in other languages and want to reuse it, etc), but if you're a lone developer or a small team for which those points are not a problem, go for it.


... and it has been just like this...   since late 70s on the Burroughs...
early 80s... IBM..

Pretty steady and predictable...  ^-^

Paul
Title: Re: GUI for Python?
Post by: MK14 on June 10, 2022, 06:11:13 pm
TurboVision  based..

Do you really mean TurboVision, or are you actually talking about Free Vision ?

https://en.wikipedia.org/wiki/Turbo_Vision

https://wiki.freepascal.org/Free_Vision

Free Vision seems to be the FreePascal (IDE) version.
Title: Re: GUI for Python?
Post by: PKTKS on June 10, 2022, 06:16:31 pm
TurboVision  based..

Do you really mean TurboVision, or are you actually talking about Free Vision ?

https://en.wikipedia.org/wiki/Turbo_Vision

https://wiki.freepascal.org/Free_Vision

Free Vision seems to be the FreePascal (IDE) version.

That is really FreeVision - which is a more or less direct translation of Turbo Vision.

It is faster and more TERM friendly than TurboVision.

I do have TurboVision as well but the API is C++ based.

FreeVision is a perfect implementation ... a very good work.. all in native PASCAL


BTW thanks for pointing that...

worth mention that although both can run on any term...
FreeVision is more easy to set .. VT100 and XTerm are best supported

RXTERM works pretty well on both

Actually the IDE is all based on FreeVision with integrated debugger...

The FreeVision itself is a 99.999% ported TurboVision PASCAL UNIT

Paul


PS> anyone interested should look for Robert Hohne port of latest Borland TurboVision for UNIX
 latest Borland 2.0 was ported and match tvision-2.2.1 (under Robert Hohne rhide)

Borland made TurboVision for PASCAL available in TurboPascal 7.0
and that implementation seems to be root for FreeVision..  (my opinion based on my use)

Both (C++ Robert Hohne ) and PASCAL (from FPC) work pretty fine


Title: Re: GUI for Python?
Post by: SiliconWizard on June 10, 2022, 06:20:08 pm
Ah, but FreeVision is text-based UI only, right?
I would call that UI, but not GUI.
But you can definitely design GUIs with FreePascal and Lazarus. It's close-ish to Delphi as far as I could tell, but I haven't touched either in ages so I'm not too sure.
Title: Re: GUI for Python?
Post by: PKTKS on June 10, 2022, 06:34:04 pm
Ah, but FreeVision is text-based UI only, right?
I would call that UI, but not GUI.
But you can definitely design GUIs with FreePascal and Lazarus. It's close-ish to Delphi as far as I could tell, but I haven't touched either in ages so I'm not too sure.

Far more than this...

TurboVision is a whole DESKTOP SOLUTION from Borland...

A TUI  Dekstop  with streaming object capabilities and several other class goods
in short you can even record your TUI to a file..
The whole thing is a marvelous work

Paul

PS. btw it has also object record and streaming (like dialogs.. records... anything)
Title: Re: GUI for Python?
Post by: Nominal Animal on June 11, 2022, 05:24:51 pm
Qt is entirely and certainly FOSS. Pick your license: GPL or LGPL at your choice.
Anything and everything in Qt that an application developer can use, definitely.  Everything Qt installed in Linux distributions is available under FOSS licenses.

However, there is one or two Qt packages that are not licensed under FOSS licenses, and not available in standard Linux distributions.  The main one is Qt for MCUs (https://doc.qt.io/QtForMCUs-2.1/qtul-licensing.html), which is only available under a commercial or an evaluation license.



I've talked about this in a different thread, but I'll repeat the core points: One can create proprietary Qt applications based on the LPGL license.  One will not be required to expose their own source code.  Open source applications can use the GPL license, proprietary applications the LGPL license (if they link dynamically to the Qt libraries).  The commercial license gives you commercial support.

Satisfying the Qt developer community, and the Qt company, is easy: be proud of using Qt in your application, link to qt.io for further information, and abide by the license.  If you compile your own distributable Qt binaries, be open about the exact toolchain (including compiler version and library configuration); optimally, you'd provide build scripts that builds them for each target OS and architecture when run in a directory containing the pristine upstream sources.  If you do modify any of the Qt sources, you do need to provide your customers with the modified Qt sources too.

In short: the language at the web pages may seem scary to those used to very friendly FOSS projects, but that's just marketing.  Everything behind that is quite friendly to FOSS developers.  And if you are a developer relying on the LGPL license, they aren't hostile, just indifferent: you neither hurt nor help.  (But, if you do stuff I mentioned above, you actually do help a bit, at least as an example of doing things right as a completely outside party.)



If you say that software that's opensource and released under the GPL and/or LGPL isn't FOSS,
then many software will not be FOSS like for example the GTK toolkit.
The fact proprietary non-FOSS closed-source applications and libraries are explicitly allowed to dynamically link to any LGPL-licensed library/toolkit/framework, can be confusing to those who do not understand the core idea of FOSS:  it is not about zero price, it is about end-user freedom.

Even the dynamic linking requirement is really about end users: they must be able to recompile or create their own variants of those LGPL-licensed libraries, so that they can have the proprietary non-FOSS application run with those modified/different libraries.

This is the reason why so many of the core libraries are LGPL-licensed.  (I do not consider LGPL to be a "compromise" that for example the Wikipedia LGPL article (https://en.wikipedia.org/wiki/GNU_Lesser_General_Public_License) claims, because LGPL fits perfectly well within the free software (https://en.wikipedia.org/wiki/Free_Software) philosophy: it is about personal, end-user freedom.  After all, it initially wasn't "Lesser GPL", it was "Library GPL".  It's just that it depends on the exact library what license is best suited; not all libraries need to or are best licensed under LGPL.)
Title: Re: GUI for Python?
Post by: RoGeorge on June 11, 2022, 07:46:47 pm
No longer than this morning I've tried to install the latest and greatest Qt, which is Qt6, only to realize that there is no Qt6 installer binaries.  Then I've bumped into this blog https://embeddeduse.com/2020/02/02/less-love-for-foss-qt-users/ so it seems the last binary available without a Qt account was Qt5.14, and from that one on, one either has to register on Qt.io, or build from sources.  :-//

Not sure if I properly understood that, but if it is so, then I'll strike out Qt from the candidates.  I understood that I can build from sources without an account, but such a trend still worries me.  Whatever needs an online account is a big no for me, will only use such products only if there is no other option.



Guess I tried too many GUI frameworks in a too shorter time and probably burned out, because now I'm seriously thinking in just scribbling future GUIs on a piece of paper and manually translate the hand drawings to Tkinter code, or maybe to PySimpleGUI (a simplified wrapper over many possible frameworks, including Tkinter, Qt, etc.)  PySimpleGUI has good documentation and many online tutorials. 

For Tkinter there is this standalone WYSIWYG editor called PAGE (https://sourceforge.net/projects/page/files/) (should work to generate Tcl/Tk, too), but I've tried it only for Python, and it worked.  A little too basic, from sourceforge, seems straight from the 90s and not very intuitive for these days, but it kind of works.  :)

Meanwhile tried REMI (https://github.com/rawpython/remi), too.  It finally worked but seems an underpowered project, with almost no documentation.  Has enough examples, though.  Should work on RaspberryPi, too, but didn't try that yet.
Title: Re: GUI for Python?
Post by: MK14 on June 11, 2022, 08:12:06 pm
No longer than this morning I've tried to install the latest and greatest Qt, which is Qt6, only to realize that there is no Qt6 installer binaries.  Then I've bumped into this blog https://embeddeduse.com/2020/02/02/less-love-for-foss-qt-users/ so it seems the last binary available without a Qt account was Qt5.14, and from that one on, one either has to register on Qt.io, or build from sources.  :-//

Not sure if I properly understood that, but if it is so, then I'll strike out Qt from the candidates.  I understood that I can build from sources without an account, but such a trend still worries me.  Whatever needs an online account is a big no for me, will only use such products only if there is no other option.





I was tempted to mention it, but now you have, I will as well.

I also recently tried QT.  I had a mini-nightmare of a time trying to install it, because it is so big (like >10 Gig, temporarily needed, just to install itself), and sometimes like 47.5 GB, just to add more stuff to the QT.  It tended to be very fussy about how it was installed, and tended to NOT work out of the box.

I had to make an account on the QT thing (for this supposedly FREE open source software), rather/very annoying.  But if it is included with a version of Linux, you can escape needing a free account.

Eventually, I did get it to install and work, by using openSuse, and pre-selecting it to be installed.  I think the repositories of a particular Linux, would have a working version, as well.

I suspect QT is worthwhile, if a rather big GUI project, or lots of GUIs or professional looking/maintainable GUIs are required.

But for hobby, one-off, quick (until you climb its learning curve), things.  Other choices, such as FreePascal/Lazarus, may make more sense.  But if you're determined to go the Python route, then Pascal maybe isn't for you.
Title: Re: GUI for Python?
Post by: Karel on June 11, 2022, 08:31:00 pm
I had to make an account on the QT thing (for this supposedly FREE open source software), rather/very annoying.

Absolutely not. Here you go:

https://ftp1.nluug.nl/languages/qt/official_releases/qt/

And here is a mirrorlist if you prefer another source:

https://download.qt.io/static/mirrorlist/

Title: Re: GUI for Python?
Post by: Karel on June 11, 2022, 08:34:27 pm
However, there is one or two Qt packages that are not licensed under FOSS licenses, and not available in standard Linux distributions.  The main one is Qt for MCUs (https://doc.qt.io/QtForMCUs-2.1/qtul-licensing.html), which is only available under a commercial or an evaluation license.

This thread is about a GUI for Python. So, I was clearly speaking about the Qt GUI framework which is FOSS.
Title: Re: GUI for Python?
Post by: MK14 on June 11, 2022, 08:37:21 pm
I had to make an account on the QT thing (for this supposedly FREE open source software), rather/very annoying.

Absolutely not. Here you go:

https://ftp1.nluug.nl/languages/qt/official_releases/qt/ (https://ftp1.nluug.nl/languages/qt/official_releases/qt/)

And here is a mirrorlist if you prefer another source:

https://download.qt.io/static/mirrorlist/ (https://download.qt.io/static/mirrorlist/)

Your link says ......

Quote
Due to The Qt Company offering changes, open source offline installers are not available any more since Qt 5.15. Read more about offering changes in the https://www.qt.io/blog/qt-offering-changes-2020 (https://www.qt.io/blog/qt-offering-changes-2020) blog.

If you need offline installers, please consider our new Qt for Small Business offering: https://www.qt.io/blog/available-now-qt-for-small-businesses (https://www.qt.io/blog/available-now-qt-for-small-businesses)

Here:
https://ftp1.nluug.nl/languages/qt/official_releases/qt/6.3/6.3.0/OFFLINE_README.txt (https://ftp1.nluug.nl/languages/qt/official_releases/qt/6.3/6.3.0/OFFLINE_README.txt)

TL;DR
Maybe just the framework itself, QT.  Can be downloaded.  But if you want their GUI designers, it seems to get harder to obtain, without an account (but can be done, without, with a degree of difficulty).
I'm NOT especially familiar with QT, so there may be better/easier ways of doing it.

Most free/open source software, can be just used.  This QT thing, has left a bad taste in my mouth.  Why it has to be so difficult, it puts me off from being involved with QT.  Technically speaking it is open source, but in practice, the hoops you have to sometimes jump through for it, can be frustrating.
Title: Re: GUI for Python?
Post by: Karel on June 11, 2022, 09:55:22 pm
Maybe just the framework itself, QT.  Can be downloaded.

Not "maybe", for sure. But you are right about the installers and probably also Qt Designer and Qt creator (the IDE).
But you don't need them. I write software with grafical interfaces using Qt for 10 years and the only thing I need is the
Qt framework (the libraries), a good editor (Kate) and a compiler (GCC).

On Linux, programming with Qt is easy. When I want to release a windows version, I fire up a virtual machine and recompile
it for windows. No installer, no IDE. I simply download the Qt source and compile the libraries with MinGW-64.
Then I compile my program static. That way I don't need to install a gazillion of dll's when deploying my program
and I don't risk any version conflicts. The result is an executable with everything needed inside it.
Title: Re: GUI for Python?
Post by: bd139 on June 11, 2022, 09:55:57 pm
Qt is why Electron is so popular…
Title: Re: GUI for Python?
Post by: MK14 on June 11, 2022, 10:02:33 pm
Maybe just the framework itself, QT.  Can be downloaded.

Not "maybe", for sure. But you are right about the installers and probably also Qt Designer and Qt creator (the IDE).
But you don't need them. I write software with grafical interfaces using Qt for 10 years and the only thing I need is the
Qt framework (the libraries), a good editor (Kate) and a compiler (GCC).

On Linux, programming with Qt is easy. When I want to release a windows version, I fire up a virtual machine and recompile
it for windows. No installer, no IDE. I simply download the Qt source and compile the libraries with MinGW-64.
Then I compile my program static. That way I don't need to install a gazillion of dll's when deploying my program
and I don't risk any version conflicts. The result is an executable with everything needed inside it.

That makes sense.  Maybe using the framework that way, is also more programming language agnostic (yes it would need to change, but not by that much), but you are NOT committed to the actual programming language.

Many people say, staying with text based solutions (which is exactly what you just said), is the best way, anyway.
Title: Re: GUI for Python?
Post by: Karel on June 12, 2022, 06:17:54 am
Many people say, staying with text based solutions (which is exactly what you just said), is the best way, anyway.

When I started to program with Qt, I used Qt Designer, but I didn't like the generated code.
For sure it's easier for starters but as with everything, the risk is that you never learn Qt well enough.

By te way, the documentation of Qt is the best:

https://doc.qt.io/qt-5/reference-overview.html

When I'm programming, I usually have this page open so that I can easily jump to any class/widget:

https://doc.qt.io/qt-5/classes.html

And no, I haven't touched Qt6 yet, I stay with Qt5 untill Qt6 is complete and ready for production and when it's
the default Qt version Linux.
Title: Re: GUI for Python?
Post by: Karel on June 12, 2022, 06:29:32 am
Qt is why Electron is so popular…

You are kidding, aren't you?

Which software uses electron:

https://en.wikipedia.org/wiki/List_of_software_using_Electron

Now let's have a look at Qt:

https://en.wikipedia.org/wiki/Category:Software_that_uses_Qt

https://en.wikipedia.org/wiki/Category:Proprietary_software_that_uses_Qt

Also, electron is slower and uses more memory than Qt but I guess that's not a problem for hobbyists.
Title: Re: GUI for Python?
Post by: bd139 on June 12, 2022, 06:53:48 am
The market is larger than that. There are an order of magnitude more applications behind closed doors. And they’re pushing towards web and electron over native GUI. One thing I have heard is that Qt is complicated to license and expensive to build. Plus there aren’t enough people who can actually do it out there.

I’m no fan of electron myself but it’s s viable tech for a good chunk of cases where Qt sat.

The largest thing I’ve seen recently was a fintech numerical analysis tool built in Electron and React. The processing was done with an external process which was C++.
Title: Re: GUI for Python?
Post by: Karel on June 12, 2022, 08:20:18 am
The market is larger than that. There are an order of magnitude more applications behind closed doors. And they’re pushing towards web and electron over native GUI. One thing I have heard is that Qt is complicated to license and expensive to build. Plus there aren’t enough people who can actually do it out there.

I’m no fan of electron myself but it’s s viable tech for a good chunk of cases where Qt sat.

The largest thing I’ve seen recently was a fintech numerical analysis tool built in Electron and React. The processing was done with an external process which was C++.

That's your opinion only, you don't provide any info.
By the way, electron is slower and consumes more memory than Qt.
Title: Re: GUI for Python?
Post by: Nominal Animal on June 12, 2022, 10:37:20 am
However, there is one or two Qt packages that are not licensed under FOSS licenses, and not available in standard Linux distributions.  The main one is Qt for MCUs (https://doc.qt.io/QtForMCUs-2.1/qtul-licensing.html), which is only available under a commercial or an evaluation license.

This thread is about a GUI for Python. So, I was clearly speaking about the Qt GUI framework which is FOSS.
I was agreeing with you, not arguing with you.

It is important to be precise about licensing, as there is too much FUD flying around Qt licensing.  Describing the Qt package (unrelated to this thread) that is not FOSS, shows the whole picture.  As in "the border lies there, and it is miles away; thus, the claim is quite correct."
Title: Re: GUI for Python?
Post by: MK14 on June 12, 2022, 10:40:21 am
Many people say, staying with text based solutions (which is exactly what you just said), is the best way, anyway.

When I started to program with Qt, I used Qt Designer, but I didn't like the generated code.
For sure it's easier for starters but as with everything, the risk is that you never learn Qt well enough.

By te way, the documentation of Qt is the best:

https://doc.qt.io/qt-5/reference-overview.html

When I'm programming, I usually have this page open so that I can easily jump to any class/widget:

https://doc.qt.io/qt-5/classes.html

And no, I haven't touched Qt6 yet, I stay with Qt5 untill Qt6 is complete and ready for production and when it's
the default Qt version Linux.

Thanks, that's interesting and good to know.  Apparently, there is a similar situation (of sorts) between GTK3(+) and GTK4.  GTK4 is the latest one, but many things are still GTK3(+).

I also find it annoying with systems (but still might use them), which automatically write some of the code for you.  On the one hand it makes it fast and easy, but it can adversely affect the source code.

So, it is preferable, to be in charge of the source code, and not have some automatic system, make changes to bits of it.

Excellent point about the QT's documentation.  Many, GUIs, are rather powerful and useful.  But are significantly deficient on the documentation side, which can be a real pain in the neck.  Especially when starting out with a new (to the programmer/developer), GUI system, or coming back to it, after a long period of doing other things.
But also, exactly as you said.  While developing with a particular GUI, the quality of the documentation, can easily affect your workflow speed and aggravation factor.

TL;DR
It is sad.  But GUIs which lack quality/useful/extensive documentation, are (possibly, opinions might vary) best avoided.  Certainly the ones which have almost zero documentation and/or what there is, is of rather poor quality, are best avoided.  Even GTK, (or so I've heard), suffers from that, because of issues, related to automatically generating the documentation, from the source code.  Brought about, especially because of the numerous multiple, language bindings, for GTK (I've read about this, rather than had it as first hand experience).
Title: Re: GUI for Python?
Post by: Nominal Animal on June 12, 2022, 11:12:22 am
When I started to program with Qt, I used Qt Designer, but I didn't like the generated code.
I don't like using code generators at all.

I recommend against using uic to generate the code for the UI, and instead save the designed UI as an .ui file, instantiating it at runtime via PySide2.QtUiTools.QUiLoader (PySide2) or PyQt5.uic.loadUi (PyQt5).

For those interested in this, see e.g this example (https://www.eevblog.com/forum/programming/pythonic-solution-for-accessing-class-properties/msg3333028/?topicseen#msg3333028) I posted in another thread a couple of years back.

Apparently, there is a similar situation (of sorts) between GTK3(+) and GTK4.  GTK4 is the latest one, but many things are still GTK3(+).
Definitely.  There are those who do (use Qt 6 and/or Gtk+4), but since Qt 5 and Gtk+3 work very well for now, there really isn't any reason to "upgrade" yet.

I also find it annoying with systems (but still might use them), which automatically write some of the code for you.  On the one hand it makes it fast and easy, but it can adversely affect the source code.
I don't like those either.  I just wanted to point out that although Qt Designer supports that, it does not require one to generate the source code for the UI.  Both Glade (Gtk+) and Qt Designer (Qt) support XML-based user interface descriptions as .ui files, that can be instantiated at run time.

The syntax is sufficiently simple that one can actually write those .ui files from scratch, too; it isn't much different to writing HTML by hand.  More repetitive and verbose, perhaps, especially the <property ...>...</property> stuff needed to set widget properties.

Many, GUIs, are rather powerful and useful.  But are significantly deficient on the documentation side, which can be a real pain in the neck.
Very true.  For Qt, I use the same doc.qt.io/qt-5/classes.html (https://doc.qt.io/qt-5/classes.html) as Karel mentioned.  For Gtk+, I'm still using developer-old.gnome.org/gtk3/stable/ (https://developer-old.gnome.org/gtk3/stable/) and not the new developer.gnome.org/gtk3/stable/ (https://developer.gnome.org/gtk3/stable/) site, as I find the old pages faster to navigate; fewer clicks to find whatever I'm looking at.

(I always keep a terminal window open for man -s 2,3 function or pydoc3 module.class, or a browser tab open at man7.org/linux/man-pages/ (https://man7.org/linux/man-pages/) or docs.python.org/3/library/ (https://docs.python.org/3/library/index.html), too.  There is no reason to memorise function signatures and other insignificant details, when you can check in a couple of seconds, and avoid bugs like memset(pointer, length, value) – it's memset(pointer, value, length) –; these kinds of typos are too common already.)
Title: Re: GUI for Python?
Post by: Karel on June 12, 2022, 12:53:50 pm
However, there is one or two Qt packages that are not licensed under FOSS licenses, and not available in standard Linux distributions.  The main one is Qt for MCUs (https://doc.qt.io/QtForMCUs-2.1/qtul-licensing.html), which is only available under a commercial or an evaluation license.

This thread is about a GUI for Python. So, I was clearly speaking about the Qt GUI framework which is FOSS.
I was agreeing with you, not arguing with you.

It is important to be precise about licensing, as there is too much FUD flying around Qt licensing.  Describing the Qt package (unrelated to this thread) that is not FOSS, shows the whole picture.  As in "the border lies there, and it is miles away; thus, the claim is quite correct."

No offence. I like your contributions here.
Title: Re: GUI for Python?
Post by: spostma on June 12, 2022, 07:33:38 pm
anybody interested in FreePascal and Lazarus should visit the Ultibo website.
Ultibo compiles for (and can run on a) Raspberry Pi, and gives you a full Lazarus IDE with debugging.
The compiled output can go on an SD card, and you are ready to run!

This is a monolithic system, so all the OS-specific and all rPi-specific functions are written in Lazarus.

You can use most USB devices out-of-the-box, and use wired or wireless ethernet.
Also CAN drivers are available, and support for many popular peripheral chips.

A great project for people loving the beauty of Pascal!

Just take a look at this CAN dashboard with 2x HDMI output for a TVR sports car:
https://ultibo.org/forum/viewtopic.php?f=9&t=1450
Title: Re: GUI for Python?
Post by: eugene on June 12, 2022, 10:26:40 pm
For Tkinter there is this standalone WYSIWYG editor called PAGE (https://sourceforge.net/projects/page/files/) (should work to generate Tcl/Tk, too), but I've tried it only for Python, and it worked.  A little too basic, from sourceforge, seems straight from the 90s and not very intuitive for these days, but it kind of works.  :)

To be fair, in your opening post you asked for something that works like VB5, which was released in 1991.  ;D

Anyway, I gave PAGE a try and found that it suits my needs well. Like RoGeorge, I sometimes wish for something as simple and easy as early VB. You could put together a good looking interface in just a few minutes, then flesh out the event handlers. Not suitable for sophisticated programs, but often I just want to interface with some instrument or microcontroller, maybe plot a graph, and save some data to a file. VB5 was great for that.

I use Python for similar things today, but writing code to define tkinter widgets and use pack... it's simple, but not RAD enough. PAGE makes it RAD enough for me.
Title: Re: GUI for Python?
Post by: RoGeorge on June 13, 2022, 07:38:58 am
About PAGE, on my desktop the Ctrl+Z does strange things, not really undo-ing, sometimes the graphic WYSIWYG is not synchronized with the tree view of the same elements, selecting more than one element (middle mouse) is not very intuitive (click and drag around elements doesn't select all the enclosed elements, things like Shift or Ctrl alterators behaves unexpected when used for selection, etc.), doesn't do multi-edit of the same property, things like that.

I'm not sure if those are bugs, or if it's the expected behavior, but certainly PAGE is not as intuitive as VB5 was.  PAGE works, but not very smooth, even if it were to judge it by the 90's standards.
Title: Re: GUI for Python?
Post by: Ed.Kloonk on June 13, 2022, 07:48:37 am

I'm not sure if those are bugs, or if it's the expected behavior, but certainly PAGE is not as intuitive as VB5 was.  PAGE works, but not very smooth, even if it were to judge it by the 90's standards.

Do you mean in the app design/widget placement stage or running the generated code?
Title: Re: GUI for Python?
Post by: RoGeorge on June 13, 2022, 08:14:08 am
Talking about the WYSIWYG editor, the quirks while you edit how your Python GUI will look like.  PAGE has a Drag&Drop editor, and when you are happy with your future GUI look, it can generate Python code to be edited later for adding functionality to the designed GUI.

Also it was not possible to move an element in the tree, for example to just drag a button from outside to inside of a labelframe.  Such a change can still be done by copy/paste then deleting the original, but only with one element at a time.  So if you want to add later a labelframe around a group of GUI objects you have to copy/paste them one by one inside the new labelframe.

Also the alignment appears missaligned sometimes, even when the snap to grid is enabled, things like that  :-//
Title: Re: GUI for Python?
Post by: bd139 on June 13, 2022, 08:23:52 am
Ugh I'd rather use WPF than deal with that sort of stuff  :-DD
Title: Re: GUI for Python?
Post by: Karel on June 13, 2022, 09:06:02 am
Ncurses!  8)
Title: Re: GUI for Python?
Post by: Ed.Kloonk on June 13, 2022, 11:31:58 am
+1
Title: Re: GUI for Python?
Post by: eugene on June 13, 2022, 02:35:56 pm
About PAGE, on my desktop the Ctrl+Z does strange things, not really undo-ing, sometimes the graphic WYSIWYG is not synchronized with the tree view of the same elements, selecting more than one element (middle mouse) is not very intuitive (click and drag around elements doesn't select all the enclosed elements, things like Shift or Ctrl alterators behaves unexpected when used for selection, etc.), doesn't do multi-edit of the same property, things like that.

I'm not sure if those are bugs, or if it's the expected behavior, but certainly PAGE is not as intuitive as VB5 was.  PAGE works, but not very smooth, even if it were to judge it by the 90's standards.

Ah, okay. I didn't run into those things, but likely because I didn't try to do the things you did. I ran through the first tutorial without incident, then put together an interface for a simple file sync program using almost the same process.

You're right, behavior like that is hard to tolerate. I'll still be on the lookout for something better, but may continue to use PAGE to build interfaces initially. That's the usual workflow anyway, isn't it? Design/create a GUI then fill in the functionality. With VB5 (and VB.NET and C# in VisualStudio) you can make changes to the interface as you discover the need. With PAGE (even without the intolerable quirks) it's not that simple, but I did find it useful for the first step of building the GUI. Maybe if I'd experienced the same frustration that you did then my attitude would be different.
Title: Re: GUI for Python?
Post by: Nominal Animal on June 13, 2022, 03:36:15 pm
It would be interesting to create a simple example Python 3 program using the various toolkits (Tkinter, Qt, Gtk+ at least), comparing the implementations and especially the maintainability, written with long-term maintainability and customisation in mind.  That would be very informative, I think, for everyone interested in the subject.

I personally am most interested in the ways an external (XML-based text) file is used to define the user interface, as opposed to implementing it in code.  For tkinter, one can use pygubu (https://pypi.org/project/pygubu/) and pygubu-designer (https://pypi.org/project/pygubu-designer/); Glade for Gtk+, and Qt Designer for Qt.

Serial port access and serial device enumeration is a "problem", because the various existing libraries used for this are, uh, "deficient".  So, it'd have to be something more local.  Python does have built-in support for CSV files, JSON data, various configuration file formats (including .INI-type files), network sockets and TLS encryption, and even WAV (https://docs.python.org/3/library/wave.html) files.  Numpy and Scipy have all kinds of FFT and such support, so maybe something to do with those would be useful?  I've already done a simple Finite Impulse Filter response analysis (https://www.nominal-animal.net/answers/fir-analysis.html) tool as an example of completely standalone single-file HTML+CSS+JavaScript browser tool.

It'd have to be something actually useful, as to properly "stress" the toolkits/frameworks, and see what working with the codebase and resource files is like.  I just cannot think of a suitable example.  Even better if someone designs a suitable UI in pygubu-designer/Glade/Qt Designer, or even just e.g. Inkscape as a picture, to start with.
Title: Re: GUI for Python?
Post by: Bud on June 13, 2022, 04:13:54 pm
Given Python's shitty backwards compatibilty, this may be a useless exersize. This may work for a specific version but become broken once a new version is out.
Title: Re: GUI for Python?
Post by: Nominal Animal on June 13, 2022, 04:23:05 pm
Given Python's shitty backwards compatibilty, this may be a useless exersize. This may work for a specific version but become broken once a new version is out.
Aside from Python 2 to 3, which was annoying as all hell but carefully controlled and not a surprise to anyone, I haven't been bitten by that at all.  Exactly what are you referring to?

And do note, I am not particularly fond of Python.  I use it only because it currently fits my use case – portable interpreted language suitable for user interface implementation, with an easy interface to native libraries – better than the alternatives.  It is just a tool for me, and I use it as such.  Thing is, I want others to have multiple tools in their kit, and choose the one they use based on the problem/task at hand; and Python only where it is appropriate.  Thus, an actual real life example is much more useful than this kind of discussion, in my opinion.
Title: Re: GUI for Python?
Post by: Bud on June 13, 2022, 04:36:28 pm
Carefully controlled?

"Python version incompatibilty is intentional" - When such statements come out right from the horse's mouth (Guido van Rossum, the creator of Python), that makes you think.
Title: Re: GUI for Python?
Post by: bd139 on June 13, 2022, 05:58:49 pm
I’ve had about 15 million lines of it in production before. Not one issue. Even the python 2 to 3 port was smooth.
Title: Re: GUI for Python?
Post by: Nominal Animal on June 13, 2022, 06:01:39 pm
Carefully controlled?

"Python version incompatibilty is intentional" - When such statements come out right from the horse's mouth (Guido van Rossum, the creator of Python), that makes you think.
It applied to the 2-to-3 thing.  I'd rather have a rewrite/redesign/refactoring, than live with a sub-par design.  Now that they know how painful it is, how likely do you think it is they repeat it?

Even Perl 7 (https://www.perl.com/article/announcing-perl-7/) intends to fix defaults that are no longer applicable, somewhat "breaking" backwards compatibility.  Although I do realize first-hand how painful all backward compatibility breaking changes are, I still think they are good/important/preferable in the long term.

Programming languages are just tools, after all.

In any case, if someone comes up with a good idea for a basic but useful GUI example program, especially if they bother to design/sketch out the UI, I do promise to try to write at least Qt (PySide2 + PyQt5) and Gtk+ (gi) implementations (on Linux, as I cannot currently test on Windows), perhaps also a tkinter/pygubu one.  (The "try" is there, because I'm still struggling with productivity/responsibility/stress management failures, and cannot promise I don't stumble on those personal pitfalls I tend to stumble on. :()
Title: Re: GUI for Python?
Post by: Bud on June 13, 2022, 06:25:53 pm
I’ve had about 15 million lines of it in production before. Not one issue. Even the python 2 to 3 port was smooth.
Good for you. Total opposite experience here.
Title: Re: GUI for Python?
Post by: Karel on June 13, 2022, 07:16:11 pm
When you report a problem on a forum related to one of the bigger python projects,
the first thing they ask you is which version exactly of python you are using.
Then they tell you to try version 3.xyz instead of version 3.xzy...
Title: Re: GUI for Python?
Post by: Nominal Animal on June 13, 2022, 09:20:13 pm
Then they tell you to try version 3.xyz instead of version 3.xzy...
I've done that in C projects also, for the simple reason that if there has been a lot of churn in that part of the code base between the two versions, having information in which version the behavioural change occurred, tells a lot about what code might cause it.  Hell, this is exactly why git bisect exists: it is how bugs and behavioural changes in the Linux kernel are pinpointed (https://www.kernel.org/doc/html/latest/admin-guide/bug-bisect.html).

In other words, it is an useful buggy code locating technique.  Please, do not think it is a way to just divert you to a new version!  I have never done that with the intention of having the end user switch to a newer version, only as a tool to pinpoint the source code involved!  I know what kind of hell version dependencies can be, firsthand.

Only when they refuse to fix the issue because it does not occur in a later version, does it actually become assholey behaviour.

Also, even if Python developers were to refuse to fix the issue (for example, for 3.8.x because the bug is not a security issue), Linux distribution maintainers often will, applying bug-fixing patches at the distribution level.  In general across many projects, sane upstream developers then relent, and release a bugfix anyway.

Why Python 3.8.x as an example?  It is listed as "security fix maintenance only", but 3.8.x is currently shipped in e.g Mint 20.3 (Long Term Support) and other Debian/Ubuntu derivatives.  I personally am currently using 3.8.10 myself, even though 3.10.y is the Stable and 3.11.z the Development version right now (2022-06-13).
Title: Re: GUI for Python?
Post by: nctnico on June 13, 2022, 09:37:37 pm
It'd have to be something actually useful, as to properly "stress" the toolkits/frameworks, and see what working with the codebase and resource files is like.  I just cannot think of a suitable example.  Even better if someone designs a suitable UI in pygubu-designer/Glade/Qt Designer, or even just e.g. Inkscape as a picture, to start with.
The latter is a good option. Draw a layout as a mock-up and code it. I've let go of the idea of using GUI design tools a long time ago. You quickly want your controls & screens to scale which is easy to do in code but very hard with controls that just sit there at a fixed position. And creating a bunch of contols using a for loop is quicker too and the spacing & position can be changed much quicker compared to using a GUI design tool and adjusting the position of every button, text, etc.
Title: Re: GUI for Python?
Post by: nfmax on June 13, 2022, 09:43:54 pm
In any case, if someone comes up with a good idea for a basic but useful GUI example program, especially if they bother to design/sketch out the UI, I do promise to try to write at least Qt (PySide2 + PyQt5) and Gtk+ (gi) implementations (on Linux, as I cannot currently test on Windows), perhaps also a tkinter/pygubu one.  (The "try" is there, because I'm still struggling with productivity/responsibility/stress management failures, and cannot promise I don't stumble on those personal pitfalls I tend to stumble on. :()

Oddly enough, I had occasion to make just such a tool a few months back. It's a 'data inspector' for signals from an ultrasound system whose purpose it is inconvenient to go into too deeply here. Suffice it to say, the development engineers were having a hard time using the application software, which does some fancy signal processing and presents measurements derived from this processing, to decide if the system was actually working as designed or not.

So I put something together in Python (since rest of the software is in Python) using PyQt5, numpy, scipy & matplotlib. It shows a tabbed interface that lets you look at a signal in the time domain or as a spectrogram, or a whole set of such signals together as an echogram (i.e. like a medical ultrasound image). With features like optional harmonic cursors in the spectrogram, time/frequency/range cursor readout in lots of different modes, and lots of control over the visualisations to bring out different features (or bugs). It's been highly revealing. Also handy to make pretty pictures to show the investors!

I started using the Qt visual designer, but in the end I kept it only for the menu structure. The rest of the interface I just wrote by hand in Python. It uses the 'springs and struts' approach which I am familiar with from ancient history. This leads to a huge __init__() method for the View object, which is inconvenient to work with. It's also a bit hairy keeping track of the slot/signal connections, since that can only really be done by the Controller. You end up having to modify two separate parts of the code for each change or addition to the UI. It's not the old VB click & code approach. But the View & Controller are both really too large & unwieldy for comfort and should be split up somehow. I didn't really try, but Qt doesn't seem to offer any help with that.

One unexpected nice feature was PyQt's threading support. It made keeping the interface live while loading data from a directory containing some hundreds of CSV files quite easy to accomplish. Complete with progress bar and cancel button!

Now we are gaining confidence in the system, the inspector is seeing less use, but it still scratches a significant itch. No thoughts of reworking it using another GUI toolkit though, and I can't disclose the code :( But perhaps it may inspire someone else
Title: Re: GUI for Python?
Post by: Nominal Animal on June 14, 2022, 06:04:11 am
I've let go of the idea of using GUI design tools a long time ago. You quickly want your controls & screens to scale which is easy to do in code but very hard with controls that just sit there at a fixed position.
For what it is worth, I tend to use GtkGrid or QGridLayout for widget layout, much like HTML tables, which scale automatically.  I basically never use fixed layouts, as I need mine to scale according to my varying needs.

I lived through the "This web site is best viewed in 800x600 resolution" era, and hated every time I encountered that.  I didn't do it myself then, and I don't want to do it now.  I habitually browse web sites with varying (site-specific!) zoom levels, too.  (Right now, for EEVblog forums, on this particular laptop I use 120% with 14pt DejaVu Serif as default font.  For other sites, it varies between 90% and 133%.  It obviously also varies depending on the display I'm using, and the distance I am at from the display.)

creating a bunch of contols using a for loop is quicker too
True.  It really depends on the application, which is my point regarding an example.  A synthetic example won't be useful much; we really need a real-world use case for it to matter.

GtkBuilder does support <template> .ui objects in Gtk+ 3.10 and later, and in both Gtk+ and Qt .ui files you can generate objects (and object hierarchies) and instantiate them multiple times, but I prefer to create Python classes (possibly extending a suitable toolkit widget class) instead.  And I have a habit of describing things in dictionaries (in Python; in arrays of structures in C) and instantiating them in a loop.

Whatever makes the code most maintainable, but does not have any significant downsides (like slowdowns or installation quirks), is the best approach in my opinion.

Oddly enough, I had occasion to make just such a tool a few months back. It's a 'data inspector' for signals from an ultrasound system whose purpose it is inconvenient to go into too deeply here. Suffice it to say, the development engineers were having a hard time using the application software, which does some fancy signal processing and presents measurements derived from this processing, to decide if the system was actually working as designed or not.

So I put something together in Python (since rest of the software is in Python) using PyQt5, numpy, scipy & matplotlib. It shows a tabbed interface that lets you look at a signal in the time domain or as a spectrogram, or a whole set of such signals together as an echogram (i.e. like a medical ultrasound image). With features like optional harmonic cursors in the spectrogram, time/frequency/range cursor readout in lots of different modes, and lots of control over the visualisations to bring out different features (or bugs). It's been highly revealing. Also handy to make pretty pictures to show the investors!
Well, visualising signals and filters in time and frequency domains is an important tool in many sub-fields members here would be interested in.  ;)

It's also a bit hairy keeping track of the slot/signal connections
When using Qt Designer .ui files, PyQt5.QtCore.QMetaObject.connectSlotsByName auto-connects on_widgetName_signalName slots to the named signals.  Applying the Principle of Least Surprise, we can do that ourselves with just a couple of lines.

Let's assume we use a custom class, with the widget hierarchy already hanging off the ui member.  (I load this using self.ui = loadUi("filename.ui"), but it does not matter how you construct it, as long as you use widget.setObjectName("widgetName") or equivalent to give each signal-generating widget an unique name.)

Connecting all abovenamed functions in the custom class to proper signals requires just a few lines of code, after the self.ui widget hierarchy has been created (but not shown yet):
        for slot in dir(self):
            if callable(slot) and slot.startswith("on_") and slot.find("_", 3) > 3:
                widgetName, signalName = slot[3:].split("_", 1)
                signal = getattr(self.ui.findChild(QtCore.QObject, widgetName), signalName, None)
                if signal:
                    signal.connect(getattr(self, slot))

Alternatively, you can use an array of ("widgetName", "signalName", pythonCallable) tuples, and in a loop over them,
        sourceSignal = getattr(self.ui.findChild(QtCore.QObject, widgetName), signalName, None)
        if sourceSignal is not None:
            sourceSignal.connect(pythonCallable)
To include signal-to-widget-slot tuples of form ("sourceWidgetName", "sourceSignalName", "targetWidgetName", "targetSlotName"), do
        sourceSignal = getattr(self.ui.findChild(QtCore.QObject, sourceWidgetName), sourceSignalName, None)
        targetSlot = getattr(self.ui.findChild(QtCore.QObject, targetWidgetName), targetSlotName, None)
        if sourceSignal is not None and targetSlot is not None:
            sourceSignal.connect(targetSlot)
instead.

I find these "tricks" make the signal-slot stuff much more maintainable.