Live data from Hacker News

PyQt5 Tutorial: Create a Python GUI in 2018

build-system.fman.io

91–100 of 211 posts

Re: PyQt5 Tutorial: Create a Python GUI in 2018

#91
post #2

Just to note, there are official [1] Python bindings available for Qt and this can usually be installed with `pip install pyside2` . [1] https://www.qt.io/qt-for-python

We use (and pay for) PyQt5 at work. Do you have experience with both and if so can you comment on any tangible differences?

If possible, I would rather get behind the "official" one since we also already pay for commercial Qt licenses.

Re: PyQt5 Tutorial: Create a Python GUI in 2018

#92
post #67

I'd like to take this time to introduce a project I have been working on. I'm using it in production currently. https://github.com/qmlnet/qmlnet It is a perfect balance between QML and .NET. The tech stack splits along the perfect line. QML for UI, .NET for business logic. I'd be glad to answer any questions.

Do you know if it is working fine with F#? Will possibly try it as I learn F# (on Linux).

Re: PyQt5 Tutorial: Create a Python GUI in 2018

#93
post #86

In commercial settings, I wonder how hard it really is to package this up? I've been building/distributing fully cython'd installers for a while (to sort-of hide the source as well as make a convenient package)... I wonder if that would be harder with PyQt for some reason? "In the Python world, the process of turning source code into a self-contained executable is called freezing. Although there are many libraries th…

I can't speak for fbs (never used it), but the way these things usually work (pyinstaller et al ) is by compiling everything to .pyc or .pyd and/or pack it up with the python runtime in an executable. It's probably not too hard to extract the original source, but it would be enough to deter a casual observer. The problems with packaging PyQt usually boil down to module discovery, because the import machinery is lever…

Ok, thanks for the info! Yeah the pyinstaller, etc. experiences I've had were trivial to decompile from pyc back to py so for "hide the source" we found that Cython takes it to the next level.

I wonder what fbs does in this case that handles the PyQt import stuff so well.

Re: PyQt5 Tutorial: Create a Python GUI in 2018

#94
post #4

I like the tutorial, but I don't know why you would use PyQt these days. Tkinter is more permissive and has wrappers like appJar which make it disgustingly easy to put together a quick, ugly GUI. If you're building a desktop app that needs to really look good and be fast, why are you using Python?

> If you're building a desktop app that needs to really look good and be fast, why are you using Python? Why not? For an app to feel fast, you need to make it responsive and non-blocking. You can easily make apps with Python and Qt or Gtk that start instantly and never seem to hang. Discipline when it comes to not running things on the main thread, using proper async techniques etc. is more important than the number…

Agreed! Although I use SWIG on my job, pybind11[0] is a nice alternative that I've been looking at.

[0] https://github.com/pybind/pybind11

Re: PyQt5 Tutorial: Create a Python GUI in 2018

#95
post #43
post #28

I've been using wxPython for many years, and it works very well. What are the advantages of PyQT over wxPython? Anyone experienced both 'worlds' in a non-trivial application?

1. wxPython has inconsistent looks and layouts between platforms and monitor resolutions (or DPI). For example, on PlayOnLinux GUI app I cannot click an "OK" button while using Surface Pro because the button is hidden outside of the window. 2. QML is an amazing language. It is modern, declarative and reactive but still very simple to use. Personally I don't want to go back to the traditional GUI coding styles after e…

The article doesn't mention QML at all. Is it possible to use it with Python?

Re: PyQt5 Tutorial: Create a Python GUI in 2018

#96

This is a case where the "in 2018" in the title is very helpful, as Googling information about Python and Qt usually returns something dreadfully out of date. (and as other comments note, there are lots of new companion tools/competitors like Electron)

The API still looks messy and unpythonic though, sadly. Look at the basic hello world example. Why do I need to pass QApplication an empty array? Why am I calling a method ending with _ to launch the program? And the fact the label magically attaches to the app through some side effect is also confusing.

Does anyone know if there's any good shim/wrapper around PyQt that has a better API?

Re: PyQt5 Tutorial: Create a Python GUI in 2018

#98
post #82
post #29

Earlier quoted context omitted.

Flexibility to do what, though? I'm genuinely curious: what doesn't Qt offer that a desktop app might need?

Why do you think programmers of all people are heavily migrating to Electron based editors like VS Code? Because they like using slow and bloated apps? And I'm not talking only of web programmers, I know plenty of C++ programmers who moved to VS Code.

Because VSCode is a good enough program that fits their needs and the alternative that they were using was Visual Studio? How does that say anything about native frameworks?

Re: PyQt5 Tutorial: Create a Python GUI in 2018

#99
post #34

Anybody know if it's easy to reverse engineer or strip parts of the application when deploying PyQt5 apps? Or do you need extra measures to obfuscate the code to protect certain logic?

I've never tried it but given Python's interpreted nature, it is likely pretty easy unless you use an obfuscator. Note that that's true for Java .class files as well. I was really surprised once when I tried to decompile one of my own that I had thought would be safe. You get near-perfect accuracy.

>Note that that's true for Java .class files as well.

Yes. There was a free third-party Java decompiler called JAD some year ago, for example.

Re: PyQt5 Tutorial: Create a Python GUI in 2018

#100
post #90
post #85

I'm sometimes considering porting the UI of a relatively complex management app I wrote sometime ago for a small company, from Ext JS to a Python-flavored traditional GUI framework like PyQt (it would essentially become a desktop app powered by an already Python-based backend, which wouldn't be really a problem deployment-wise, as it's an internal-facing app). I think there would be some benefits, but what stops me i…

You can do all those (sorting, filtering, etc) in Qt as well using the Model/View components. There is a bit of a learning curve to understand the "Qt way of doing MVC", but after that it works fine. At work we use Qt5 with both C++ and Python (through PyQt) and I love it.

Thanks! What I'd like to know more specifically is if there are some ready-made components already packing a lot of these functionalities without needing too much custom logic, or you need to roll out your own from low-level ones?
Post reply on HN