Python GUI Django – Using a Web Framework as Python GUI

djangoguipython

If I built some useful piece of python code to e.g. scrape a website or to calculate something big, at some point I might want to add a GUI to my project. For this I could use Tk, Qt, Pygame or any python graphic/GUI framework.

Now I also want this tool to be usable by clients without the need for a python installation. Of course I could use something like py2Exe or py2Dmg. But wouldn't it be cooler to use a python-based web framework for this? Something like Django or Pyramid.

What would be the drawbacks of doing this? Can I just use the framework to execute my code on a server and only return the result? Or will this get tricky when there are multiple users?

Best Answer

Making a web UI will make it easier to extend, and update. But it will be another layer of complexity for you to deal with.

I recommend looking at the lightweight http://webpy.org/

    urls = (
        '/hello', 'hello'
    )
    app = web.application(urls, globals())

    class hello:        
        def POST(self, name):
            #call your script here

You can call this with POST localhost/hello

Benefits:

  • Portability: no installers, can access from anywhere.

  • Extensibility: easyer to modify the UI (if you know HTML/CSS) and easier to re-deploy your application.

drawbacks:

  • Complexity: you will need to understand HTML, CSS request/response etc, set up a webserver or shared hosting,

  • Security: don't make it public.

Related Topic