Re: [PyQt] Using QVariant.toPyObject to wrap the to* functions
On Thu, Aug 14, 2008 at 9:44 AM, Arve Knudsen [EMAIL PROTECTED] wrote: On Wed, Aug 13, 2008 at 9:37 PM, Erick Tryzelaar [EMAIL PROTECTED] wrote: [..] and etc. This makes QVariant a little more pythonic to me, in my opinion. I agree about this. It would be more natural to have toPyObject work for the standard types in addition to custom ones, and simplify the logic greatly. Yes this would be a great improvement. I currently use the function below but having this available via toPyObject() would be a great improvement. variant_converter = { QVariantList: lambda v: from_variantlist(v), QListQVariant: lambda v: from_variantlist(v), int: lambda v: v.toInt()[0], double: lambda v: v.toDouble()[0], char: lambda v: v.toChar(), QByteArray: lambda v: v.toByteArray(), QString: lambda v: unicode(v.toString()), QPoint: lambda v: v.toPoint(), QPointF: lambda v: v.toPointF(), QSize: lambda v: v.toSize(), QLine: lambda v: v.toLine(), QStringList: lambda v: v.toStringList(), QTime: lambda v: v.toTime(), QDateTime: lambda v: v.toDateTime(), QDate: lambda v: v.toDate(), QLocale: lambda v: v.toLocale(), QUrl: lambda v: v.toUrl(), QRect: lambda v: v.toRect(), QBrush: lambda v: QBrush(v), QFont: lambda v: QFont(v), QPalette: lambda v: QPalette(v), QPixmap: lambda v: QPixmap(v), QImage: lambda v: QImage(v), bool: lambda v: v.toBool(), QObject*: lambda v: ScripterNG.fromVariant(v), QWidget*: lambda v: ScripterNG.fromVariant(v), } def from_variantlist(variantlist): convert QListQVariant to a normal Python list return [from_variant(variant) for variant in variantlist.toList()] def from_variant(variant): convert a QVariant to a Python value typeName = variant.typeName() convert = variant_converter.get(typeName) if not convert: raise ValueError, Could not convert value to %s % typeName else: return convert(variant) ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Add a download to KGet
On Thu, Aug 14, 2008 at 6:47 AM, Jan Holthuis [EMAIL PROTECTED] wrote: Well, I really need to know if there's a way to do this. Maybe via DBUS or something like that... Can someone please help me? Thanks in advance, Jan Holthuis Am Sonntag 10 August 2008 15:10:17 schrieb Jan Holthuis: Hi! I was just wondering if there's a method to add a download to KGet. Maybe something like this: http://api.kde.org/4.x-api/kdenetwork- apidocs/kget/html/classKGet.html#2cb901470443e9fdd5c4b703b6f97434 Unfortunately, it seems that kdenetwork doesn't exist in PyKDE. Is (or will) there (be) another way to do this? All the best, Jan Holthuis I would like at dcop. kget has a addTransfers method which you may be able to use via the dcopext module. Run kdcop to find the names required. (kdcop wouldn't execute the addTransfers method when I tried it because it didn't know what the KURL::list type was, but dcopext does know.) I have seen the future and I'm not in it! ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Using PyQt within an application
I'm assuming you're using a QDialog. A)If it's a standard dialog (with OK/Cancel) then I usually use the accept()/reject() slots on the dialog. These close the dialog and return the status of the dialog upon exit (accepted or rejected). B) I would guess that you don't want the dialog to be modal. this way you can still interact with the application that called it. Use the method on the dialog, setModal(False) to turn off modality. darryl andYpsilon wrote: Hi! I am starting a PyQt dialog from inside an application (The Compositing package Nuke from The Foundry) to use the application specific python module. The problem is, as soon as I am in the main event loop, Nuke crashes when doing something outside of the dialog. This would be somehow OK, if the quit() or the exit() function wouldn't quit the whole application instead of only closing the dialog window. Does anyone know how to: A) -Quit a dialog without quitting the application from which the dialog was startetd?? or B) How to run the main event loop that the application from whioch the dialog was started can still be used?? thx, a desperate andy ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Add a download to KGet
On Thursday 14 August 2008 16:37:16 Dog Walker wrote: On Thu, Aug 14, 2008 at 6:47 AM, Jan Holthuis [EMAIL PROTECTED] wrote: Well, I really need to know if there's a way to do this. Maybe via DBUS or something like that... Can someone please help me? Thanks in advance, Jan Holthuis Am Sonntag 10 August 2008 15:10:17 schrieb Jan Holthuis: Hi! I was just wondering if there's a method to add a download to KGet. Maybe something like this: http://api.kde.org/4.x-api/kdenetwork- apidocs/kget/html/classKGet.html#2cb901470443e9fdd5c4b703b6f97434 Unfortunately, it seems that kdenetwork doesn't exist in PyKDE. Is (or will) there (be) another way to do this? All the best, Jan Holthuis I would like at dcop. kget has a addTransfers method which you may be able to use via the dcopext module. Run kdcop to find the names required. (kdcop wouldn't execute the addTransfers method when I tried it because it didn't know what the KURL::list type was, but dcopext does know.) I replied already but maybe it didn't show up: just call kget with the URLs you want to download as arguments in its CLI. It will add them itself. -- (\''/).__..-''`-. . Roberto Alsina `9_ 9 ) `-. ().`-._.`) KDE Developer (MFCH) (_Y_.)' ._ ) `._`. -.-' http://lateral.netmanagers.com.ar _..`-'_..-_/ /-'_.' The 6,855th most popular site of Slovenia (l)-'' ((i).' ((!.' according to alexa.com (27/5/2007) Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it. --Brian W. Kernighan ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] changing to qlist to use PyIter_Next instead of assuming a python list
On Thu, Aug 14, 2008 at 2:33 PM, Phil Thompson [EMAIL PROTECTED] wrote: The current version of PyQt will accept a sequence rather than a list. For some reason I didn't mention this in the ChangeLog, the NEWS file or the documentation. Even better! Thanks again Phil. ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Auto-generate sip specification file?
Hi, I used SIP today to generate a wrapper for one class in my library. My library has about 50 classes, and I want to wrap most of them. Now that I have things set up, it won't be too hard to copy each header file and manually edit them to create SIP specification files. But as the classes change, I'll need to maintain the SIP files too. Are there any tools that would help automate this process? Thanks, Mark ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Auto-generate sip specification file?
On Thursday 14 August 2008 17:02, Mark A. Schmucker wrote: Hi, I used SIP today to generate a wrapper for one class in my library. My library has about 50 classes, and I want to wrap most of them. Now that I have things set up, it won't be too hard to copy each header file and manually edit them to create SIP specification files. But as the classes change, I'll need to maintain the SIP files too. Are there any tools that would help automate this process? Phil has a gcc-xml based tool he uses to generate PyQt, but I'm not sure if he wants to make it generally available (there are lots of good reasons not to). Simon Edwards is using a tool for PyKDE4 called twine whose lexer./parser are based on PLY and which will generate a versioned set of sip files (one that, at least in theory, will build for any version of your lib). It also handles multiple modules, and will produce a set of HTML class docs from doxygen markup. It's GPL'd. There isn't much in the way of docs. It requires a project file (PyKDE4's project file can be used as an example) and has a few quirks. It's entirely written in Python and takes under 2 minutes to generate all of PyKDE4's sip files and HTML docs from KDE h files. It probably has some PyKDE specific stuff that needs to be worked out to make it a general purpose tool (for example it automatically builds a PyKDE4 directory structure, but the code that does that is a plugin that's easily replaced). If Simon doesn't chime in with a location where it's available, email him - simon AT simonzone.com :) Jim ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt