Learn KDE Programming with PyQt
Friday, 9 December 2005 | Jriddell
Sebastian Kügler has written a new PyQt tutorial. Python is the perfect language to start learning programming with and this tutorial takes you through making a basic Qt based program. He also shows how pyuic from PyKDE Extensions makes it possible to use Qt Designer with Python. Some wise words to new programmers from the tutorial, "use the examples and try to change things, play around with them, this is the best way to get comfortable".
Comments:
I like PyQt - Yuko - 2005-12-09
I like PyQT but there is no well integrated in KDevelop. You have to transform .ui files from Qt Designer to pyqt , to make this you have to use pyuic to make this pyqt file and then edit in KDevelop. You edit this file and add python code for buttons for example. The problem is when you change the ui file , to add other button for example , you have to compile this file to a pyqt file and write back all the buttons code that you make in python. I think if in KDevelop you can make the .ui file , the code of the buttons in python in other file and then if you press compile / execute file , KDevelop can join all code in one file . If the .ui file change don't change all code and you don't have to write back all python code.
Re: I like PyQt - Boudewijn Rempt - 2005-12-09
No! You do not, ever, edit the files generated by pyuic, uic, juic or any other .ui compiler. Include or import the file and subclass the widget you've created, or use it directly, but don't change.ui file by hand. And if you want an ide specifically tailored to PyQt try Eric3 (or BlackAdder, but that's commercial and not much better than Eric3).
Re: I like PyQt - Simon Edwards - 2005-12-09
Just to expland a little bit on what Boudewijn said. You use pyuic to create your class from your .ui, then you create a subclass of that widget. In the subclass you can add all of the extra behavior, methods, event handlers etc that you need. You application should then just use the subclass. The widget class from pyuic can now be regenerated as much as you like without wiping out your handmade code. As for invoking pyuic by hand, have a look at http://www.simonzone.com/software/pykdeextensions/ . This provides extra support for KDE applications. Things like handling installation, i18n, and bunch of other odds and ends. The interesting thing is that it also lets you directly import .ui files into python code without having to manually run pyuic everytime that your .ui file changes. You can just change and save your .ui file in Designer, then start your application up again. -- Simon
Re: I like PyQt - Yuko - 2005-12-09
>>No! You do not, ever, edit the files generated by pyuic, uic, juic or any other .ui compiler. Include or import the file >>and subclass the widget you've created,or use it directly, but don't change.ui file by hand. How to do this?
Re: I like PyQt - Boudewijn Rempt - 2005-12-09
See http://www.opendocspublishing.com/pyqt/index.lxp?lxpwrap=x4274%2ehtm for an in-depth discussion.
Re: I like PyQt - Marcio - 2005-12-09
look at the example "gui coding sucks" in the tutorial.
Kudos - Pascal Klein - 2005-12-09
For someone like me who has just started to diveintopython.org, this is really very much appreciated. I have often marvelled at some of the powers that Qt offers and since I am starting to have another look at Python, this is definitely something that appeals to me and could allow me to make something useful from the skills I learn. Thanks for this. Kudos. :) ~Pascal
Is PyKDE functional right now? - mikeyd - 2005-12-09
Gentoo won't install it with anything approaching a modern version of kdelibs installed.
Re: Is PyKDE functional right now? - Roberto Alsina - 2005-12-09
Try the PyKDE from kdebindings, I think that one's supposed to work. I suspect you get a slightly older PyKDE that works with a newer KDE, if that makes any sense ;-)
Re: Is PyKDE functional right now? - mikeyd - 2005-12-09
That only seems to include the dcop bindings, not the parts that let you make a full application (with widgets etc.)
Re: Is PyKDE functional right now? - Richard Dale - 2005-12-09
Look under kdebindings/python
Re: Is PyKDE functional right now? - Carlo - 2005-12-10
There's no kdebindings package anymore and I was a bit lazy fixing the mess with kdebindings including sip, pyqt and pykde. http://packages.gentoo.org/search/?sstring=pykde
Re: Is PyKDE functional right now? - Pingveno - 2005-12-13
dev-python/pykde dev-python/PyQt
Re: Is PyKDE functional right now? - Paul Boddie - 2005-12-09
I had no real luck with the kdebindings version of PyKDE (at least for KDE 3.4). However, recent PyKDE snapshots do work, although some additional patches may be required. I recommend looking at the Ubuntu source packages (which you can find using the package browser at http://packages.ubuntu.com) since some of the necessary patches are included in those archives; look out for python2.4-kde and python2.4-qt along with various sip packages.
Re: Is PyKDE functional right now? - hds - 2005-12-12
i compiled PyKDE from riverbank: http://www.river-bank.demon.co.uk/download/PyKDE2/PyKDE-snapshot20051013.tar.gz works fine with KDE 3.4 and 3.5 on gentoo.
Re: Is PyKDE functional right now? - Daniel Ross - 2006-01-22
There's a masked, but not blocked, version at kde-base/pykde.
OT LSB Desktop released (no libqt) - Tiziano - 2005-12-09
LinuxBase has released the first draft of desktop modules http://www.linuxbase.org/spec/book/Desktop/Desktop.html
Re: OT LSB Desktop released (no libqt) - Olaf Jan Schmidt - 2005-12-09
Hi Tiziano! I can assure you that Qt4 will be a part of 3.0. The LSB Steering Comittee is currently in the process of changing the license criteria to allow for this, and the discussion how to exactly phrase the new criteria has not been finalized yet. For this reason, Qt4 was missing in LSB 3.0 beta. But the stated intention of LSB Desktop workgroup is to include Qt4 alongside, and there are no objections to this. The final version of LSB 3.0 will be released in January 2006, and by then all of the LSB websites will hopefully be updated and corrected. Olaf Jan Schmidt, KDE e.V. representative in the LSB workgroups
Re: OT LSB Desktop released (no libqt) - Christian Loose - 2005-12-09
Good to see that there soon will be a solution for the license criteria problem. Although I still think that Alan Cox's proposal (http://mail.freestandards.org/pipermail/lsb-desktop/2005-September/000133.html) would be even better. Just IMHO.
Aggregate tutorials & tools on KDE.org - Vlad C. - 2005-12-09
Why not aggregate (or link to) these great tutorials and tools in a location where potential new KDE developers are likely to first look (ie. on the KDE developer website): http://developer.kde.org/language-bindings/python/
Re: Aggregate tutorials & tools on KDE.org - MandrakeUser - 2005-12-09
Excellent idea. Only problem is how to mantain these link lists (keep them up to date). The other problem is choosing what to put. Sometimes you go to a wiki and get a list of 25 tools to do, say, IM in Linux. But you end up wasting a lot of time, because just two or three of the linked tools are relevant. What I typically do is google for things. And let the page rank do the job or sorting things out to me. It works, except for very new documents/info ...
Re: Aggregate tutorials & tools on KDE.org - sebas - 2005-12-10
I've added a link to the page.
Re: Aggregate tutorials & tools on KDE.org - Vlad C. - 2005-12-10
Great, thanks!
PyKDE and KPanelApplet - John Tuymo - 2005-12-10
Could someone please provide a complete working example (a hello world) for the KPanelApplet class, I would really like to be able to make my own python-powered panel applets for KDE.
PerlQt - Long Pa - 2005-12-10
Ummm... For a dog who is too old to be taught new tricks, is PerlQt a dead animal? I think the last ChangeLog for PerlQt is 2-3 years old. Sorry if I raise any hackles by mentioning such a beast in this thread. Candidly - but not caninely :) Paddy Healy
Re: PerlQt - Morty - 2005-12-11
I have no clue of it's state but the latest download looks like PerlQt-3.009-b2.tar.gz dated Jul 10, 2005. Not exactly recent, but less than years old:-) And http://lists.kde.org/?l=kde-bindings&m=112071056609643&w=2 Try the mailinglist for more better information.
Scripting KDE apps with Pyhon - ac - 2005-12-14
How would you go about creating a KDE app that can be controlled simultaneously from the GUI (i.e., the Qt event loop) and an interactive python interpreter? I've seen that IPython allows something similar (see http://www.scipy.org/wikis/topical_software/QtWithIPythonAndDesigner), but there it seems like the main program must be written in Python, or at least started from within a IPython session. Does anyone have any ideas about this?
Re: Scripting KDE apps with Pyhon - jyaan bresy - 2008-02-09
ipython allows you to run existing python code from within the interpreter. it's one of the "magic" functions that come with ipython. this is the usage: %run appname.py just launch your application, then continue. note you can use the magic funcs for changing directories also. otherwise you need to type the full path, of course. full help/doc is available through the iterpreter. and yes i know this post is ancient history, but who knows -- it may end up useful.