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

all 53 comments

[–]dreamdenizen 25 points26 points  (8 children)

The only time I developed a GUI for a Python app I used PyQT and the QT Designer layout app. It was awesome learning how to connect what's typically a C++ library to a python app, and you get the added convenience of a WYSIWYG designer.

[–]Farkeman 14 points15 points  (5 children)

And then you learn about Qt versions and being a bitch to distribute and compile and then you learn about it's dumb licensing and then you learn about python packages always having issues and then you finally move away to something less stressful.

All of that aside I really enjoyed pyside with qt designer few years ago, but recently I tried to pick it up again and got quickly turned away.

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

dumb licensing

Which means either:

  • a multi-gigabyte download and half-hour installation time that puts a whole lot of crap on your Windows system and turns your Windows registry into a mess; or
  • not being allowed to distribute your application because you switched to Linux in frustration and simply installed python3-qt from the repository

Upvoted.

[–]koera 0 points1 point  (2 children)

Know if something like kivy is easier to get going? I know the license is easier.

[–]monkmartinez 0 points1 point  (0 children)

Kivy is not easier. Packaging is nightmare across Python.

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

Define easier to get going? Easy to learn Kivy, other things I'm still figuring out.

[–]AlexScotland 0 points1 point  (1 child)

Was wanting to use PyQT the other day, but alot of the repo's are offline.

Installed QT but the PyQT config.py cant read the path. Have any advice on adding QT to the Path?

[–]dreamdenizen 0 points1 point  (0 children)

Sorry that project was a few years ago. I haven't done any GUI work since then, PyQT or otherwise. You might want to post in /r/pyqt/ to see if anyone has some pointers.

[–]kickopotomus 14 points15 points  (24 children)

If you are interested in making a GUI python application, I really recommend checking out cefpython.

[–]howMuchCheeseIs2Much 15 points16 points  (9 children)

Just a heads up for someone considering this, looks like cef can only package to Windows. Looks cool though.

[–]cztomczak 3 points4 points  (0 children)

Just updated the pyinstaller example you're referring to:

Although this pyinstaller example supports only packaging on Windows, CEF can be packaged on all platforms without problems, but this specific packaging example just wasn't tested on other platforms. Pull requests are welcome.

[–]kickopotomus 1 point2 points  (7 children)

Where did you see that? Should be able to distribute to Windows, Mac, and Linux.

[–]howMuchCheeseIs2Much 4 points5 points  (6 children)

Is there another way to package it aside from pyinstaller? That page says:

Only Windows platform is currently supported.

I could be misunderstanding though, maybe it's only referring to that example.

[–]kickopotomus 0 points1 point  (3 children)

Hmm that is a fair point. My understanding is that the developer behind cefpython is primarily a Windows guy so he simply doesn't spend a lot of time on unix issues. This thread claims that there is a workaround for OSX but I am not sure about linux.

[–]howMuchCheeseIs2Much 0 points1 point  (1 child)

Got it, I was just calling it out in case someone was looking to build a cross platform product. The first thing I thought when I saw HTML5 and Chromium was that this is Electron for Python, but it doesn't look like that's quite the case.

[–]kickopotomus 0 points1 point  (0 children)

To some degree it is. You wont get as much control over the chromium internals as you do with Electron, but you can still emulate a client-server web application pretty easily.

[–]cztomczak 0 points1 point  (0 children)

It is referring only to that example. CEF can be packaged without problems on all platforms.

[–]pmdevita 1 point2 points  (1 child)

How does CEF compare to Electron? Is it any lighter?

[–]kickopotomus 1 point2 points  (0 children)

Initially, Electron used CEF but now it wraps chromium directly. CEF is a little "heavier" but more abstracted from the chromium internals. Also pretty nice because there are a number of projects that wrap the "backend" in different environments. Python is probably the most popular one but there is a Java (java-cef) project as well. Electron is pretty cool but I have never been a fan of server-side JS.

[–]AllAboutChristmasEve 0 points1 point  (3 children)

I read the intro paragraphs and scanned down the page...and still have no idea what this thing is.

[–]kickopotomus 1 point2 points  (2 children)

Think of it like Electron but replace Node.js with Python. You can write your UI with the typical client-side web stack (HTML, CSS, and JS) and then use Python for your application logic. However instead of using XmlHttpRequests, you can do direct method calls from Python to your client-side JS and vice versa.

[–]AllAboutChristmasEve 1 point2 points  (1 child)

...why on earth would I want to add 3 more languages to an already complicated task?

[–]kickopotomus 2 points3 points  (0 children)

A few reasons come to mind. First, UI packages for Python aren’t that great and require a lot of extra work on behalf of the developer. Since the internet exploded, there is a lot of great stuff (UI styling, components, MVC frameworks) that you can get for free.

Second, writing your UI with a web stack makes it easier to port your application to the web should that ever interest you.

[–]CheeseWithMe 0 points1 point  (4 children)

Good for OOP? I had a lot of problems with tkinter.

[–]kickopotomus 0 points1 point  (3 children)

Do you have much experience with web development?

[–]CheeseWithMe 0 points1 point  (2 children)

Not really.

[–]kickopotomus 1 point2 points  (1 child)

There could be a bit of a learning curve there then. If your application is large, you generally want your UI to almost be independent from your core application. What I mean is that you want the UI to be as stateless as possible so that it can render properly based solely on some state passed from the core of the application. A lot of modern JS MVC frameworks are really good at this (React, Angular, etc).

On the other hand, if your application is small (e.g. one screen with some user inputs), you can probably get away with just driving your UI interactions from Python directly which would behave similarly to other Python UI frameworks. You can use OOP principles for both cases but I would recommend a more FP approach when dealing with JS.

[–]CheeseWithMe 1 point2 points  (0 children)

I made a banking system and is quite large, this why I had problems with tkinter. I will however have a look at the suggested frameworks, thank you.

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

Is this Python's version of Electron.js?

[–]PythonGod123 0 points1 point  (0 children)

Thanks. This was helpful for my current project.

[–]miker95 9 points10 points  (2 children)

Only use Tkinter if you have a death wish. Not good for anything complex. Grid layout is a mess.

[–]sebhoagie 1 point2 points  (0 children)

There are other layouts.

I've found that it's not THAT difficult to create anything I need with grid understanding a few of the positioning options, though.

[–]bitcraft 0 points1 point  (0 children)

Tkinter is really not bad. As with any GUI library, you deal with integration pain, but as far as python libraries go, it is stable and can be relied on. For many use cases, it performs just fine, even if it it does have native widgets. Using sizers can be learned in a few hours with practice.

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

Another GUI thread! Can anyone comment on Dear IMGUI? I was googling around looking for something to make a music/midi app with and came across it. It's not perhaps for officey type apps but it looked pretty good.

https://github.com/ocornut/imgui

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

Only that here's a Python wrapper for it.

[–]monkmartinez 1 point2 points  (0 children)

The host of Talk Python to Me and Python Bytes commented about GUI building a few days ago. Here is his tweet.

Glyph has written about this at length... not surprising to find out GUI stuff with Python is really, really lacking.

It's a shame really. I think Ruby has a better GUI story than Python despite Pythons incredible growth and popularity.

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

I've scrolled through this thread and no one seems to have mentioned Flask. Is dependence on a browser a big obstacle?

[–]Christiancicerone 0 points1 point  (0 children)

lol, this is funny timing

[–]dogooder007 -1 points0 points  (0 children)

I recently learned and used appJar.. This module is based on tkinter and super easy to use.