I want to create a web/browser-based GUI for a command-line python application. The goal is to make use of HTML/JS technologies to create this GUI. As the application itself, it needs to run on Linux and Windows, and the interface will be accessible only from localhost (not exposed to internet). The GUI will contain 5 to 10 pages.

I don't want a traditional desktop GUI that includes HTML/JS, but just a bunch of html files and some kind of controller between those and the application.

I also want to make use of asynchronous programming (ajax like) so I can load and print data in the GUI without refreshing the whole page. I'd probably use jQuery for that and a couple other things.

How would you recommend to design this? Performance is not the key here, I'm rather looking at reliability, portability and simplicity.

I'm thinking of using a lightweight python HTTP server / framework (like CherryPy) and maybe later a Python templating system (at the begining it will just be a couple pages).

I'm looking for ideas/recommendations how to build this, not for alternatives to browser/web-based GUI.

  • 2
    If its only going to run locally, simplify the whole thing and write the GUI in python. – GrandmasterB Oct 23 '13 at 18:59
  • 3
    Dont be intimidated by the idea of making a desktop gui. I find desktop gui's far easier to produce than HTML based interfaces. – GrandmasterB Oct 23 '13 at 19:14
  • 4
    Although I agree they have strong advantages, this is not what I want to achieve. And as you say, you find them easier to produce, but it's not my case. At last, I'm using javascript libs that provide things you don't find in Python GUI frameworks. – ack__ Oct 23 '13 at 19:27
  • 2
    Sharing your research helps everyone. Tell us what you've tried and why it didn’t meet your needs. This demonstrates that you’ve taken the time to try to help yourself, it saves us from reiterating obvious answers, and most of all it helps you get a more specific and relevant answer. Also see How to Ask – gnat Oct 23 '13 at 21:18
  • 2
    Again it's not about being intimidated, I have developped many desktop GUI in the past, using Gtk, nCurses, WinForms, .Net and I even made a GUI in x86 assembler using radasm. It's just that it doesn't fit my needs here. – ack__ Oct 24 '13 at 17:59

I am currently trying to do pretty much the same thing. Looks like Python has a server (SimpleHTTPServer) so I trying to make an AngularJS web application that will be interacting with Python server.

Potentially there is a cefpython project that would allow distributing Python applications as standalone programs.

  • I saw negative comments about SimpleHTTPServer here on SO, I'd suggest looking for another server (I will probably go for CherryPy but there are many others available). Have you tried CEFPython ? I'm afraid it does not provide the most up-to-date Chromium functionalities but I might be wrong. Using a real browser guarantees a real support, maintenance and active development. – ack__ Oct 23 '13 at 21:09
  • @ack__ I am currently playing with SimpleHTTPServer - I don't think there are any problems if all you need is a single-session server. I am trying to make do only with the staff from default library to make it easier to install on users systems. I have not yet gotten to a point when I need cefpython - but it should be doable to update CEF there if need be. – Eugene Oct 24 '13 at 16:09
  • Ok, and which CEF version did you use ? I'm not concerned about the multi-process part, rather by the differences between the Webkit API and Chromium-content API, if any. – ack__ Oct 24 '13 at 19:23
  • You can just grab binaries from their site. They have a CEFClient app you can use to seed your application. I've also seen a couple of CEF-based product, though they use node.js - github.com/adobe/brackets-shell and github.com/rogerwang/node-webkit. brackets-shell runs node in a separate process while node-webkit (last time I checked) was doing that in-process. I wonder how hard would it be to replace node with Python app. – Eugene Oct 24 '13 at 20:25

Your stated criteria are:

  • Reliability
  • Portability
  • Simplicty

If thats the case, a desktop app is the way to go. There is no need to throw a web server into the mix. That will just complicate matters for no actual gain.

Based on the OP's edit - that an HTML-based interface is desired - a possible route might be node-webkit. This will allow you to create a desktop application that runs on Windows, Linux, and Mac using HTML & Javascript. It takes an approach somewhat similar to PhoneGap (with the exception that the same embedded browser is used on all platforms). Node is used to power the Javascript, which provides access to a large number of libraries. And you have access to the underlying system, allowing you to run the Python-based command line program.

  • 2
    I'd argue they'd be just has easy, not easier. It's not going to be more reliable because he's not as familiar with pytk whatever. He never said anything about command line. There is nothing LESS portable about a local server. Again if he's making his own controls for example, it will be much harder to develop with an application gui. – BeardedO Oct 23 '13 at 20:21
  • You get a lot of benefits by doing our UI in HTML - that's why Steam, Spotify and others support Chromium Embedded Framework. Adobe Brackets is one interesting example - they have node.js running as a separate process alongside CEF UI process. – Eugene Oct 23 '13 at 20:24
  • Yes the main benefit is flexibility. You have much less resistance for example to developing new controls, reactive layouts, dynamic page layouts. – BeardedO Oct 23 '13 at 20:27
  • 3
    Just to clarify - by doing UI in HTML you get cross-platform modern UI with heavily optimized support for font rendering, GPU-accelerated transitions, etc. There is a huge number of well-maintained libraries and frameworks, tools and such. E.g. one irritating problem I face with doing UI in Java is Retina Macs support. No such problem when running in browsers. – Eugene Oct 23 '13 at 20:28
  • 1
    GrandmasterB I am not saying you can't do what browser does. You can. But browsers already have it implemented and heavily optimized (competition is fierce there). – Eugene Oct 24 '13 at 16:05

Options for Python web apps:

  • django
  • web.py
  • werkzeug (w/ or w/o flask)
  • twisted
  • cherry.py
  • raw wsgi
  • raw simplehttpserver

Any one of these will work. As far as how you build an app; most of these frameworks have online tutorials. Just follow along and adapt it to fit your needs.

Not the answer you're looking for? Browse other questions tagged or ask your own question.