jython

From Qt Labs

Jump to: navigation, search
Qt Jambi Jython bindings
Project logo: QtJambiLogo200.png
Platforms: Linux, Windows, Mac OS X
Qt version: Requires Qt Jambi
License: Trolltech GPL
Depends on: Jython
   Jambi Qt Jambi Jython bindings blogs
Subversion:
svn://labs.trolltech.com/svn/qtjambi/jython




[edit] Qt Jambi Jython Bindings

As Håvard pointed out in his blog some time ago, Qt Jambi is really a door opener into a number of other languages. Jython for instance, the python implementation done in Java. By just putting the qtjambi.jar files into classpath one can write this code in Jython:

from com.trolltech.qt.gui import *

QApplication.initialize([])

hello = QPushButton("Hello Jython!")
hello.show()

QApplication.exec()

This is pretty neat by itself, but it usually comes to a problem with signals and slots, as we implement these based on reflection of method names. Very few of these scripting solutions produce reflectable methods that we can use, so we need to bridge this gap. This project provides a few classes that solves this problem for jython. Enjoy!

[edit] Building

Run ant, it should automatically pick up the build.xml build description and build a qtjambi-jython.jar file in the current directory. Please note that both Qt Jambi libraries and jython libraries must be in the local path when compiling. It should look something like this:

C:\qtjambi\jython>ant

Buildfile: build.xml

qtjambi-jython.jar:
   [mkdir] Created dir: C:\qtjambi\jython\out
   [javac] Compiling 13 source files to C:\qtjambi\jython\out
   [javac] Note: Some input files use unchecked or unsafe operations.
   [javac] Note: Recompile with -Xlint:unchecked for details.
     [jar] Building jar: C:\qtjambi\jython\qtjambi-jython.jar
  [delete] Deleting directory C:\qtjambi\jython\out

BUILD SUCCESSFUL

Total time: 2 seconds

C:\qtjambi\jython>

[edit] Running the examples

Be sure that Qt Jambi and jython is set up in the environment and run the minimalist demo:

> jython mybutton.py

or

> jython paint.py

[edit] Known Issue: Accidental private constructor...

Qt Jambi classes, like QWidget have a special constructor that takes a QPrivateConstructor. This constructor is protected and not callable in Java unless the user does something nasty and should he do, it will result in an exception. The problem is that jython won't have the option of selecting between

 QWidget(QWidget parent)

and

 QWidget(QPrivateConstructor ctor)

The result of this is that the code:

class Fail(QWidget):
   def __init__(self, parent):
       QWidget.__init__(self, parent)

f1 = Fail(aParent)
f2 = Fail(None)

Will fail in the case f2 because parent is None. I don't have a good solution for this just yet, but I'll see if something comes to mind...


[edit] Latest 5 Qt Jambi Blogs

eskil
Qt
Qt Jambi
News
Contributors
Git
Posted by eskil
 in Qt, Qt Jambi, News, Contributors, Git
 on Monday, May 11, 2009 @ 12:06

It’s taken a little longer than expected, but the nice and polished Qt Jambi 4.5.0_01 packages are finally ready for download on Qt Software’s server. As usual, there are both source and binary packages available, but to match the new licensing of Qt, the GPL packages have been replaced by LGPL packages this time around. […]

» 10 comments «
Tor Arne Vestbø
Qt
KDE
Qt Jambi
Labs
News
QtCreator
 in Qt, KDE, Qt Jambi, Labs, News, QtCreator
 on Monday, May 11, 2009 @ 12:00

With the announcement back in January of Qt going LGPL there was a small piece of information that slipped though the cracks of the wider news reporting, namely the fact that we were planing on opening up our repositories and development model. The first major phase of this work is now complete, and we are […]

» 22 comments «
eskil
Qt Jambi
Posted by eskil
 in Qt Jambi
 on Wednesday, July 23, 2008 @ 14:11

A while back we announced the research project Qt Jambi AWT Bridge which allows you to mix AWT/Swing components and Qt widgets in the same window on Windows and Linux.
There were a few issues with the original version. The main problems were the fact that your window would be deactivated by the window manager […]

» No comments «
gunnar
Uncategorized
Qt
Qt Jambi
WebKit
Qt Concurrent
Graphics View
Patternist
Posted by gunnar
 in Uncategorized, Qt, Qt Jambi, WebKit, Qt Concurrent, Graphics View, Patternist
 on Tuesday, June 10, 2008 @ 09:13

So the time is finally here. Qt 4.4.0 was released a few weeks ago and as promised Qt Jambi is right behind. A lot of effort has gone into this one, in addition to supporting all the new Qt features, like Phonon, Webkit, Widgets in Graphics View, XQuery and Qt Concurrent, we also have a […]

» 2 comments «
eskil
Qt
Qt Jambi
Posted by eskil
 in Qt, Qt Jambi
 on Wednesday, March 12, 2008 @ 13:03

The Qt 4.4 beta was released on February 26th, and, true to form, the corresponding Qt Jambi release comes a couple of weeks later.
In honor of the 4.4 release, we’d like to go through some of the new features you should look out for.
WebKit integration
WebKit is an open source web browser engine which is […]

» 3 comments «


© 2008 Nokia Corporation and/or its subsidiaries. Nokia, Qt and their respective logos are trademarks of Nokia Corporation in Finland and/or other countries worldwide.
All other trademarks are property of their respective owners.