[PyKDE] Making use of the K Widgets

Matt T. Matt at Boons.net
Mon Jan 17 06:48:17 GMT 2005


On Monday 17 January 2005 04:27, Dennis Schaaf wrote:
> Hi,
>
> I'm designing tools with qtdesigner and then compiling the ui files I
> get with pyuic. This works ok when I'm using normal qt widgets but if
> I use the KDE specific widgets like KTextBrowser I get errors because
> the compilet output file doesn't import any of the required kde
> modules(and I don't even know exactly where they are).
>
> What do you think is the best way to design with the KDE widgets?
>
> dennis
>

There are 2 ways to go (AFAIK):

---------------------------
1) Add manually in each form file compiled by pyuic, after "from qt import *":

from kdecore import *
from kdeui import *

There are more kde modules, but these probably are enough for most apps.

Later, after it works, to reduce memory consumption, do not import all "*", 
but list explicitely the modules you use only : "from kdeui import 
KTextBrowser" etc.

Disadvantage: Every time you modify the form, and thus run pyuic, you have to 
redo this step.
---------------------
2) You can add the imports 

from kdecore import *
from kdeui import *
(etc.)

also in the comment section of the form, when you have it open in qtdesigner. 
Cannot give you details here, I haven't tried that myself yet. Probably the 
better way to go. 
----------------------

NOTE: pyuic adds a "main" function to each form, which allows you to run the 
form stand alone. Very helpful for testing. But, if you use kde widgets, you 
should also manually change the "QApplication" there to a "KApplication", 
otherwise some kde widgets will not work as expected.

HTH,
Matt




More information about the PyQt mailing list