6 ms·
I have been developing in HTML/Python for a while now. This works wonderfully. You just need to put all your business logic in Python, use PyQt to run all the p
by Loic 9y ago
I have been developing in HTML/Python for a while now. This works wonderfully. You just need to put all your business logic in Python, use PyQt to run all the platform specific code like file dialogs, printing, etc. but keep the main interface with React. You do that by having a webview with a service object being the bridge between Python and the JS view[0]. If you are a bit careful with the amount of information going through the bridge, you get very good performance (the page[0] is linking to some small screencasts/videos).
With this approach, I have the best of both worlds for my small shop where development time is constrained. The really good part is that I can reuse for the desktop application work done for the website both the front-end and the backend which is written in Python for all the scientific code.
[0]: https://www.ceondo.com/ecte/2016/04/chemeo-studio-explore/ https://www.ceondo.com/ecte/2016/04/chemeo-studio-explore/
- makecheck 9y agoI’m curious, does that work with sandboxing on the Mac? One of the things that Mac file dialogs do is implicitly expand the sandbox for the process that opens the file dialog. Is the other side of the bridge still able to access the selected path?
- danieldk 9y agoI don’t know about this project, but I am using Qt in a C++ application, and this certainly works with macOS sandboxing. Qt will just open a native macOS dialog that will link files into the sandbox. From there you can pass the path returned by the dialog to sandboxing-oblivious C++ code. As a side note: Flatpaks in Linux use a similar mechanism for sandboxed applications (in Flatpak these are called ‘portals’).
- Loic 9y agoI am sorry, I am developing mostly for boring big companies and my experience is only with Linux (because I develop with) and Windows (because my customers pay me to have the stuff available on it). Practically, this is just a PyQt application with a webview, so, it should work with PyInstaller.
- joshvm 9y agoI'm assuming this is a desktop app, not running off a server. How do you get round the problem of distributing Python with every install? Or do you just accept it? I love Qt in C++ because most of the time the code just recompiles between Mac/Windows/Linux. I've shied away from writing GUIs in Python because deploying - to the point where a non-technical user can run the program - always ends up being hacky.
- infinite8s 9y agoThat is literally the point of the original post.
- joshvm 9y agoIt's not clear that the poster I replied to is using fbs - I'm assuming not. But in any case fbs doesn't mention some useful bits. Does freezing work reliably with all packages (is it different to the canonical packages for freezing Python binaries)? In my experience some libraries just wouldn't freeze - matplotlib was a pain. How big are the output binaries? The Qt libraries are large enough without chucking in Python as well (even a minimal install is quite big).
- ktpsns 9y agoIndeed, Qt is a great basis for developing a modern application with a HTML frontend. This is because Qt bundles a modern browser engine (was WebKit, nowadays Chrome) and has JavaScript support at various places (https://doc.qt.io/qt-5.10/topics-scripting.html https://doc.qt.io/qt-5.10/topics-scripting.html). All this makes Qt a first citizen in the Rich user interface world where the players have names like Vue, React and Angular today. Btw, don't forget we had desktop toolkits with rich user interfaces already in the 2000s. In that time, Java was the big player. Swing was already superseded by Eclipse's SWT and HTML panels were already ubiquitous.
- faldzip 9y agoBut why you would want to use React, Angular etc. while you can just do it in C++ and QtQuick and have many times better performance so better user experience and for example Servo browser engine rendering benchmark animation took me 1/2 loc to reproduce in QtQuick...
- chrisgd 9y agoForgive my naivete, this is a python application that interfaces with the user through QT. You still had to build a react front-end separately though?
- Loic 9y agoYes, the react front-end is the interactive view so to speak. In my first comment, you have link to some videos where it shows the interface and you do not need to be a genius to see the HTML look of the interface.
- faldzip 9y agoWait, what? You are using python, to use Qt, to open a WebView to run HTML/JS app... Why can't you just use Qt directly? I've done some test on an embedded device powered by i.MX6 and HTML5 animation in WebEngineView gives 8fps, while the same animation purely in QtQuick gives stable 60fps... That's a K.O. I guess...