Advice on the Choice of a GUI Library?

gronjo45@lemm.ee to Programming@programming.dev – 25 points –

Hi Everyone,

I've gotten a lot of older books on mathematics, physics, chemistry, and dabbled a lot in computational simulation with programs like LAMMPS and GROMACS. I am interested in learning how to make a GUI application that I can use to automate graphing functions, understanding how sensitive a model may be to perturbations in particular parameters, and different ways of visualizing data to help me get an "intuition" on subjects. Numpy, SciPy, Pandas, Matplotlib.pyplot, numba, glob, and os, are libraries I like to use. See Gibbs'/Maxwell's original envisionment of thermodynamic surfaces from the late 1800s.

However, I am a moron with respect to software development. My interests are in the FOSS-sphere of things, but I have never made a piece of software other than botched code to calculate averages, perform PCA, and typical statistics visualizations with distributions, Monte Carlo simulations, and see how this effects the properties of the underlying system of study. I've also glanced at design patterns, know the different paradigms of computing to a basic level, and am willing to suffer for long-term educational gains.

The language I'm most comfortable coding in is Python, but I found it discouraging to start writing a software project, as I assume writing something entirely in Python isn't the best way to ship quality software.

Julia and Matlab are other languages I've written programs in. I've tortured myself with the whole gamut of toolchains/editors like Neovim (and my inability to get my lua.init file to ever work properly), and prefer to use FOSS tools. I can navigate in a clunky sense around a terminal, but whenever I try to configure my .bashrc or modify the behavior of my editor, it results in me chasing down a particular filepath for an hour just to change the color of the text, or rearrange how the text is displayed to the terminal so that I actually can read what is saying. Without color-coating, it's hard to distinguish between directories, file extensions, and so forth, and even more frustrating when you can't get the changes to work.

Essentially, I am a confused orangutan given a mallet.

When I ditched Word for LaTeX several years ago, it inspired me to take my FOSS journey one step at a time, rather than what I did a year ago, where I chucked every proprietary tool into the trash.

I need to actually be able to do work, as one would prefer to drive their car, rather than get out every 5 feet to fix another busted part.

I would like to eventually develop software that ends up in the FOSS sphere, and write programs that do not take up 100GB of space, or have 100s of bandaid layers, countless dependencies, and the whole gamut of issues that plague certain software packages.

Libraries that I've looked at are...

  1. Tkinter
  2. PyQt5
  3. Dear PyGui

I don't particularly care about modern esthetics for the interface. All I care is that the program functions, uses a relatively low amount of resources, and can educate me further about how to rip open a widget, modify the code associated with that particular button, and get a greater control of visualizing concepts taught in math/physics books.

Thank you!

12

It's not a GUI library, but Jupyter was pretty much made for the kind of mathematical/scientific exploratory programming you're interested in doing. It's not the right tool for making finished products, but is intended for creating lab notebooks that contain executable code snippets, formatted text, and visual output together. Given your background experience and the libraries you like, it seems like it'd be right up your alley.

For your use case I recommend working with the web - HTML/CSS for basic interface designs and where those fall short SVG or Canvas or WebGL.

There are various frameworks but if you're just starting out I wouldn't touch those with a ten foot pole. You need to learn how these things work first, without adding complicated third party code to your environment.

You can write code that runs on the server, or client side in the browser. Most web software is a mix of both. Literally any language works well server side, but client side most people use JavaScript (you don't have to do that - you can write code in almost any language and compile it to WASM (Web Assembly)... but JavaScript has deep integration with HTML/CSS so it's probably the best choice.

I'd start with w3schools.com for the absolute basics.

Web software doesn't have to run in a browser. You probably use apps every day that use Electron - which is essentially a way to integrate web applications into your operating system (and also, a way to run web apps without an internet connection).

It's really quite simple to get your head around, a web browser sends a text message like this (I've simplified it) to a server::

GET /example/page HTTP/1.1
Host: example.com

And the server responds with another text message, like this:

HTTP/1.1 200 OK
Date: Tue, 20 Feb 2024 12:00:00 GMT
Server: Apache/2.4.1 (Unix)
Last-Modified: Sat, 18 Feb 2024 12:00:00 GMT
Content-Length: 438
Content-Type: text/html; charset=UTF-8
Connection: close

<html>
<head>
  <title>An Example Page</title>
</head>
<body>
  <p>Hello, World!</p>
</body>
</html>

You can generate that response with software, or you can have it sitting as a file on the disk.

As someone who's written GUI software for a couple decades - trust me that simple "text in, text out" approach to writing software is really really good especially when you just want to get something to work and don't want to spend years refining every little detail. I'm a thousand times more productive writing web software than anything else.

Thanks for the code example. I tried going through web3 awhile back with HTML, but need to go through at least 60% more of the course and examples they provided on the website.

I'm a bit confused on what a server is, past "someone else's computer" or "another computer" or "a machine elsewhere that is able to take and receive requests". When you write a "GET" request, is this pulling from another file on your machine locally, but still using the HTML framework and WASM to have "Piece of code 1" talk to "Piece of code 2"? And this all happens locally on the same machine you're using?

Currently I'm using the Kate IDE editor since Neovim made me hurl my lunch. Spyder was what I used for Python, but it can't be used with more than one language unfortunately. I'd assume programs with functions provided by Electron are able to cache what they retrieve... Is the "server" downloaded alongside the application, therefore not requiring WiFi connection to use the application?

Hope my questions aren't too out in left-field and thanks again for your response!

Not to talk down the suggestion, but with your experience in writing software I would not recommend adding JavaScript, HTML, CSS and whatever Llibrary you need for plotting to your tech stack.

Distributing python applications can be a pain (no easy "here's the .exe, just run it"), but it's easy to write, you can use matplotlib, numpy, etc. And the graphics libraries are well established.

I am currently writing an application with PyQT6. It works well. There is a graphical editor to design the layout if you don't want to write everything in code by hand.

Like others said, definitely consider using Jupyter Notebooks for development (note: not necessarily JupyterLab, just Notebooks - multiple IDEs like VSCode support them).

For an actual GUI, I would recommend considering some web dashboard frameworks like Streamlit, Dash or Gradio if you are not felling like spending too much time organizing the layout and making it pretty.

Other than that, I would also recommend taking a look at a few plotting libraries other than matplotlib like Bokeh or Plotly.

I assume writing something entirely in Python isn’t the best way to ship quality software

You seem to have a sharp intuition in this aspect.

am willing to suffer for long-term educational gains

Have you considered learning Rust? There are some nice GUI libraries for it like iced. It also seems to resonate with what else you've written. You can learn by reading this online book: https://doc.rust-lang.org/book/

I've had murmurs of Rust throughout my time here... I'll give it a try and attempt to make a barebones application with buttons.

Once I've either failed catastrophically or have created something to be reviewed, I'll report back.

Thanks!

There is also a rust book that walks through building a todo app with rust and gtk (gnome desktop). Haven’t gone through it yet myself, but might be something you’d be interested in skimming through.

That looks like a helpful guide to go through as well. I'm not too familiar with compiling/building/making (only the general notions)... In the past, I've abandoned programming projects because I got bogged down in the semantics of the documentation.

Should I stick to drawing high-level flowcharts pursuing a "make this" Occam's Razor type philosophy and just condition myself to abandon unnecessary pedantic details? Just trying to make sure I follow through with my programming project this time instead of getting overwhelmed!

I’m not too familiar with compiling/building/making

Don't worry, Rust makes this very simple for you, as you'll quickly learn once you learn about Cargo. You don't even need to think about it.

GUIs are in general quite complicated regardless of language I would say, so it's perhaps not the best place to start if you want to learn iteratively. But I think you can still make simple GUI things quite quickly so perhaps it's not too bad.

Feel free to ask if you run into anything, I love teaching people Rust heheh

There's also !rust@programming.dev where you can ask questions.

Definitely will, I appreciate the support :) I'll hop onto the Rust form after I've read the book with some questions.