11 ms·
Python GUIs
- dist-epoch 3y agoThe best Python GUI, Electron, is missing from this page.
- yboris 3y agoConfirmed! You can run Python with Electron: Use zeroRPC - https://www.zerorpc.io/ https://www.zerorpc.io/ https://medium.com/@abulka/electron-python-4e8c807bfa5e https://medium.com/@abulka/electron-python-4e8c807bfa5e
- taffit 3y agoAnyone has some experience with Kivy [1]? It seems that it checks off some of my requirements, like cross-platform, supporting touch interfaces, ease of development, allows complex/fancy UIs as well, etc. [1] https://kivy.org/ https://kivy.org/
- justinmayer 3y agoA interesting option I haven’t seen mentioned here is Beeware, an open-source (MIT) project with this summary: “Write your apps in Python and release them on iOS, Android, Windows, MacOS, Linux, Web, and tvOS using rich, native user interfaces. Multiple apps, one codebase, with a fully native user experience on every platform.” Source: <https://beeware.org https://beeware.org>
- atomize 3y agoI've been coming in and out of the Python ecosystem for years as it isn't my primary tool but often is a piece of a project or something along those lines. Is it just my limited exposure, or is there a sort of stagnated, low-key 'GUI lib cold-war' going on in the Python space? Many libraries, and framework-type things seem to have come and gone, while none have really 'taken hold', so to say. Is this the case? And, specifically, what is the big hurdle to a widely accepted GUI library in Python?
- zzzeek 3y agofor Python GUIs (or "TUIs", or "a screen with colorful buttons and controls I can use with the mouse or keyboard but NOT a "GUI" " if that helps some of the responders to get through the day) I recommend considering a console-based GUI using the excellent Textual: https://textual.textualize.io/ https://textual.textualize.io/ this is the most modern GUI (in a console or not) framework you'll find for Python right now.
- TheRealPomax 3y agoNot really a GUI then, though? It's a UI (and from the screenshots, quite nice), but it's lacking the part that makes it "graphical" (which doesn't actually include "colors or borders", of course, we've been able to do those since CGA, and terminals, respectively).
- noman-land 3y agoWow, Textual looks amazing. Thanks for the link.
- deleted 3y ago[deleted]
- 1ark 3y agoI have used React/Preact/React Native/Flutter to build complex UIs. I thought it would be great to use something like this to render TUI and get rid of some of the app complexity for “simpler” one-user apps. I have used it and it is a nightmare when your app gets just slightly complex. Instead of making simple components I ended up traversing the internals of the library. Impressed by some people getting things done with it though. - CSS, why?! It does not really work like CSS when it comes to positioning things, overlapping and so on. Compared to previous versions where these properties were in a dict or sent in to the component, they are now in either big string blocks or in separate files, removing syntax highlighting and/or locality. - Cannot easily use debugging such as PDB because it hijacks Traceback and uses async. Maybe fine if you rely on other debugging tools. - It lacks simple off-the-shelf components such as menu bars, so I built my own, but run into annoying artifacts as mentioned before. Rich, the underlying rendering library is good, and simple enough. I ditched Textual for prompt_toolkit, and can still use Rich to render things in pt.
- torstenvl 3y agoI'm a big fan of using wxPython instead of Qt or the other recommendations in OP. https://www.wxpython.org/ https://www.wxpython.org/ wxWidgets is mostly licensed under an LGPL analog with linking exceptions intended to permit distributing binaries under any license you choose. No part of wxWidgets, including wxPython, has a license more restrictive than the LGPL.
- pdonis 3y agoI have tried wxWidgets and wxPython, and while there are many nice features, my issue with it has always been that its behavior is inconsistent across platforms. I have found Qt to be much better at delivering the same experience across platforms. Using PySide 2 with the previous version of Qt (Qt 5 instead of the current Qt 6) avoids any licensing issues since PySide 2 uses the LGPL version of Qt 5.
- LoganDark 3y ago> my issue with it has always been that its behavior is inconsistent across platforms Isn't that because different platforms are different? This should be a feature. "Cross-platform that feels native", because each platform has a different definition of "native". IME wxWidgets was always better than Qt or any other of the high-level piles of bloat. For example, its layout system would actually use the platform-native, rendered sizes of components, instead of the native components only being a skin over a secret other layer that has its own input handling (looking at you, Qt/GTK).
- pdonis 3y ago> Isn't that because different platforms are different? To some extent they are; I don't mind having Windows-native-looking widgets on Windows and Linux-native-looking widgets on Linux. But programmatically, code that is designed to do a particular function should do it the same on all platforms. That's the point of having a cross-platform toolkit. If I end up having to write a lot of platform-specific code to handle quirks, I might as well just ship separate apps for each platform. It's been a while so I don't have specific examples, but that's generally what I remember running into. Of course a lot of this will depend on what specific things you are trying to do. One item that I do remember having particular issues with was multiplexing network I/O with the GUI--which is inherently difficult because both of those things want to run their own event loop. Qt has a built-in "widget", QSocketNotifier, to bring network I/O events into its GUI event loop, but wx does not, so I had to roll my own, and it took different tricks on different platforms to make it work (and it was still clunky even then). But many GUI applications don't have to do that.
- BlackLotus89 3y agoI sometimes miss the good old days of visual basic and delphi when I could create a gui that just worked in seconds, help pages via F1 and quick access to all events possible through simple gui clicks. A few days ago I tried getting a simple PyQtWebengine example working using pyqt6 and failed miserably. It was a frustrating experience for sure
- brainbag 3y agoI'm working on a project and have been thinking along the same lines. Are there any modern cross-platform tools any language that are good for building like the good old days?
- adderthorn 3y agoLazarus with Free Pascal is the only one I know of. The designer component works just like VB/WinForms but works cross platform.
- UnnoTed 3y agoI like to use GoVCL [0] as it provides the GUI of Lazarus [1] including drag-n-drop form designer but with Go as the main language. GoVCL's author built a C library called liblcl [2] which is what GoVCL uses to control the GUI, so if you know C you can use it instead of Go. I'm building a lightweight Steam chat client with GoVCL so that I don't need the official client that takes like 200-300mb ram just to show text [3]. [0]: https://github.com/ying32/govcl https://github.com/ying32/govcl [1]: https://www.lazarus-ide.org/ https://www.lazarus-ide.org/ [2]: https://github.com/ying32/liblcl/blob/master/README.en-US.md https://github.com/ying32/liblcl/blob/master/README.en-US.md [3]: https://files.catbox.moe/c4lzxb.png https://files.catbox.moe/c4lzxb.png
- moffkalast 3y agoMaking a GUI these days that isn't based on HTML and CSS in some way is an... experience.
- maho 3y ago
- okasaki 3y agoI tried to use GTK for a little project at work and I couldn't figure out how to make it look decent. I ended up making a flask app and launching a browser. It seemed to be 100x easier. I would prefer to make native GUI apps but it's just so much more difficult.
- pdonis 3y agoI have had the same problem whenever I've tried to use GTK. Qt, which is what the article is mostly based on, has worked much better for me.
- marcodiego 3y agoMy suggestion for people experimenting with GTK these days is to take a look at the examples that are being built into "gtk workbench".
- F00Fbug 3y agoFor vanilla applications PySimpleGUI is so easy to use: https://www.pysimplegui.org/en/latest/ https://www.pysimplegui.org/en/latest/ Personally, if I'm writing software that needs to talk to a human I'll just build a web interface instead of a GUI.
- hwayne 3y agoThe guide lists four different GUI frameworks and the comments (so far!) have listed two more.* None of them really have claim to being the good "default" (except maaaaaaaaybe tkinter) and all of the "GUI-knowledge" is fragmented across them. I like Python but whenever I have to make a GUI, I shy away. * Between starting and finishing this comment, someone brought up a third. Now we're up to seven!
- bmelton 3y agoWell I haven't seen anyone mention Flet, which is pleasant (if maybe not all that complete) if you have Dart/Flutter experience, so increment your counter at least one. :-) https://flet.dev/ https://flet.dev/
- igortg 3y agoBoth PySide and PyQt are Python wrappers for the Qt library (that makes it 2 frameworks). Basic usage is almost the same. It seems the author push for PyQt a bit, even though PySide has the same basic capabilities with the benefit of LGPL license (PyQt is GPL or Commercial).
- minimaxir 3y agoMany of the Python GUIs here are GPLv3, which unfortunately makes them a nonstarter in a lot of projects.
- Brian_K_White 3y agoWhy should anyone care about that? If you want to sell something and keep it all to yourself, then go buy something. Qt will happily sell you a quite nice resellable component. If you want to reshare that which you got for free yourself, great, no problem there either. Say what exactly is the problem that isn't either of those two situations out loud.
- dist-epoch 3y agoThe problem is when you want to create a tool for internal company usage.
- Philpax 3y agoIf you don't distribute it publicly, you don't need to distribute the source: https://www.gnu.org/licenses/gpl-faq.en.html#NoDistributionRequirements https://www.gnu.org/licenses/gpl-faq.en.html#NoDistributionR...
- Brian_K_White 3y agoThere is no problem with that.
- minimaxir 3y agoBecause I want to write open-source software that isn't required to also be GPLv3 as a result of using GPLv3 software.
- pacifika 3y agoThe problem remains delivering the app to the customer in my experience, unless something like flatpak can be used cross platform. Unless picking a solution from the start and testing it throughout, I find that the most challenging.
- pdonis 3y agoI have found PyInstaller [1] to work well for packaging everything into a single ZIP file that unzips to a folder with an executable binary and all accompanying files (or even a single EXE file that self-extracts when run, but that increases startup time). It knows how to package PyQt and its associated Qt libraries (or PySide, which I actually prefer) so that they can be shipped with your application. [1 https://pyinstaller.org/en/stable/ https://pyinstaller.org/en/stable/
- igortg 3y agoYeah, PyInstaller is the best thing out there if you need to bundle a complex Python app into an executable, with cx_Freeze not far behind. But it's still considered challenging when you compare with any other compiled language, where you can get an executable out of the box. I ship Python desktop apps at work and it's remarkable how much code we accumulated over the years just to deal with the "interpreter in bundled/exe mode".
- mherrmann 3y agoCheck out (my) https://build-system.fman.io https://build-system.fman.io.
- PrivateButts 3y agoPyInstaller always seems to tick off our org's MalwareBytes, causing it to break in new and interesting ways but only after a good amount of development hours have been sunk into the project. Recently I've been using Nuitka to package python apps. It would be nice if PSF would adopt/develop an official way to do this.
- Case_of_Mondays 3y ago
- at_a_remove 3y agoI used wxPython many, many years ago on a foolish project. I am sure it has matured. But as always, I turn to PEP 20, in particular "There should be one-- and preferably only one --obvious way to do it." Batteries ought to be included. I'm hardly a language designer, but more and more I care less about things like syntax and such, and more about having as much as possible already built out, so I can focus on the particulars of a problem, rather than having to endure a "evaluate a bunch of alternatives" phase for each little thing. It's a tall order, and a growing one, but I think whatever the next big language is, it will have that kind of focus.
- etrevino 3y agoMaybe I misunderstand you, but there is Tkinter if you want a GUI included with Python.
- at_a_remove 3y agoA little bit, yes. I don't just want something bundled with Python, I want that thing to be the undeniably best choice. I want "batteries included" to mean that I wouldn't bother to look for anything but what came with the language.
- galoisscobi 3y agoIs it just me or do most python GUI options have ugly UI and seem to lack polish?
- Case_of_Mondays 3y agoSome of the new web-oriented ones look a lot better. Streamlit, nicegui, gradio, etc.
- galoisscobi 3y agoAh sweet. I’ll check those out. Thanks!
- nrjames 3y agoI'll piggyback here for a related question: I need to build some simple UI on top of a few Snowflake tables, to support a small group of users and their quality assurance tasks. Essentially, they verify important metadata and need to fix it in the Snowflake tables when it is incorrect. Ideally, I can build that with Python. I was thinking of DRF and React (since things like Retool are out of the question) but I'm open to any framework/stack. What is the most simple way to accomplish and maintain this?
- igortg 3y agoDrop React, just go with pure DRF or Flask and use a nice JavaScript library for table edition (https://datatables.net/ https://datatables.net/).
- theanonymousone 3y agoYour description loudly shouts Streamlit to me. The fact that streamlit is owned by Snowflake is just the cherry on the topy, if anything :) You may want to have a look at https://streamlit.io/gallery https://streamlit.io/gallery
- spapas82 3y agoI think that tkinter is "good enough" for most cases that need a GUI in pythonb these days (for more complex stuff you'd better go with either a web app or a compiled language that creates normal desktop apps). As a showcase I've built two simple utils with python and tk (and pyinstaller): - https://github.com/spapas/pdfmerger https://github.com/spapas/pdfmerger a simple tool to merge pdfs into one - https://github.com/spapas/pomo https://github.com/spapas/pomo ; a simple pomodoro timer
- ptx 3y agoThe pomodoro example seems to be updating the UI from a background thread. The TkDocs tutorial [1] advices against this and suggests posting a custom event to the main thread instead. Using the after or after_idle methods [2] to post a callback to the main thread also works, and seems easier to me since it allows you to pass arguments. In this particular example, where the background thread is just used as a timer, you could remove the threading entirely if you use after to let Tkinter handle the timer. [1] https://tkdocs.com/tutorial/eventloop.html#threads https://tkdocs.com/tutorial/eventloop.html#threads [2] https://tkdocs.com/shipman/universal.html https://tkdocs.com/shipman/universal.html
- spapas82 3y agoThank you for the suggestion I'll update my code to use after instead!
- footlose_3815 3y agoPyQT's license is not ideal, and that's why Pyside exists. https://www.pythonguis.com/faq/pyqt-vs-pyside/ https://www.pythonguis.com/faq/pyqt-vs-pyside/
- maho 3y agoI love gooey: https://github.com/chriskiehl/Gooey https://github.com/chriskiehl/Gooey It allows me to quickly slap a GUI on an existing script that accepts command-line-arguments. In the end, I get the best of both world: Discoverability from the GUI, automation through the script, and automatic feature parity between the two. Downside: Control over the GUI layout is basic, and only "standard" GUI features work, but I never felt limited when using it.
- 037 3y ago+1 for Gooey. This "auto-GUI" app is a godsend for any script-user seeking to minimize friction. Lately, I've been diving into Ruby (fallen in love with Ruby on Rails) and I'm hoping to come across something similar.
- fud101 3y agoDope
- gary_0 3y agoNote that it's built on top of wxPython. I think a "middle ground" user interface between the commandline and a full-blown graphical environment is a great idea.
- deleted 3y ago[deleted]
- Case_of_Mondays 3y agoI have been looking at Python GUI libraries/frameworks/services over the past > 1 year. I'll cut straight to the chase with my recommendations for what they are worth. - NiceGUI https://nicegui.io/#features https://nicegui.io/#features - my favorite of the bunch, essentially wraps Quasar Vue components with accessible python. Tons of features including SPA, FastAPI under the hood, TailwindCSS. Have used it on a few projects and started contributing recently. - Streamlit https://streamlit.io/ https://streamlit.io/ - if your goal is to get some python code set up with a GUI and deployed ASAP this is the best option. I have gone from 0 to a full working app in like an hour for some projects. Lots of love for it. A bit limited in terms of full-scale applications and large backend databases but it actually holds up really well. There are a lot of other ones that people regularly recommend. - Gradio https://gradio.app/ https://gradio.app/ - really popular with huggingface and ml folks. Similar to streamlit in that it sacrifices some level of depth for speed of standing up projects. - Textual https://www.textualize.io/projects/#textual https://www.textualize.io/projects/#textual - Building text-based UIs for the console. Seems to be pretty popular on reddit... Not to be a hater, but I have never seen a good argument for why it's worth dumping a bunch of time into this versus a web-oriented framework. They say "it's useful for products that don't need the internet", "you can use it through ssh", etc... doesn't really fit with my needs, I'll just leave it at that. - Anvil https://anvil.works/ https://anvil.works/ - a "low code" option for building python GUIs. I am pretty impressed, it has integrated databasing and a lot of plugins. If you are aiming for a scalable application for a large number of users this is probably a good options. My personal gripe with it is the number of mouse clicks it takes to do stuff but that could also be my lack of experience with the tool. - Plotly dash https://dash.plotly.com/ https://dash.plotly.com/ - not usually thought of as a full GUI library necessarily but they have options for deploying the dashboards to the web - and the overall look and feel is nice. A good option if you have a small notebook with plots that needs wider accessibility. My use cases are typically 10 - 50 users in an enterprise setting, so accessibility/low barrier to entry (pretty much meaning web-based) are concerns of mine. I also lean toward wanting to avoid learning overly-opinionated libraries (I put Qt and tkinter into this category). Why spend 50 hours learning Qt's way of building an app when I could use something like NiceGUI which lets you build a nicer looking app and gets you familiar with web dev concepts in the process. Imo a better use of my time.
- LoganDark 3y agoNobody has recommended prompt_toolkit (TUI only) yet, so here I go: https://python-prompt-toolkit.readthedocs.io/en/master/ https://python-prompt-toolkit.readthedocs.io/en/master/ I'm working on an interface for an LLM (large language model), and prompt_toolkit seems to be the only library with enough text-buffer features for me to implement everything I want. It's quite imperative-feeling though. Have to keep references to individual widgets if you want to do anything with them later.
- 1ark 3y ago+1 for prompt_toolkit. Good and approachable docs as well.
- LoganDark 3y ago> Good and approachable docs as well. For me the docs were barely enough to get started, and completely left out some of the features I'm using (such as the `get_line_prefix` callback); it took me a lot of messing around to figure out how to do what I wanted. But it was probably worth it, I'd say.
- nologic01 3y agoIt would be nice to have a canonical python GUI framework. Something modern and elegant and flexible. With an intuitive declarative description, quick for simple things but progressivly enhanceable for more complex things. With a friendly license and an active community sharing components, themes or whatever. Reasonanly performant and ideally cross-platform. All the options fall short somehow, but guess what, its not much better in any other language. The GUI problem is not truly solved.
- korijn 3y agoStill young and new, but definitely modern, elegant, flexible and declarative: https://github.com/fork-tongue/collagraph https://github.com/fork-tongue/collagraph
- keithalewis 3y agoMy guilty secret is to use Excel for my quick and dirty GUIs. I wrote a library to make that easy if you know C++. https://github.com/xlladdins/xll https://github.com/xlladdins/xll. People already know how to use Excel so I don't have to start from scratch
- mikewarot 3y agoI lost a year of time on a side-project because of WxPython, I built a shim to allow me to make small tweaks without having to regenerate the python code, and it was barely usable.... then I had to change a list to a drop-down (I think), and it broke everything. I threw all of that time away, and had it all working in Lazarus/Free Pascal in less than 2 weeks. Most web based programmers have no clue how badly "modern" tools are compared to the VB6/Delphi era. Everything is worse, except for GIT... GIT is brilliant. --- Also, my personal wiki of choice is WikidPad, which is distributed as an executable for windows, and works just fine. I can't move to Linux, because it's distributed as source there, and WxWindows made a breaking change to one of their key parameters to dialog function calls, so none of the dialogs work properly, though it does show text. It's effectively read-only and broken as a result.
- gapan 3y agoI'm sure there is a way to fix it on Linux but an interim solution would be to use the windows executable with wine.
- alfiopuglisi 3y agoShameless plug for my own python GUI toolkit: guietta! http://guietta.readthedocs.io/en/latest/ http://guietta.readthedocs.io/en/latest/ It is built on top of PyQt5. But be very careful if you use conda, because conda decided to rename the PyQt5 packages, resulting in near-irrecoverable env crashes if conda and pip are mixed. In that case, make sure to use conda-forge to install.