Background: I have a desktop app that I've written in Python27x that uses wxPython
for the UI and requests
with xml.etree.ElementTree
to retrieve open data from a RESTful service and present the data in meaningful ways to the user.
I am currently re-writing my app using PySide
. I am fairly certain that I can present my data-candy in HTML5
and I would eventually like to provide a web-app using web2py
and JavaScript
.
The PySide
and web2py
versions both need to support:
Throttle
object that I've made to handle the fair-usage policy of the service.NLTK
.Question: Given what I've told you about my app, and assuming web2py
and HTML5
can meet my user-interface / presentation needs, what steps can I take / widgets should I use in making my PySide
desktop app to maximize re-use when porting over to web2py
? What should I be sure to avoid when writing the desktop version?
You need to separate your data and data-processing from the user interface. Qt (and thus PySide) has a very strong focus on this Model-View approach (see e.g. http://qt-project.org/doc/qt-4.8/modelview.html), and provides models to organize your data, and views to present the data. Within Qt, this approach allows to easily use multiple views on the same data sets, without having to worry about how to get the data in the view.
Admittedly, the Qt models take some time to get used to, but the aforementioned tutorial should give you some pointers and references to get you started. In your case, I would go for the following approach:
I'm not familiar with web2py, so I can't assess how hard/easy this last step would be. However, I can recommend to invest some time (if you have it) in getting to know the Qt Model-View framework, as it can save you huge amounts of time in the future (at least, in my experience).