Jack_of_All_Trades
Jack_of_All_Trades

Reputation: 11468

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.

Upvotes: 5

Views: 7648

Answers (4)

Maksym Polshcha
Maksym Polshcha

Reputation: 18358

You think absolutely right. There are loads of python-based frameworks, just choose the right one: pyramid, pylons, django are the most popular and widely-used.

I suggest you to outsource HTML/CSS slicing to some professional instead of doing it by yourself. You can face up quite a lot of browser-specific things, which will waste your time, but obvious for an experienced person.

Upvotes: 2

Kasapo
Kasapo

Reputation: 5374

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!

Upvotes: 4

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 798456

You're correct, but don't roll your own.

Upvotes: 2

dm03514
dm03514

Reputation: 55922

No, you are thinking of this correctly. HTML/CSS is very simple it can lend to rapid development. Additionally python micro frameworks will make creating your business logic a breeze. This is a very straight forward sipmle route to take.

Upvotes: 1

Related Questions