Back

Python GUIs for Humans – Transforms UI into People-Friendly Pythonic Interfaces

275 points3 yearsgithub.com
frederikvs3 years ago

For those looking to build a simple GUI, another option is Gooey [0]. It takes your arparse declarations and builds a simple GUI based on that.

Gooey is probably easier to set up, but PySimpleGUI looks like it's more flexible and powerful. Look at your own battle and choose your weapons accordingly :-)

[0] https://github.com/chriskiehl/Gooey

leoncvlt3 years ago

Came here to mention this, Gooey is very useful to make simple command-line scripts "non-tech-friendly" by giving it a familiar GUI rather than a scary black terminal window :)

arpafaucon3 years ago

Kudos to the writer! I used this framework for an small robotics project and, as others pointed out, I was up and running in less than an hour. However, as the project grew more complex, I reached a point where I felt the framework was in the way: I wanted complex things, and lacked the means to configure the framework that precisely. I would recommend others to keep the framework for what it does so incredibly well : small / prototypes projects ; but do not hesitate to switch to a more powerful backend once you feel your needs are complexifying.

KeplerBoy3 years ago

What solution did you end up switching to?

I have a feeling that most python GUIs are lacking in some area and for full creative freedom someone would have to go for flask or fastapi, build the UI with modern js-frontend frameworks and connect that frontend with the actual application using websockets or regular HTTP-Requests.

simonh3 years ago

I’ve had great success using PyQt for quite sophisticated GUIs. Any of the native bindings should give good results too. I doubt JS would give you more flexibility and performance than these.

barnabee3 years ago

I have found DearPyGui [1] to be a really efficient way to knock up a quick GUI for a Python script/app. There's almost no boilerplate and I've found it scales reasonably well as things get more complex as it's easy to split views/"components" into modules and classes.

[1] https://github.com/hoffstadt/DearPyGui

scarygliders3 years ago

I've been very happy with using Qt and PySide and now PySide2.

Without it I couldn't have produced Captain's Log, for example : https://captainslog.scarygliders.net/captains-log-2/

BrandoElFollito3 years ago

This is exactly what happened with my home dashboard.

The initial version, 5 or so years ago (maybe a bit more, I do not remember) was based on a python library (sorry, I forgot the name but it was the major one at the time). It worked fine for a bit but moving to a kiosk browser and vue.js completely changed the game.

The backend was Python, then got replaced by a bus (mqtt) updated via golang microservices (they were in python initially, but then I wanted to learn go)

arpafaucon3 years ago

For most applications in my company, we prefer fastapi + Jinja to generate HTML pages, and rely on the browser to display that for us. For the few programs that need to be run locally & without browser, we use PySide2 (Qt bindings): the framework is bulkier, but somehow feels more reliable.

hexadec3 years ago

This is an incredible project I had never even heard of before. This is what github/lab projects should be in my opinion. An incredible solution, well documented, with exceptional examples. I got the intent and was up and running in less than an hour. Great functionality as well in terms of simplifying layout and portability.

412093 years ago

Very very neat.

I might use this the next time I need to build out a small personal project. I've taken a rather strong liking to Python recently. So much is built into the standard library compared to NodeJS. Very useful for quick projects/ AWS lambdas where installing dependencies is a pain.

Do you have a good guide on wrapping this in a binary ?

Wouldn't be able to use it in a corporate environment though, the licensing isn't great for that.

analog313 years ago

I like the concept a lot, having written my own "wrapper" for Tkinter and wishing I could adapt it to Remi. My only thought is that defining the contents of a layout as a dict instead of a list, would allow the elements to be referenced by a name rather than number. That would make it easier to read and modify one's own code.

maicro3 years ago

From Example 2 (https://github.com/PySimpleGUI/PySimpleGUI#example-2---inter... ) it looks like you can assign names to layout elements with "key".

H8crilA3 years ago

Dict() is unordered.

rmellow3 years ago

As of Python 3.6, Dictionaries are ordered.

smarnach3 years ago

It's actually as of Python (the language) 3.7. The CPython implementation of Python 3.6 already has ordered dicts as an implementation detail, but it's not part of the language in that version.

H8crilA3 years ago

Uh, nice, didn't know. That will fix a lot of bad (nondeterministic) code out there :)

semireg3 years ago

Does this kind of app distribute easily? As in, can I package up the runtime and the app into a single exe? I see this, but does someone have experience to share?

Edit: Found it!

https://github.com/PySimpleGUI/PySimpleGUI/blob/master/docs/...

dagw3 years ago

Another option to look into is Nuitka. I haven't tested it with PySimpleGUI, but I've used it to package wxPython apps for windows in the past and it worked really well.

moondev3 years ago

I suppose if targeting the web backend you could package into a docker container. I wonder if golang embed could be an option for packing python for native ui

wraptile3 years ago

I used PySimpleGUI in a devops app that used the new tables widget (only on tkinter) to track/resolve/debug issues (i.e. domain specific sentry). It worked really well! The whole codebase was 300 loc: pull issues from api, put them into table rows, filter rows by combobox filters and handle button presses.

Unfortunately as the app grew the main loop became really hard to follow and I've started to miss callbacks or some sort of oop wrapper around the whole thing. I also noticed that any other backend than TKinter was more like a 3rd class citizen rather than an alternative. Other than that it's probably the best GUI programming entrypoint in Python!

phil2943 years ago

Does anyone know how this compares to guietta? [1] Both look quite similar, and I have already successfully used the latter in two small projects. It was so easy to set up, I had not even have to read much of the documentation at all.

Edit: I have found the answer in the docs [2]

[1] https://github.com/alfiopuglisi/guietta/ [2] https://guietta.readthedocs.io/en/latest/intro.html#aren-t-y...

s_gourichon3 years ago

Used Guietta for a small project. Looked simpler to code and to "package". Nice you mention it.

jimnotgym3 years ago

I can't help but love projects like this. I used to write simple apps that took a simple input and did a thing... and it seems so unintuitive compared to VisualBasic, for instance, even allowing for defining windows programmatically.

Raineer3 years ago

Just finished up a Python class as part of my EE this summer. I had no idea this wasn't the default way everyone did Python GUIs. This was the main library we used throughout - it was very approachable and easy to configure.

mtoohig3 years ago

I've also found this project to be very good. I used it for a personal project to help me manually tag images and prepare a payload to upload to a remote server's database.

Some of their naming conventions though are odd IMO but otherwise I thought it was an easier way to process images than a webapp which is my usual working area. Now that I think of it though, a juniper notebook may have also been a solution but I wanted to dabble with writing a GUI.

KingMachiavelli3 years ago

Is there something like this but creates a simple web app?

dagw3 years ago

Anvil (https://anvil.works/) is probably the closest thing to what you are looking for, at least in the python world.

nyellin3 years ago
johnne86sd3 years ago
analog313 years ago

To make it run entirely in the user's browser, you need to have the Python interpreter and any additional libraries running on the user's machine. This is the case with Javascript but not Python.

GeorgeTirebiter3 years ago
Uberphallus3 years ago

This actually has a web backend.

GeorgeTirebiter3 years ago

I wrote a pretty fancy GUI for a real-time system (was handled by MPUs externally, so no real-time in GUI). I found it to be fairly easy to use; there are plenty of examples, and often you can mix-and-match from the examples to get what you want.

It's also true that as you want fancier interactions, you have to be clever to get the framework to do what you want. It's very good --- best easy-to-use Python GUI I'd say --- but it won't handle every fancy GUI requirement. (That's why you have PyQt etc)

mwexler3 years ago

Props for the best readme I've seen on GH in a long, long time.

cafard3 years ago

Interesting. PythonCard used to be a very handy tool, built on top of wxPython, but it was abandoned some years ago.

mdtrooper3 years ago

One question. Which is the best python library for TUI?

I used to use http://urwid.org/ but It needs a lot of code to do the stuffs.

I look for a library that is packaged in Debian (if something is in Debian, it is standard and has long life).

brian_herman3 years ago

I've used pysimplegui at work it is a great framework to get up and working for a simple gui. It took me 30 minutes to code the gui and I sent it to our underwriting department to help them deal with a bug we were having with our system.

pryelluw3 years ago

I’ve used this to build stuff of various complexity and it works well. The docs are good.

thecal3 years ago

I've used this library twice, it is fantastic when you need a simple GUI on top of a Python script. Congrats for being on the front page of HN!

Barrin923 years ago

I really like the "interface layout as a list of lists" idea. It's kind of like a LISP 'code is data' paradigm but for guis

naomeux3 years ago

The code looks readable. This needs to be exposed, it's quite easy, and it seems interactive.

amelius3 years ago

The example code almost looks like HTML ...