September 11, 2010

QML signals on PySide

I studied QML with signal-slot communication across to Python a bit.
If you are looking for examples in source code, see

The latter one use PySide but not QML, and has a preview video elsewhere in this blog. Here are my earlier experiments.

This video shows a very small application, consisting of two files - webview.qml and webview-qml.py.
The first three signals originate from QML and Python opens up a QMessageBox to display them, along by printing to stdout. The third signal will emit a fourth signal from Python to QML, with an url as a parameter, and the url will open inside a WebView.

This app evolves the idea a bit further. The HTML5 canvas demos seen in the video are not by me, they are from the web. There is a state machine working behind the scenes.

6 comments:

Unknown said...

Hi,

Excellent is all i can say. This is exactly the kind of information i am looking for. To learn the basics to work with QML in the frontend and python in the back end.

I am a relatively newbie python,django hobbyist since few months.But i am equally interested to learn PyQt/Pyside/QML. In short i want to learn to use python in making web, mobile and desktop applications. I work during the day as a sysadmin and IT tech support, basically in windows XP and also some linux and at home with Mac.

I simply want to say i have found your blog as the definitive sweet spot.I mean there are so many articles in your blog that i have been Googling around for some time.

Simply Great!Please keep on sharing your wonderful knowledge.

Kiitos Paljon
Everest, currently living in Finland.

Mikael said...

Thank you for feedback. ;)

I've been working on some more PySide in a private project, which will be available under BSD license shortly.

PySide definately needs more examples, and QML is a peculiar entity that has its own quirks. My examples are available at Gitorious and the PySide mailing list is a good place to get information.

Are you working on Linux or OSX?

Unknown said...

I am working at work mostly with Windows XP and a bit with Debian.At home i use Mac OSX 10.5. At work, i write some scripts to automate tasks, currently using batch scripts.

I have tried to use python with py2exe, but have been successful only very little. I would like to implement windows automation scripts with QML in the UI and python in the back. That is my ideal wish:) I found your example that parse the html file to MS Excel very interesting.
As they say, the best way is learning by doing by starting with simple things,initally i have tried do the follwing real example task, but with little success:

1. To remove an app in silent mode(adobe reader in my case) and restart PC.which i have managed to do in python using the MSIexec from the Windows registry.

2. After restart and login, START immediately the next line of the script to run and do a silent install adobe acrobat professional version from a given path and pick up the license key from the license file at the same time.(this i am not able to implement even with batch script(though i have figured it out a bit), but i would like eventually do with python).

3.Finally putting all these things in a UI with QML.

If you can help with a real example that would be really great, but even at least some suggestions with be very nice.

Also, can i install Qt Quik in Windows XP and implement it right away. If so, can i make QML UI speak with windows batch scripts if not with python? Can i also install Qt Quick and Pyside in MAC OSX without any problem and try to implement it?

Ohh, Sorry!, many questions now!

I would really appreciate if you could assist/help/suggest in any form.

I have already read some articles in your blog. It will be one of my favourite blogs now. YOU ROCK!:)

Many Many Thanks

Unknown said...

OOPS Sorry!, i posted it by a diffirent ID that i do not use so much! this was my other account in Gmail :) But i use Everest(thinkoutofthecubicle) as my id for most email conversations.

Mikael said...

I took this idea one step further and published a preview video along with the source. See the post from today.

Mikael said...

To many of your questions I do not have an answer, I am not familiar with automated Windows administration.

However the question you had about connecting backend services and QML.. I resorted to use plain QWebViews for MxController, but QML would be better. I am planning to write more about it.

Anyhow, connect signals from your UI to a the backend engine and you can work it out. Anything involving reboots is nasty. (:

There is a general need for PySide examples. Do you have any specific example you would like to see?