Sorry for the somewhat noob question, but how do you pick a library for making a GUI for your apps? My background is in physics, so most of my programming is perfectly find with a CLI that outputs a graph as a ps file or some csv. I am looking to learn about making some neat little GUIs. I was thinking it would be a good idea to try and build my GUI out of the browser so that my app can be as portable as possible, but does this mean it has to be in Javascript or can the backend be done in anything else?

I am not really sure what I am asking, but wanted to get a feel for how people approach front ends.

Thanks :)

18 points
*

If you do want to go the web route, I’d highly recommend avoiding SPAs and going with https://htmx.org/ instead. Much simpler, less code, entirely driven by your backend, while still giving you the ability to make nice interactive applications.

As a bonus, since you presumably have been working with Python anyway, the author of htmx has a whole book online walking you through building an app using htmx and Flask, a web framework for Python: https://hypermedia.systems/book/contents/

permalink
report
reply
1 point

Whoa I’ve heard of tkinter but I’ll look into htmx too!

permalink
report
parent
reply
13 points

Time, experience and a lot of mistakes. Everyone who has been programming/scripting has made their fair share of mistakes along their journey.

Sometimes you just have to pick one, start it and see how it goes.

permalink
report
reply
11 points
*

be as portable as possible

This is important to me, which narrows down my options quite a bit.

Electron is portable across desktop OS, but unacceptably bloated (I don’t want my users to have to deal with that) and buggy (I don’t want to deal with that).

wxWidgets and various similar wrapper libraries exist, but on Linux most of them wrap Gtk, which in recent years has become very opinionated in UI directions that I find intolerable.

A few new cross-platform GUI toolkits have been appearing recently, but I’ve found all of them suffer from poor text handling, anemic widget sets, or very out-of-place look and feel (especially keyboard navigation) relative to native applications.

That leaves Qt as my only reasonable choice, at least for now. This is mostly okay, as it does a wonderful job all around. My main complaint is that using the full power of its widgets and libraries means I’m restricted to a handful of languages: C++, Python, and maybe one or two minor ones like D. Its declarative API (Qt Quick) seems to be getting more language bindings, though, so simpler apps might be possible in other languages.

Note that the landscape is different for mobile apps. I don’t have a recommendation for those.

permalink
report
reply
2 points

What about Tauri? I don’t know what exactly your app is but since you mentioned Electron as an option I guess Tauri could run it. Offers more choice for frontend frameworks hence less „language lock-in“ than Qt.

permalink
report
parent
reply
1 point
*

I mentioned Electron only to acknowledge a well-known cross-platform toolkit, not as an example of acceptable results.

Tauri on Linux is effectively a Gtk wrapper (plus WebKit), which makes it unappealing to me. I keep it bookmarked anyway just in case I find myself in a situation where the only other option is Electron, since I suspect Tauri would at least be lighter on system resources.

permalink
report
parent
reply
1 point

What about tcl/tk?

permalink
report
parent
reply
1 point
*

I don’t enjoy writing in Tcl. If I were to use Tk today, it would probably be through Python’s tkinter package.

IMHO, Tk interfaces look awful by default, but they can be made to look pretty decent if you’re willing to hunt for (or create) a good theme. I have considered it a couple of times for trivial tool UIs, and I occasionally use one that someone else wrote.

That said, getting it to look native on multiple platforms would take more effort than I feel is worthwhile, and getting it to feel native (keyboard nav, etc.) even more so. Qt has this stuff built in, and a lot more.

permalink
report
parent
reply
8 points

I’m a web dev with a wife who is a researcher, and on the side I’ve built a few tools for her work. Web apps are great because cross-platform distribution and compatibility are non-issues. If you don’t need a database or server-side logic, a client-side only application is basically free to host given that it’s ultimately just a pile of static files. You can use localstorage for persistence, and because there’s no server logic you have a lot fewer security implications to worry about.

JavaScript gets a bad rap, but if you pair it with typescript and decent tooling it’s really not bad. HTML and CSS are an incredibly powerful engine for building UI, which is only getting better.

permalink
report
reply
7 points
*

I (probably unreasonably) despise using web front-ends for desktop applications.

GTK is OK. QT is very feature rich, but that adds complexity. Both can be cross-compiled to most systems and shipped with all the required libraries pretty easily.

I haven’t used it in a long while, but I remember liking Java Swing for some reason. Java should be “write once, run anywhere.” But, cross-compiling isn’t usually too hard, so not sure how much that matters. There’s more modern frameworks for JVM-based languages now, but I haven’t tried them.

I’ve noticed Gradio is popular in the ML community (web-tech based, and mostly used for quick demos/prototypes).

Edit: For web applications, I prefer Angular’s more traditional architecture over React’s hook architecture.

permalink
report
reply

Programming

!programming@programming.dev

Create post

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person’s post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you’re posting long videos try to add in some form of tldr for those who don’t want to watch videos

Wormhole

Follow the wormhole through a path of communities !webdev@programming.dev



Community stats

  • 3.2K

    Monthly active users

  • 1.8K

    Posts

  • 30K

    Comments