Tutorial: Custom Widgets using PyQt

Everyone who has programmed an application knows that sometimes you create a gadget that can be reused in other situations, and that code reuse is good. In the specific case of GUI applications, often what you would want to reuse is a widget. I wrote a short tutorial explaining how to create easy-to-reuse custom widgets using PyQt.

Dot Categories: 

Comments

by Roey Katz (not verified)

Is there a chance we'll see PyKDE in Debian SID or KDE anytime soon?
I'd like to get started with it but it has issues on my system.

- Roey (FilthyMonkey / JelliedMisery / CongealedHappiness)
remove turtles from my email to reply.

by Simon Edwards (not verified)

Once PyKDE is up to date with PyQt and SIP (the binding generator), I intend to import and maintain a copy of PyQt and PyKDE in kde-bindings/KDE CVS. The idea is help make it a lot easier for packages to package and distribute it with their normal KDE packages.

The situation will improve soon. :-)

--
Simon

by Roey Katz (not verified)

Neat! Thanks!!

by jameth (not verified)

Is there any idea of the time-table on this, yet?

I was just starting on a new project, but since I am running 3.2 now it seems impossible to use Python. I've been reading the PyKDE lists, but they're kinda sparse on details, besides that it is coming, and that an alpha may be floating about. If there at least a way to get the alpha easily?

by Roberto Alsina (not verified)

It should be sometime this month, that´s my guess. The author is a bit of a perfectionist :-)

by Richard (not verified)

PyKDE has been waiting for someone to volunteer to maintain a KDE "copy" for ages.

Simon, you rock!

by Jonas (not verified)

What happened to QtRuby? I toyed a bit with the language and immediately grew rather fond of it. I think it's OO-ness would suit Qt perfectly. The Qt bindings Google can find are for Qt 2.x, but the KDE Developer site speaks of something called the SMOKE Bindings that should be automatically generated for any version. Where can I find more information about this? Is it usable?

by Richard Dale (not verified)

Yes, QtRuby and Korundum (the kde bindings) are in the kdebindings module. It is a completely different project to the original Ruby/Qt which was generated by the SWIG tool. The new version uses the Smoke library as you've found, and that is automatically generated as part of the kdebindings configure.

It is certainly usable, and is part of KDE 3.2 - and some bugs have been fixed, along with DCOP support added for the 3.2.2 release. QtRuby includes an rbuic tool so you can use Qt Designer .ui files to generate ruby code. It features a very complete coverage of the Qt/KDE apis (950 classes, 29000 methods), you can override all the virtual methods, use operator methods and so on.

Alex Kellett has set up a site on RubyForge where you should be able to download it as packages. Otherwise, checkout kdebindings from the HEAD to get the latest version.

I've attach qt scribble from the book 'Programming in Qt' as an example.

-- Richard

by Matthew Feinberg (not verified)

I'm interested in writing bindings for PHP 5 using Smoke, but I can't find any decent documentation. Do you know of any decent documentation on how to begin using Smoke to write bindings for a language?

by Richard Moore (not verified)

I'd be interested in docs on this too.

by Richard Dale (not verified)

I asked Ian Geiser this:
> PS: I did buy a 'JavaScript the Definitive Guide' to try and see if
> KJSEmbed could be used with Smoke, and I couldn't work it out - I've never
> done any javascript. Does it have a default "I can't find the method you're
> calling, and I'll divert to a default method" feature. In ruby, you have a
> method called method_missing(), and any calls you make to an instance which
> doesn't have a method defined gets diverted to method_missing().

He replied:
"I'm not sure I follow... If you ask in the kjsembed list, or on irc in #kaxul
rich moore might have an answer."

So I'm not even sure it could be used by KJSEmbed, but I think I need try and explain exactly what it does do and how it works. 'A moc on steroids' is probably the simplest description.

by Richard Dale (not verified)

Germain Garand has written a technical document which can be found on the PerlQt site I believe. But I would say it's still a long way from being straightforward to understand. I'm thinking of doing a blog on the kdedevelopers.org site about kdebindings, and Smoke in particular.