Using a webserver to replace GUI in python

I have a GUI project that I am about to start. The GUI requirement is simple (although not as easy as tkinter will suffice). So I need to use the python GUI toolkit (which would be wxpython if I need to go for the GUI). Now I am wondering why I can't use a simple web framework like cherry or bottle (sorry if I don't think that's correct. I'm new to server programming) and create html pages as GUI and use DOM (again, I think I am speaking correctly) instead of using wxpython to create a generic GUI. I can then write all my business logic and leave everything else with simple html rendering, where I have to spend less time formatting tables, creating buttons and forms, and taking care of sizers.

My question is, can anyone use a webserver python package like cherry or similar and avoid using graphical toolkit? Is this really helpful, or am I thinking about it upside down?

Benefit I expect:

I can use jquery to have a lot of functionality that can be time consuming to build with wxpython or some other GUI toolkit. For example, if I want the autocomplete function to be like jquery, there are many different stories in the GUI like wxpython. Also, many drag and drop functionality is easily handled in html.

+3


source to share


4 answers


Yes - it's just a web app instead of a native app.

Benefits include portability (assuming you can run python code in any setup - not sure what your application's purpose is) and also not dealing with disgusting TK layouts and events, etc.

However, you are also drastically changing the paradigm in which you program. This may not matter depending on your goals.

As for using the web framework:

In the simplest case, you can run a bunch of python scripts under CGI. Or you can 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 - it's easy to install and comes with a built-in server, so you don't have to set up an apache instance and mess with Proxying or mod_wsgi or all that goodness.



You should be DEFINED to go to w3c ( http://www.w3schools.com/ ) and color in the CSS / HTML if you haven't tagged the webpage for a while.

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

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

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

Enjoy!

+4


source


You're right, but don't roll .



+2


source


You think it is absolutely correct. There are tons of python frameworks out there, just pick the right one: pyramid, pylons, django are the most popular and widely used.

I suggest you transfer third party HTML / CSS for some professionals instead of doing it yourself. You may run into a lot of browser-specific things that will waste your time, but are obvious to a seasoned person.

+2


source


No, you are thinking about it correctly. HTML / CSS is very simple, it can provide fast development. Plus, python microstructures will make your business logic lightweight. This is a very direct sipmle path to take.

+1


source







All Articles