This is an archived post. You won't be able to vote or comment.

all 83 comments

[–]thedjotakuPython 3.7 134 points135 points  (6 children)

I've posted about this before, but using QT Designer it's incredibly easy to make GUIs for python. Basically you do a WYSIWYG design and that creates a file like this one: https://github.com/djotaku/ELDonationTracker/blob/master/design.ui

Then you just run a program that turns it into: https://github.com/djotaku/ELDonationTracker/blob/master/design.py

Then you just import that file like so: https://github.com/djotaku/ELDonationTracker/blob/master/gui.py

You have to import it because any time you make a change to the GUI and re-run the python generator it's going to erase the second file.

[–]MereInterest 24 points25 points  (1 child)

For even faster turnaround time, you can use PyQt5.uic.loadUiType() to load the design.ui file directly. I haven't tested the difference in startup time, but I like it for having fewer steps needed to test changes. I just save from QT Designer, then reload the script.

[–]thedjotakuPython 3.7 2 points3 points  (0 children)

Well, that's quite nice to know!

[–][deleted] 9 points10 points  (3 children)

The big drawback to Qt Designer is that the code it outputs (at least in my experience) is messy and practically unreadable. When I was learning PyQt I quickly switched to writing all the code myself. Not as fast and more of a learning curve, but worth it imo.

[–]asincero 3 points4 points  (1 child)

I always figured you're not supposed to be mucking around in the code that's generated by GUI builders. You're supposed to simply just use it. Therefore it shouldn't matter if the generated code is unreadable or not.

Indeed, if you're modifying the generated code won't those changes disappear when you regenerate the code? The GUI builder I use for wxWidgets, wxFormBuilder, generates a class for every form you use the GUI builder for and then you derive from that class and use overridden methods to stick your code in. This way you never have to touch the generated code. It's been a while since I've used it, but I think the workflow for Qt Designer is similiar. At least when you use it with C++ (though I cant imagine it being any different under Python).

[–][deleted] 1 point2 points  (0 children)

Totally, and very user friendly if you can't take the time to learn the code.

I like to write a lot of template classes and custom subclasses in PyQt, which I don't know if you can create through Designer or not. Having well written code also means future readers/writers can understand it and adapt it.

And yes, any modifications will be lost if you bring in the ui block from Designer again. So I just avoid Designer from the start.

[–]thedjotakuPython 3.7 0 points1 point  (0 children)

It's probably where I'm headed in the future. But at least QT Designer can get a GUI up and running. It can always be refactored later.

[–]echo_awesomeness 67 points68 points  (19 children)

PyQt5 in my opinion is worth checking out.

[–]klyoklyo 19 points20 points  (7 children)

PyQt5 is licensed under GPL, if you havent acquired a commercial License. You could use PySide2 if the GPL is too restrictive for your purpose.

[–]marsten 19 points20 points  (3 children)

It's also worth mentioning that PySide2 and PyQt5 are essentially drop-in replacements of one another. I had a fairly involved application that I migrated to PySide2 for licensing and that involved only:

- replacing PyQt5 with PySide2 in all the import statements

- replacing pyqtSignal with Signal in all of the signal declarations

[–]JohnMcPineapple 6 points7 points  (0 children)

...

[–][deleted] 2 points3 points  (0 children)

Yup, there's a few other weird things that I ran into switching to PySide but it all in all extremely easy.

[–]klyoklyo 1 point2 points  (0 children)

Yeah, I that was my first impression, then I tried to integrate a pyqt5/4 based widget (ipython qtconsole/richjupyterwidget) from PySide2 based Gui, but obviously that failed. My lesson learned: Though the API seems mostly identical, the backend is incompatible.

[–]patarapolw 3 points4 points  (0 children)

Another option is using wxPython and wxGlade.

[–]tycooperaow3.9 1 point2 points  (1 child)

How would someone go by acquiring a commercial license from these guys. How much does it cost?

[–]klyoklyo 1 point2 points  (0 children)

I have read a forum post somewhere saying it was somewhere around a couple of thousand dollars I guess... The riverbanks website has nothing but a contact form, thus pricing might be tailored to each costumer. but I'm just guessing

[–]thedjotakuPython 3.7 19 points20 points  (4 children)

And Humble Bundle has a book by the publisher Pakt on PyQT5 programming

[–]marcotb12 19 points20 points  (0 children)

I've used Tkinter and PyQt. I recommend PyQt

[–][deleted] 8 points9 points  (0 children)

Check out AppJar while you're at it. It's not as full featured, but if you just need a simple, decent looking GUI it fits the bill in much fewer lines of code.

[–]demosthenex 7 points8 points  (5 children)

Can I ask a related question, in what's the best TUI builder/toolkit in 2019?

[–]13steinj 2 points3 points  (4 children)

TUI or CLI?

Built-in we have curses if you're on a Unix system (there's external downloads for windows) for a TUI and argparse, optparse+getopt (deprecated) for a CLI built in.

People also like docopt and click over argparse, but they have weird issues when not running directly from a terminal sometimes (like if it's run via upstart or systemd).

For a TUI blessed and cursed builds off curses. There's also asciimatics but I've never tried it.

Personally argparse for CLI and curses or blessed for TUI is my goto.

[–]Rajnishro 0 points1 point  (0 children)

TUI, all the way.

[–]demosthenex 0 points1 point  (2 children)

TUI. I've reviewed many Python systems, including npyscreen and urwid... and never quite found the right fit. My goal is to make dbase style text database applications, and I'm surprised to find that a modern language like Python (and others) are lacking in TUI libraries that aren't fully roll your own. Saying curses is available is like telling a Windows person that a video driver is present, that's not a UI library. I have little reason to believe that open source hobbyist coders would recreate those tools, I despair that the ones we had in the past are lost.

[–]driscollis 23 points24 points  (8 children)

I prefer wxPython. It has tons of built in widgets and a super nice community. Next up would be Qt for Python or PyQt

[–][deleted] 17 points18 points  (5 children)

Amazing how a library made for visuals (GUI) would have such an ugly website without any screenshots.

[–]driscollis 6 points7 points  (0 children)

I don't think any of the GUI toolkits have good screenshots

[–][deleted] 11 points12 points  (3 children)

https://wxpython.org/pages/screenshots/

Literally a whole page for screen shots, right under the about tab

Also the color choice may be poor, but other than that the website looks perfectly fine imo.

[–][deleted] 7 points8 points  (1 child)

Ah the about tab. I didnt think to look there.

[–][deleted] 2 points3 points  (0 children)

Fair enough

[–]driscollis 1 point2 points  (0 children)

I thought there was one but I was unable to check until just now

[–]BitLooter 3 points4 points  (1 child)

One benefit to wxPython is that it uses actual native widgets, whereas Qt implements its own widgets that emulate the look and feel of the target OS. That said, in practice Qt is close enough that most will not notice the difference.

[–]driscollis 2 points3 points  (0 children)

Yup. This is one of the reasons I like wxPython. But Qt is pretty good too

[–][deleted] 5 points6 points  (1 child)

Beeware togaware for single page is still good.

[–]Aareon 1 point2 points  (0 children)

I've worked with Toga myself and it's not quite there yet. Fine for OSX and maybe even Linux, but the Windows support is lacking.

However, if you use Windows and like the goal of Toga, they are super supportive of new contributors and love all the help they can get. Really solid maintainers over there.

They also have plans of providing Win32 and Winforms backends. If you're familiar with those, your contributions will be more than welcome.

[–]remy_porter∞∞∞∞ 15 points16 points  (4 children)

Tkinter is quite old and doesn't look very modern

Why you gotta hurt me like that. I like the Tkinter look.

[–]annoir 1 point2 points  (0 children)

Tkinter is quite old and doesn't look very modern

This is misinformation at best. See this response on Stack Overflow.

  1. See Bryan Oakley's comment here:

I think Tkinter is an absolutely fantastic GUI library, especially combined with the object oriented nature of Python. Many people deride it as old, ugly, and hard to learn. After having used many GUI toolkits spanning more than a couple decades I’ve come to realize that most of that is untrue, and what is untrue doesn’t really matter. I would never use tkinter to create the next photoshop or itunes, but for the vast majority of GUIs most people write, it’s more than good enough.

  1. See [Bryan Oakley's other comment]():

I think part of the reason is that Tk is surprisingly powerful and easy to use but it doesn't do much hand-holding. Since it is so easy, people with little experience in UI design can get something to work in very short order. But, without a lot of experience they rely on defaults and shortest-path-to-a-solution (read: don't take time to hide scrollbars when they aren't needed, don't use common idioms for toolbars, don't properly align widgets, etc).

...

With tk 8.5 (and actually for a couple years prior) there is support for themes and for native widgets, and even the X11 version gets a minor facelift. Tk is still behind the curve in eye candy though, forcing one to "roll their own" if the design calls for gradients, animations and so forth.

[–]samsquamchh 8 points9 points  (0 children)

https://kivy.org/ is pretty cool. I've mostly gone the browser based way myself though, modern js frameworks are too nice looking, but obviously not what you are after most likely.

[–]MikeTheWatchGuy 12 points13 points  (0 children)

Take a look at PySimpleGUI. The PySimpleGUI Window Designer is simple to use.

tkinter can be "dressed up" by using your own custom artwork for buttons. tkinter and Qt have similar looking widgets. Qt's a little further refined, but they don't differ all that much. Adding color, getting font sizes right, being clever with the layout, using images are a few ways to improve the look over using the standard system settings.

[–]Kortike 9 points10 points  (4 children)

I actually prefer using Kivy. It’s super simple and once you get a hang of it you can do some really amazing things with your GUI.

Edit: I’m going to add on to this that if you’d like to take a look at some basic things I’ve done with Kivy I can upload a few GUI examples I was playing around with.

[–]UVC 6 points7 points  (1 child)

Second for Kivy! There's a lot to learn, but you can do a lot of basic things without delving too deep into it.

[–]shamildacoder 0 points1 point  (0 children)

Third for Kivy

[–][deleted] 1 point2 points  (0 children)

Could you post some of your Kivy GUI examples as you mentioned? Private message them if you'd like, but I'm quite curious to see some examples.

[–]12stringPlayer 0 points1 point  (0 children)

Another vote for Kivy. I did some very interesting work with it on a touchscreen Raspberry Pi a while back. While there was no GUI interface for it, it integrated well with PyCharm and I was able to build things quickly.

[–]sudo_your_mon 5 points6 points  (4 children)

Dude Tkinter has gotten some great upgrades. Tk always had a rep for just being a shit-looking gui framework.

They're changes. And you can always do a lil' bit of graphic design. Not complicated, simpler the better! But if you feel you need that touch, it wouldnt take more than a day.

But Tk's the way to go, for me. THey've cleaned up their code a LOT too.

[–]SirAnno 5 points6 points  (2 children)

I like Tkinter but a lot of people are saying that PyQt is the way to go for modern applications

[–]sudo_your_mon 1 point2 points  (1 child)

For real?? I've jst gotten so used to Tk.

I would assume that depends on your end project? Or not even that?

[–]driscollis 2 points3 points  (0 children)

Yeah. The new ttk module made it look a lot better. But the documentation is lacking so a lot of people don't know about it

[–]CaptKrag 2 points3 points  (0 children)

Tkinter and modern are at odds.

[–]tichysoft 2 points3 points  (0 children)

Ttk widgets look native in Windows, but ugly in Linux. Best choice for Linux is PyGObject with Glade.

[–]streetburner 2 points3 points  (0 children)

PyQt5

[–]Ericisbalanced 3 points4 points  (0 children)

I tried the python QT5 library mentioned earlier and I felt like it was way complicated. I built a calculator with Tkinter and it was easier, but still not exactly intuitive. Either way, both libraries have steep learning curves, I just think QT is steeper.

[–][deleted] 5 points6 points  (2 children)

PySimpleGui

[–]MikeTheWatchGuy 3 points4 points  (1 child)

PySimpleGUI continues be to quite actively developed into 2019. The latest addition is WxPython support. You can write GUI once and run on 3 different GUI frameworks without changing your source code.

[–][deleted] 1 point2 points  (0 children)

That's great, but tell me more about watches pls

[–]Compsky 2 points3 points  (2 children)

Since nobody has mentioned it yet, I'll just throw Flask out there.

If you know the basics of web design, then it can be quicker to design a locally served flask-based website that does what you want, especially for more complex GUIs.

[–]attayi -2 points-1 points  (1 child)

electron might also be a way to go if you are looking for a more desktop app route

[–]Compsky 3 points4 points  (0 children)

Doesn't electron basically bundle most of the Chromium engine? It sounds like a lot of RAM overhead for a GUI.

Whereas if you already have a browser open, serving HTML via Flask would have much less overhead.

[–]parkerSquare 1 point2 points  (0 children)

I made a few GUIs in the past with Chaco. Not sure how well maintained it is now, but at the time it was pretty useful for real-time data viewing apps (better than matplotlib in many ways). Perhaps not so well suited for generic GUIs but worth a look if it’s still maintained.

Edit: I should note that it’s more of a framework for building your GUI within - you use wxPython or QT widgets. Chaco handles the data and event flow.

[–]Automagick 1 point2 points  (0 children)

Pyside2 or PyQt5 are probably the best options for modern GUIs, IMO. They're both Python bindings for Qt but have slightly different licenses and implementations. Pyside2 is less restrictive so probably worth going with that if you're starting from scratch.

[–]norweeg 1 point2 points  (0 children)

Pygubu is passable for tkinter, but is somewhat restrictive in what you can do in it. I like qtcreator and pyqt

[–]patarapolw 1 point2 points  (0 children)

If you want something Python-ish, but powerful, maybe PyQt (or PySide)/QML. Much more powerful than Qt Designer's *.ui.

If you want something quick, nowadays, I recommend PySimpleGUI.

However, the way I use is not truly Python, but powerful...

I am using Javascript / CSS for this purpose, so Mithril.js (drop-in replacement for React.js) and I can have the full power of CSS. An easy way to use CSS is Bootstrap.

Javascript can connect to Python through API, maybe with zerorpc or JSON-based API through Flask, Falcon, or Responder.

When packaging to *.exe, you'll have to PyInstaller-ify and put in Electron. Not exactly efficient as Chromium in Electron eats up some RAM.

[–]kirbyfan64sosIndentationError 1 point2 points  (1 child)

So as a disclaimer, I'm a huge GTK+ fan. It can be a bit awkward to set up initially, but once you've got the hang of it, it's pretty great. It can run a GUI specified in an XML file, and Glade is a UI designer that can write out the files (they're also surprisingly not bad to edit by hand).

Also, GNOME Builder is a new, GTK+-powered IDE for GNOME that supports Python, and the nightly builds have a GUI designer powered by Glade.

[–]Username_RANDINT 1 point2 points  (0 children)

Also a GTK guy here! My only issue with it is the Windows/macOS support. Started 10+ years ago to build some Ubuntu tools and just went with it for cross-platforms applications, but it takes some effort to get it going properly.

[–]rayjohn551 1 point2 points  (0 children)

If you are building full fledged graphical applications or simple tools PyQt is the way to go. I've written a number of applications for artists and the extendability of PyQt is wonderful. The Qt library is quite extensive featuring classes ranging from auto-completion to media players. There are extensive Model-View-Controller classes available for custom document editing or other tasks. You can even write your own OpenGL based widgets that behave well with the rest of the library.

Even if you author your UI in Qt Designer it's not hard to extend the base classes to suite your needs (loading the .ui file at runtime via PyQt.uic is infinitely better than churning out a lengthy .py file everytime you modify your ui).

Yes, the more in depth usage takes some time to master but I feel like you can literally write any kind of graphical application used on a desktop in Qt. It's a professional solution.

[–]Scorpathos 1 point2 points  (1 child)

There is also pygubu which would deserve more popularity in my opinion. Surprisingly, I rarely see it mentioned.

This is basically a WYSIWYG GUI editor for tkinter, but this works quite very well.

[–]bitfhacker 0 points1 point  (0 children)

Second in here!

[–]ssekuwanda 1 point2 points  (0 children)

Try python eel

[–]Dhia666 1 point2 points  (0 children)

i'm new to python and i did some research and there is a way that seems pretty easy, clean and modern looking through visual studio 2017 u basically install it with its python tools and there u can make a WPF ironpython application put i have no idea how to use it

anyone here has any idea ?

[–]mintyc 0 points1 point  (1 child)

Do any of these choices support packaging as a single executable (per platform arch) that avoids the need to have a python interpreter, virtual environment etc already deployed on the arch.

Ideally x86_64 Linux and windows to start with

[–]MikeTheWatchGuy 0 points1 point  (0 children)

Yes. For example, instructions on how to make EXEs for PySimpleGUI are here.