Re: [PyQt] Tutorial about the use of JavaScript

2009-12-06 Thread Benjamin Kleiner
Hi Christophe.
The page http://doc.trolltech.com/4.5/qscriptengine.html#details in the 
original api doc of Qt was so far sufficient to me, e.g. I 
was able to translate most examples there from C++ into Python. You'll only 
have to take care that native functions (those that 
are implemented in Python and get called from JS) really returns a QScriptValue 
(in C++ it apparently gets casted 
automatically), and that imported Objects must be descendants of QObject, so 
you need a wrapper to import QDateTime and some 
other basic creeps.

Regards,
Benjamin.


signature.asc
Description: This is a digitally signed message part.
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

[PyQt] Problems with KSharedConfig

2009-01-21 Thread Benjamin Kleiner
I am trying to convert the toggle-compositing plasmoid from C++ to Python and 
ended up having a problem with KSharedConfig.
The original uses the following code to modify the config of kwin:

void ToggleCompositing::writeState(bool state) {
KSharedConfigPtr 
mKWinConfig=KSharedConfig::openConfig("kwinrc");
KConfigGroup config(mKWinConfig, "Compositing");
m_state = config.readEntry("Enabled", false);
if (m_state != state) {
config.writeEntry("Enabled", state);
m_state = state;
mKWinConfig->sync();
}
}

I tried to follow a narrowly and got this:

def writeState(self, newValue):
config = KSharedConfig.openConfig("kwinrc")
configGroup = config.group("Compositing")
if configGroup.readEntry("Enabled", QVariant(False) ).toBool() 
!= newValue:
configGroup.writeEntry("Enabled", newValue)
configGroup.sync()
return configGroup.readEntry("Enabled", QVariant(False) 
).toBool()

It always crashes on the third line. No backtrace, sorry. Python doesn't give 
me anything, and KCrash says it can't load the necessary symbols :/
I've already tried it with the normal KConfig class, with the result that it 
only crashes at every second try (nothing happens after the first, though)...
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt