Question

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:

  • aquiring a lock on a Throttle object that I've made to handle the fair-usage policy of the service.
  • presenting the analyzed data in tables with links or buttons for retrieving or donwloading more related data.
  • presenting lists of related data and highlighting groups of items on mouse-over of any member of the group.
  • presenting text documents and providing automatic searching / highlighting of keywords / part-of-speech tagging using NLTK.
  • providing basic graphs and charts of various stats on the data.

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?

Was it helpful?

Solution

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:

  • Find/extend a suitable Qt model to manage your data
  • Use this data with standard/custom views in your PySide application
  • Develop web2py-based view to present the data in your webapp

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).

OTHER TIPS

In my opinion, you may be over-thinking this.

Basically you will have two methods of presenting data to the end-user;

1) Via a GUI

2) Via your HTML5-candy

Surely the limiting factor will be whatever limitations (if any), web2py/HTML5 place on presenting the data?

If I were writing such an app, which used both PySide and web2py to present the same data but using their respective methods (gui, web), I'd probably want to abstract the data to be presented in such a way that you can feed the same stream into either the GUI function(s) or the Web function(s), with each taking that in and using their respective methods to present the data.

Another alternative I can think of, is embedding a web view in your GUI presentation. Perhaps you can then dispense with a lot of concern of what widgets to use/avoid, merely by using your html5-candy in the embedded web view?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top