18

This question is more about methodology.

I want to create a Python desktop application, but I don't want its GUI to be like tkinter or like PyQt. I prefer to have a beautiful and modern client GUI like Bootstrap.

Is there any existing API for creating such applications in Python?

If not: does it sound a sane workround to use some Python server (like Django or like web2py), and to start a new server each time the application is launched by a user, just for enabling the application core to be in Python and the client to be in HTML? Does anyone work this way?

SomethingSomething
  • 11,491
  • 17
  • 68
  • 126
  • Make a website using Django or flask using Bootstrap, have it running ...? – taesu Sep 09 '15 at 15:11
  • I'm not sure I understand what you say... I consider the option of using some Python HTTP server, but I understand it is not an optimal solution. I prefer something without a real HTTP server, like in node.js, in which you can write desktop applications with HTML UI – SomethingSomething Sep 09 '15 at 15:13
  • 1
    so then, why not just use javascript and bootstrap, without python? – taesu Sep 09 '15 at 15:29
  • I don't want to pay efforts on studying the JS API for interacting with the system (i.e. environment variables, files, argv, etc.) – SomethingSomething Sep 09 '15 at 18:17
  • Possible duplicate of [How to use Python and HTML to build a desktop software?](https://stackoverflow.com/questions/16127876/how-to-use-python-and-html-to-build-a-desktop-software) – Anderson Green Jun 04 '18 at 20:44

2 Answers2

11

Use PyQt or PySide 2, Qt WebEngine and Qt's builtin support for hosting HTML applications:

http://doc.qt.io/qt-5/qtwebchannel-index.html

The general architecture is a SPA (Single Page Application) running from local HTML and Javascript content bundled with your app – no need for bundling in a web server.

For anything complicated (like bypassing cross origin issues), use the Qt WebChannel to message to functionality built on the Python side.

This is basically the same architecture that Cordova uses.

Now, whether you should build an application this way (cough QML cough) is a completely different topic.

David K. Hess
  • 16,632
  • 2
  • 49
  • 73
5

There is value in having a local server that does your GUI work, whether this applies in your case depends very much on the requirements of the app. Most apps I write tend to have a habit of ending up to be multi-user and hosted, so for me it makes absolute sense starting of like this.

If you are going down this route also have a look at http://brython.info/, having the same like languages across everything makes brain context switching less of an 'overhead' (pardon the pun).