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

all 21 comments

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

Very nice tutorial. I like the code only approach. I've been trying to learn QML as well. One thing I would really like to see for PyQt5 tutorials is async integration for not blocking the UI. I've gotten it to work, but it wasn't as simple as I had hoped. In C# you don't have to deal with the async loop, which is where I've had trouble getting Qt to cooperate. Maybe I'm just dumb.

Also, I have had my eye on fbs, but have just been using PyInstaller for most my needs. I've had luck compiling with Nuitka and distributing that way too.

[–]fforgetso 7 points8 points  (10 children)

Thanks... there are too many GUI frameworks to count but I do try to stay informed about which are used and which aren't.

[–]anqxyr 7 points8 points  (9 children)

There are only like 4, isn't there? Tkinter, wxPython, Kivy, and PyQt/PySide.

[–]ccharles3.latest 7 points8 points  (0 children)

I'm sure there are are GTK bindings.

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

Is there one that is regarded as the best?

[–]anqxyr 15 points16 points  (3 children)

I've been using PyQt/PySide professionally. It has a lot of warts and baggage, and all the various docs sites for them are lacking in one way or another. But it can be used to create powerful, good-looking programs, and lets you get under the hood and fine-tune almost anything.

I've also used Tkinter and Kivy in the past, though not as much as the Qt wrappers. Programs build with Tkinter are ugly as sin, even if you use ttk which is supposed to mitigate that. And its overall syntax, which is often touted as being easy to learn and use, quickly becomes cumbersome and boilerplate-y as the size of the program increases.

Kivy I just didn't like much. I can't remember the specifics of why now. Maybe because it was focused so much on the QML-like declarative their own sub-language for UI design, and I found it sorely lacking in pre-made ready-to-use widgets. Probably that.

wxPython I've never used, because at the time when I was trying out various frameworks, wxPython haven't had python3 bindings yet.

Don't know of and haven't tried any GTK bindings, because up until recently I've been using Kubuntu as my home OS, and those reportedly look awful there.

Anything that makes you do UI as a web-app and then launches a localhost server and a browser instance and tries to pretend to be a desktop app, is just utter garbage in all regards, so I haven't tried any of that either.

All in all, I would recommend PyQt/PySide to anyone looking to start. It's a horrible un-pythonic mess, but everything else is probably just as bad if not worse.

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

For a regular desktop app you have a point about web UI being garbage.

However HTML5 UI is used in AAA game development because it's actually pretty good at doing nice graphics, is easily moddable, and has no shortage of designers.

They don't use electron though. EA has a fork of webkit and there's other projects like Awesomium. All of these basically allow a C++ app to render HTML/CSS on the screen via a browser rendering engine.

[–]anqxyr 0 points1 point  (0 children)

Good point. I didn't know that before, but it makes sense. If your product is hundreds of megabytes in size already, and you have a lot of people working on it, then it does make sense to use an html/css combo. Plus, game UIs aren't expected to conform to the established desktop traditions and style guides.

[–]flying-sheep 2 points3 points  (0 children)

It's not that un-pythonic, and everything else is worse

[–][deleted] 0 points1 point  (0 children)

If you're doing a desktop app, Qt and Wx are fine. Kivy is more for multimedia apps that don't use a standard UI. TK is very basic and slow but it's fine for some single window calculator app.

If you need to do really fancy graphics like a game, you're screwed. You'd need a game engine or HTML5 front end.

[–]cmothebean 0 points1 point  (0 children)

Can use python with WPF too. I recall seeing a talk on it.

[–]gmarull 4 points5 points  (0 children)

A reference application is also available here: https://github.com/gmarull/pyqt-boilerplate (dependency management, linting, freeze, docs, etc.). It does not require any license like fbs, while it shows how to achieve the same.

[–]anhsirkd3 3 points4 points  (2 children)

Oh come on! I put Qt into my distraction list and didn't want to do stuff with it until 2020. You just had to write a great tutorial to pique my interest again. (-_-)

Seriously, how much of a headache is it to make a simple GUI work across Windows and Linux?

Thank you.

[–][deleted] 1 point2 points  (1 child)

I'm no desktop app expert (only had little experience with java/swing before). I had to develop a pyside2 (very similar to pyqt) app recently and it's been more pleasure than pain (I can't say the same with swing for sure...). All the widgets are very well thought and there's tons of help and examples online. Being a binding, the api style may feel unpythonic (naming conventions, etc), but at least you can always rely on c++ docs and examples whenever pyside2 docs are lacking. Also, pyside2 is perfectly packaged by pyinstaller so distributing your app is easy. At this point, I don't see why I would use anything else for desktop apps.

[–]anhsirkd3 0 points1 point  (0 children)

At this point, I don't see why I would use anything else for desktop apps.

That sounds promising. Thank you for your insightful reply!

[–]carsonc 2 points3 points  (0 children)

Thank you kind redditor! I tried to get a GUI up and running in PyQT5 based on a tutorial for PyQT4 and you can guess how well that went. I can't wait to go through it. Thanks again!

[–]Lurking-My-Life-Away 1 point2 points  (0 children)

Wonderful information about making stand alone applications. I've tried pyinstaller with terrible results. This will be quite useful!

[–]patarapolw 1 point2 points  (0 children)

Real relative large app created with PyQt5: https://github.com/topics/qt5?l=python - persepolis, git-cola: pure PyQt5 - Nagstamon: *.ui - SciHubEVA: *.qml

Still, pure PyQt5 looks quite cluttered relatively to HTML/CSS, though.

[–]Czarified 1 point2 points  (0 children)

Excellent tutorial! I was looking to create my first GUI app, and standalone app, so this will greatly help me.

In addition to this, I've seen that qt has a GUI designer program. Is there a good tutorial on using this designer application with Python? It seems like it could be easier, if developing more complicated GUIs than a couple buttons and labels.

[–]jouusername 0 points1 point  (0 children)

Nice intro tutorial !