Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using web-server to substitute for GUI in python

I have a GUI project which I am about to start. GUI requirement is simple ( though not as simple as tkinter will suffice). So I need to use a GUI toolkit for python (which will be wxpython if I have to go for GUI). Now I am thinking, why cannot I use simple web-framework such as cherrypy or bottlepy (sorry, if I am not thinking right. I am newbie to server-side programming) and create html pages as my graphical interface and use DOM ( again,I guess, I am speaking right) rather than using wxpython to create the overall GUI. I can then, write all of my business logic and leave the rest to simple html rendering where I have to spend less time in formatting tables, creating buttons and forms and worrying about the sizers.

My question is: Can somebody use web-server python package such as cherrypy or similar and get-away from using graphical toolkit? Is it really beneficial or am I thinking this thing upside down?

The benefit I am expecting:

I can use jquery to have many features which might take lot of time to create with wxpython or other GUI toolkit. For example, if I want to have autocomplete feature as similar to jquery, it is whole lot of different story in GUI toolkit like wxpython. And also, lot of drag and drop features are easy in html.

like image 447
Jack_of_All_Trades Avatar asked Apr 04 '12 15:04

Jack_of_All_Trades


1 Answers

Yes -- this is then just a web application instead of a native application.

Advantages include portability (assuming you can run the python code on any setup -- not sure what your application's purpose is) and not dealing with pesky layout issues and TK events and such.

However, you are also dramatically changing the paradigm in which you are programming. Depending on your goals, this may not matter.

As for using a web-framework:

In the simplest case, you could run a set of python scripts under CGI. Or you could get an MVC framework with a database abstraction layer (DAL/ORM) like django or web2py.

If you want to get up and running quickly I would suggest web2py -- simple to install and comes with a built-in server so you don't need to set up an apache instance and mess with Proxying or mod_wsgi or all that goodness.

You should DEFINITELY go to w3c ( http://www.w3schools.com/ ) and brush up on CSS/HTML if you haven't marked up a webpage in a while.

But yes -- web2py will allow you to run any python modules/packages, though you will have to learn to deal with the client-server model and realize that clientside events must be handled in javascript, whereas python code can only be executed on the server and then only from a request URI.

In short, there will be some 'glue' code, but that's what web2py (IMHO) excels at.

http://web2py.com https://www.djangoproject.com/ http://wiki.python.org/moin/CgiScripts

Enjoy!

like image 88
Kasapo Avatar answered Oct 21 '22 04:10

Kasapo