Re: [PyKDE] Windows systray application
Rob Knapp kirjoitti viestissään (lähetysaika tiistai, 28. kesäkuuta 2005 17:26): AFAIK, QT doesn't currently have a class that allows this. You will need to use the win32api call SHELL_NOTIFYICON to create the icon, and then I used the winEvent (I think, it's been about 2 years) to capture the incoming WM_ messages. thanks for the reply! I tried but I just don't have enough experience on doing things like this. the API thing is where I get confused. and I don't really know how I should send or receive these calls.. but then I managed to find pywin32 (windows extensions for python) example on doing this exact thing. so now I have it working, but thru pywin32. I would've wanted to just use QT for this, but atleast it works. now I have icon, and right-click menu even on the tray, and click there opens up my QT interface. thanks again, maybe in future it will be easier to do straight in QT too.. (and just maybe, after staring 2 weeks at the source of this pywin32 example, I could try to convert it to QT functions.. dont know. heh.) .b ___ PyKDE mailing listPyKDE@mats.imk.fraunhofer.de http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
Re: [PyKDE] overloading events with qt designer and pyqt
thanks for all advice. As mentioned before in this list by another smart one, a conveniend way was this: in designer i generate a custom widget with class QHBox and policy 'expanding' and then use it as a placeholder. My final signal/event catching widget is constructed 'by hand' as child of this placeholder. This works out fine for me. Been three days to this list and got two problems solved - really great! Frank Am Mittwoch, 29. Juni 2005 20:44 schrieb Torsten Marek: Frank Stüss schrieb: I'm not sure if that's really what you want, but if you'd like to use qt-designer and hand-coded additions at the same time, you can create your UI / widgets using qt-designer and then subclassing that UI in another file and overload the (paint)event. That way you can still change the UI without having to re-merge your changes everytime you recompile the .ui files. Thanks. Got it. But what if i don't want to overload the overall paintEvent of the UI but only the one of a part of it, eg. a QFrame or a QHbox? Shure I would subclass QFrame and overload the event but how can I put it into the 'designed' code, since my UI still uses QFrame and not the subclass of it. I like to do some simple drawLines on a QFrame not using any extension packages, only what is shipped with QT and pyqt. Thanks again for any help. Hi, you might want to have a look at http://www.diotavelli.net/PyQtWiki/DragAndDropWithPytQt and adapt it to your needs. greetings Torsten ___ PyKDE mailing listPyKDE@mats.imk.fraunhofer.de http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
Re: [PyKDE] Typecasting problems with PyQt embedded in Scribus
On Thursday 30 June 2005 1:16 am, Henning Schröder wrote: Hi! Scribus is a free DTP application which is coded in C++ and Qt and provides scripting with Python. A Python script can import the qt module and access the data from the running application as far as it is reachable with the Qt-object system (qApp.children(), ..) Unfortunately automatic typecasting does not always work as expected. For example when I access qt.qApp.mainWidget() I get a QWidget. But the main widget is a ScribusWin-class which is derived from QMainWindow. So I expected I can get a QMainWindow. Instead of writing my own SIP-wrapper for ScribusWin I would like better typecasting. Is this possible or can I do it manually? This was discussed on the list yesterday in another context. The next PyQt snapshot should have the behaviour you are expecting. Phil ___ PyKDE mailing listPyKDE@mats.imk.fraunhofer.de http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
Re: [PyKDE] Handling exceptions in SIP
On Wed, 29 Jun 2005 15:59:08 +0100 Phil Thompson [EMAIL PROTECTED] wrote: sip command passes without error, but I have an error when linking: $OFILES in Makefile contains sipMyModuleMyException.o, while there is no corresponding .cpp file generated. BTW, when I use throw specifier in method signature without corresponding %Exception directive, sip exits with non-zero code, but reports no error message. All tests were done with sip-snapshot-20050626. Should be fixed in tonight's snapshot. Simple examples work like a charm with sip-snapshot-20050629, thanks! There are some points to discuss: 1) If sipExceptionRef is not used in RaiseCode we'll get a warning. 2) Exceptions that were not specified in throw are not caught and I see no way to add catch(...) to generated code. 3) throw specifier has no effect on generated code when %MethodCode is used, shouldn't it? 4) There are several standard exceptions which I always have to catch. Now I have a macro for them: #define CATCH_STD_EXCEPTIONS \ catch (std::bad_alloc) {\ PyErr_NoMemory(); \ sipIsErr = 1; \ } catch (std::exception exc) {\ PyErr_SetString(PyExc_RuntimeError, exc.what()); \ sipIsErr = 1; \ } catch (...) {\ PyErr_SetString(PyExc_RuntimeError, unknown); \ sipIsErr = 1; \ } used in %MethodCode: %MethodCode try { sipRes = someMethod(...); } CATCH_STD_EXCEPTIONS // sipIsErr - this comment is important hint to SIP! %End -- Denis S. Otkidach http://www.python.ru/ [ru] ___ PyKDE mailing listPyKDE@mats.imk.fraunhofer.de http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
Re: [PyKDE] Latest PyKDE Snapshot
Hi, what are the changes to last snapshot? Anyway, the changelog is not updated, and it's hard to determine the changes at all... can someone summarize the changes beginning from: [EMAIL PROTECTED]:~/kde/pykde$ less PyKDE-snapshot20050628/ChangeLog 2004/08/25 16:44:00 jim Released 3.11.3; added post-processing for WId args in KWinModule signals; fixed enum in khtml_part (for KDE = 3.3); updated version numbers ... thx, \sh On Wednesday 29 June 2005 19:50, Phil Thompson wrote: Jim's latest PyKDE snapshot is now in the snapshot's directory. Phil ___ PyKDE mailing listPyKDE@mats.imk.fraunhofer.de http://mats.imk.fraunhofer.de/mailman/listinfo/pykde -- St. Hermann jabber://[EMAIL PROTECTED] ___ PyKDE mailing listPyKDE@mats.imk.fraunhofer.de http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
[PyKDE] Re: Memory leak segfault with deleteLater
Phil Thompson [EMAIL PROTECTED] wrote: ignoring the extra reference to wrappers of objects owned by C++. Thanks, I just verified that this fixes my problem! I've had to back this out - it's the wrong fix and breaks other things. Okie dokie. Is a different fix planned? -- Giovanni Bajo ___ PyKDE mailing listPyKDE@mats.imk.fraunhofer.de http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
Re: [PyKDE] Re: Memory leak segfault with deleteLater
On Thursday 30 June 2005 12:34 pm, Giovanni Bajo wrote: Phil Thompson [EMAIL PROTECTED] wrote: ignoring the extra reference to wrappers of objects owned by C++. Thanks, I just verified that this fixes my problem! I've had to back this out - it's the wrong fix and breaks other things. Okie dokie. Is a different fix planned? I'd like to think so. The cyclic garbage collector treats weak references differently but I'm a long way from understanding fully how it all works. Phil ___ PyKDE mailing listPyKDE@mats.imk.fraunhofer.de http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
[PyKDE] Segmentation fault with the latest SIP snapshots
Using QTimer.singleShot() causes a segmentation fault with sip-snapshot-20050626 and sip-snapshot-20050629. With sip-snapshot-20050623, it worked. See the example code below. Ulli import sys from qt import * class MyWidget(QWidget): def __init__(self,parent=None,name=,fl=0): QWidget.__init__(self,parent,name,fl) # This works with # sip-snapshot-20050623 # # With sip-snapshot-20050626 or # sip-snapshot-20050629 it fails # with a segmentation fault QTimer.singleShot(500, self.single) # This works QTimer.singleShot(2000, qApp, SLOT(quit())) # This works t = QTimer(self) self.connect(t, SIGNAL(timeout()), self.repeated) t.start(100, False) def single(self): print singleShot() def repeated(self): print repeatedShot() if __name__ == __main__: a = QApplication(sys.argv) QObject.connect(a, SIGNAL(lastWindowClosed()), a, SLOT(quit())) w = MyWidget() w.show() a.exec_loop() ___ PyKDE mailing listPyKDE@mats.imk.fraunhofer.de http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
Re: [PyKDE] Segmentation fault with the latest SIP snapshots
Ulrich Berning schrieb: Using QTimer.singleShot() causes a segmentation fault with sip-snapshot-20050626 and sip-snapshot-20050629. With sip-snapshot-20050623, it worked. See the example code below. Ulli Oops, mozilla has shuffled the whitespaces a little bit, I hope you can still read the code example. Ulli ___ PyKDE mailing listPyKDE@mats.imk.fraunhofer.de http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
[PyKDE] PyKDE without KApplication
Is there a way to instantiate pykde classes using QApplication instead KApplication. Thanks. Mike ___ PyKDE mailing listPyKDE@mats.imk.fraunhofer.de http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
Re: [PyKDE] PyKDE without KApplication
On 30.Jun 2005 - 17:33:34, Mike Tammerman wrote: Is there a way to instantiate pykde classes using QApplication instead KApplication. I think so, at least most. For instance KMainWindow is derived from QMainWindow and thus it should be possible to use QApplication.setMainWidget Instead of KApplication. And also you should be able to use a KDE widget wherever a QWidget can be used. Note: I did not test this myself, these are only assumptions based on the information about the classes from the kde docs. Andreas -- Your business will go through a period of considerable expansion. ___ PyKDE mailing listPyKDE@mats.imk.fraunhofer.de http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
Re: [PyKDE] Segmentation fault with the latest SIP snapshots
On Thursday 30 June 2005 2:10 pm, Ulrich Berning wrote: Using QTimer.singleShot() causes a segmentation fault with sip-snapshot-20050626 and sip-snapshot-20050629. With sip-snapshot-20050623, it worked. See the example code below. Will be fixed in tonight's SIP snapshot. Thanks, Phil ___ PyKDE mailing listPyKDE@mats.imk.fraunhofer.de http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
Re: [PyKDE] PyKDE without KApplication
Mostly it creates a segfault, the basic one is --- from qt import * from kdeprint import * import sys a = QApplication(sys.argv) KPrinter() --- Mike On 6/30/05, Andreas Pakulat [EMAIL PROTECTED] wrote: On 30.Jun 2005 - 17:33:34, Mike Tammerman wrote: Is there a way to instantiate pykde classes using QApplication instead KApplication. I think so, at least most. For instance KMainWindow is derived from QMainWindow and thus it should be possible to use QApplication.setMainWidget Instead of KApplication. And also you should be able to use a KDE widget wherever a QWidget can be used. Note: I did not test this myself, these are only assumptions based on the information about the classes from the kde docs. Andreas -- Your business will go through a period of considerable expansion. ___ PyKDE mailing listPyKDE@mats.imk.fraunhofer.de http://mats.imk.fraunhofer.de/mailman/listinfo/pykde ___ PyKDE mailing listPyKDE@mats.imk.fraunhofer.de http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
Re: [PyKDE] Handling exceptions in SIP
On Thursday 30 June 2005 10:25 am, Denis S. Otkidach wrote: On Wed, 29 Jun 2005 15:59:08 +0100 Phil Thompson [EMAIL PROTECTED] wrote: sip command passes without error, but I have an error when linking: $OFILES in Makefile contains sipMyModuleMyException.o, while there is no corresponding .cpp file generated. BTW, when I use throw specifier in method signature without corresponding %Exception directive, sip exits with non-zero code, but reports no error message. All tests were done with sip-snapshot-20050626. Should be fixed in tonight's snapshot. Simple examples work like a charm with sip-snapshot-20050629, thanks! There are some points to discuss: 1) If sipExceptionRef is not used in RaiseCode we'll get a warning. Tonight's snapshot will only generate it if it is used. 2) Exceptions that were not specified in throw are not caught and I see no way to add catch(...) to generated code. It could be specified by allowing ... as the last in the throw list, but I'm not sure how to specify the %RaiseCode. Allowing ... to be specified with %Exception would mean the same code would have to be used everywhere in the module. Alternatively, %RaiseCode could also be allowed as part of a method definition - but that would need it to be specified every time. 3) throw specifier has no effect on generated code when %MethodCode is used, shouldn't it? It shouldn't. If you are providing code to call the method, you should also handle the exceptions. 4) There are several standard exceptions which I always have to catch. Now I have a macro for them: #define CATCH_STD_EXCEPTIONS \ catch (std::bad_alloc) {\ PyErr_NoMemory(); \ sipIsErr = 1; \ } catch (std::exception exc) {\ PyErr_SetString(PyExc_RuntimeError, exc.what()); \ sipIsErr = 1; \ } catch (...) {\ PyErr_SetString(PyExc_RuntimeError, unknown); \ sipIsErr = 1; \ } used in %MethodCode: %MethodCode try { sipRes = someMethod(...); } CATCH_STD_EXCEPTIONS // sipIsErr - this comment is important hint to SIP! %End If your point is the need for the comment, then yes - consider it a feature. Phil ___ PyKDE mailing listPyKDE@mats.imk.fraunhofer.de http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
Re: [PyKDE] Typecasting problems with PyQt embedded in Scribus
Hi! Jim Bublitz [EMAIL PROTECTED]: [..] wrapinstance and unwrapinstance are covered in the sip docs. Thanks I will try your C++/Python-mixed solution. But I wonder why the following does not work: ptr = sip.unwrapinstance(qt.qApp.mainWidget()) mainWindow = sip.wrapinstance(ptr, qt.QMainWindow) Unfortunately mainWindow is still a QWidget. Henning ___ PyKDE mailing listPyKDE@mats.imk.fraunhofer.de http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
Re: [PyKDE] SIP- 4.2.1 (snapshot-20050625-332) less smart than g++ in identifying abstract classes
On Sunday 26 June 2005 3:57 pm, Gerard Vermeulen wrote: Here is an example where the sip specification matches exactly the corresponding header files: -- start header file -- #ifndef V_H #define V_H class A { public: A(); virtual ~A(); virtual int getTypeId() = 0; }; class B: public A // abstract by derivation { public: B(); virtual ~B(); virtual int bStuff(); }; class C: public B // abstract by derivation { public: C(); virtual ~C(); virtual int cStuff(); }; class D: public C { public: D(); virtual ~D(); virtual int getTypeId(); virtual int dStuff(); }; #endif // V_H -- end header file -- -- start sip file -- %Module v 0 class A { %TypeHeaderCode #include v.h %End public: A(); virtual ~A(); virtual int getTypeId() = 0; }; class B: A { %TypeHeaderCode #include v.h %End public: B(); virtual ~B(); virtual int bStuff(); // SIP must have the information so that I do not have to copy // virtual int getTypeId() = 0; // from a base class since that may be tedious in huge libraries }; class C: B /Abstract/ // prevents subclassing { %TypeHeaderCode #include v.h %End public: C(); virtual ~C(); virtual int cStuff(); }; class D: C { %TypeHeaderCode #include v.h %End public: D(); virtual ~D(); virtual int getTypeId(); virtual int dStuff(); }; -- end sip file For C++, classes A, and B and C by inheritance are abstract because of the pure virtual getTypeId() declared in A. SIP does not look for pure virtual functions in base classes of a class but it should have all the information isn't it? Should be fixed in tonight's snapshot. Thanks, Phil ___ PyKDE mailing listPyKDE@mats.imk.fraunhofer.de http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
Re: [PyKDE] Latest PyKDE Snapshot
On Thursday 30 June 2005 04:24, Stephan Hermann wrote: Hi, what are the changes to last snapshot? Anyway, the changelog is not updated, and it's hard to determine the changes at all... can someone summarize the changes beginning from: [EMAIL PROTECTED]:~/kde/pykde$ less PyKDE-snapshot20050628/ChangeLog 2004/08/25 16:44:00 jim Released 3.11.3; added post-processing for WId args in KWinModule signals; fixed enum in khtml_part (for KDE = 3.3); updated version numbers Yeah - since I started running svn locally I haven't been maintaining the ChangeLog very well. There aren't too many changes since the last snapshot: 1. Added explicit private destructors in a few places as required by new sip version 2. Fixed one sipConvertTo_ call that was in error (seems to have been a long-standing bug that the compiler missed in previous versions - misnamed function call) 3. Fixed dcop extensions/bytearray.sip to handle bool type for returned results. Prior to that, most of the changes were things required by sip (enum syntax, for example), changes in paths and other stuff related to the build system, and a few minor bug fixes. Additionally, PyKDE has picked up any KDE changes that occurred - the current snapshot should have everything through KDE 3.4.1. Other than incorporating any new KDE classes or methods, PyKDE has been fairly static for the last year. I'm not aware of anything (at least anything that wasn't changed in sip too, like enums) that would break older code, although there probably were a few bugs introduced that had to be repaired. Jim ___ PyKDE mailing listPyKDE@mats.imk.fraunhofer.de http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
Re: [PyKDE] PyKDE without KApplication
On Thursday 30 June 2005 16:33, Mike Tammerman wrote: Is there a way to instantiate pykde classes using QApplication instead KApplication. You could try, but it would be a very unwise thing to do. The KDE classes assume that KApplication is around and correctly initialised. -- Simon Edwards | Guarddog Firewall [EMAIL PROTECTED] | http://www.simonzone.com/software/ Nijmegen, The Netherlands | ZooTV? You made the right choice. ___ PyKDE mailing listPyKDE@mats.imk.fraunhofer.de http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
Re: [PyKDE] Segmentation fault with anonymous enum
On Thursday 30 June 2005 5:27 pm, Denis S. Otkidach wrote: If I define single enum in module (no other entries constants), then I have no enummembers in generated file and it's not exposed in module. If I have other (non-anonymous) enums, then adding anonymouse one causes segmentation fault when module is imported: #0 PyObject_Call (func=0x11, arg=0x3146cc, kw=0x0) at Objects/abstract.c:1750 1750if ((call = func-ob_type-tp_call) != NULL) { (gdb) bt #0 PyObject_Call (func=0x11, arg=0x3146cc, kw=0x0) at Objects/abstract.c:1750 #1 0x003d8671 in initsip () from sip.so #2 0x003d616b in initsip () from sip.so #3 0x00371d50 in inittest () from ./test.so Fixed in tonight's snapshot. Thanks, Phil ___ PyKDE mailing listPyKDE@mats.imk.fraunhofer.de http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
Re: [PyKDE] Typecasting problems with PyQt embedded in Scribus
Jim Bublitz [EMAIL PROTECTED] wrote: But I wonder why the following does not work: ptr = sip.unwrapinstance(qt.qApp.mainWidget()) mainWindow = sip.wrapinstance(ptr, qt.QMainWindow) Unfortunately mainWindow is still a QWidget. I'm not sure - my guess is that it's because ptr is already typed in Python as a QWidget. I've done something similar to get a C++ object into Python, but the object was already the correct type - just instantiating the wrapper, but no cast involved. You might try: mainWindow = sip.cast (ptr, qt.QMainWindow) We just discussed this on the list. Phil is going to implement a general solution so that you always get the most derived class Python knows about -- QMainWindow in this case. Giovanni Bajo ___ PyKDE mailing listPyKDE@mats.imk.fraunhofer.de http://mats.imk.fraunhofer.de/mailman/listinfo/pykde