Re: [PyQt] About keyPressEvent
> What I suddenly think about is that you should try to catch some > signal (I can't remember the name, but do read up on what signals and > slots a QMainWindow/KMainWindow has) that is related to quitting the > application. I seem to remember there are methods which get triggered > at exit -- you could perhaps rewire them somehow. > This is good advice however, I also have a systray application, and do not see the behavior the original poster is talking about. I can hit Alt-F4 or Alt-Esc (which for me on GNOME minimzes) all day and my app stays up. (Well, ok... not all day, but well after the last window is closed.) Perhaps you (the original poster) should double check and make sure that you are calling setQuitOnLastWindowClosed(False) on your QApplication instance before your call to exec_. Sounds silly I know, but more than once I've been moving code around and missed a line or two. --- Rob Knapp Lead Developer www.bizling.com ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Need Help Wrapping WebKit
> On Sat, 14 Jul 2007 07:15:29 -0400, Rob Knapp wrote: > > > But, now I've hit my first snag. I'm trying to wrap WebKitQt up for use in > > the project, and following the example at riverbankcompting.com/Docs, > > (which looks like it was written for qt3, since > > I couldn't find qt/qtmod.sip) I > > have come up with something that compiles > > I found it easier to look at an existing project. Maybe it's time for > some more documentation about this. Well, I dug for several hours a while in the PyQT code before posting to the list, but wasn't able to find the magic key. I will keep trying. If I can get this working, I'd be happy to submit an updated tutorial with whatever information I gather. > > > but when I try to import I get: > > >>> import libQtWebKit > > > > Traceback (most recent call last): > > File "", line 1, in > > ImportError: ./libQtWebKit.so: undefined symbol: > > _ZN8QWebPage11qt_metacastEPKc > > This looks like moc should have been used to process a header file, but > wasn't. It's not easy to say how you can fix this without knowing more > about WebKitQt's build process and the one for your own wrappers. > Does WebKit come with test and examples that you can use to check that > it actually works as expected? Yes, building webkit builds a program called QtLauncher that lets you test and make sure everything is working, and I have verified that it was functional before posting. > > I know you included a link to the WebKit Wiki, but I don't have the time > to build it myself. > > [Information about the build process.] > > > Now, this seems to compile and link just fine... > > and all the world seems to be sunshine and roses... > > until I start a python interpreter and try to import, > > and I get the error message above. > > > > I would appreciate any help or advice on getting this > > code actually usable. > > If you put your code somewhere, the people on this list who are both > interested in WebKit and SIP experts can take a look at it. > The code was attached to my original posting, a breach of netiquette, I know. However, I figured since the tarball was smaller than some posts (1.8K) to the list, it wouldn't raise too many hackles. Of course, if people would rather download it from a website, I can easily post it somewhere as well. > David (neither a WebKit expert nor a SIP expert) > > ___ > PyQt mailing listPyQt@riverbankcomputing.com > http://www.riverbankcomputing.com/mailman/listinfo/pyqt > ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Need Help Wrapping WebKit
> On Sat, 14 Jul 2007 07:15:29 -0400, Rob Knapp wrote: > > > But, now I've hit my first snag. I'm trying to wrap WebKitQt up for use in > > the project, and following the example at riverbankcompting.com/Docs, > > (which looks like it was written for qt3, since > > I couldn't find qt/qtmod.sip) I > > have come up with something that compiles > > I found it easier to look at an existing project. Maybe it's time for > some more documentation about this. Well, I dug for several hours a while in the PyQT code before posting to the list, but wasn't able to find the magic key. I will keep trying. If I can get this working, I'd be happy to submit an updated tutorial with whatever information I gather. > > > but when I try to import I get: > > >>> import libQtWebKit > > > > Traceback (most recent call last): > > File "", line 1, in > > ImportError: ./libQtWebKit.so: undefined symbol: > > _ZN8QWebPage11qt_metacastEPKc > > This looks like moc should have been used to process a header file, but > wasn't. It's not easy to say how you can fix this without knowing more > about WebKitQt's build process and the one for your own wrappers. > Does WebKit come with test and examples that you can use to check that > it actually works as expected? Yes, building webkit builds a program called QtLauncher that lets you test and make sure everything is working, and I have verified that it was functional before posting. > > I know you included a link to the WebKit Wiki, but I don't have the time > to build it myself. > > [Information about the build process.] > > > Now, this seems to compile and link just fine... > > and all the world seems to be sunshine and roses... > > until I start a python interpreter and try to import, > > and I get the error message above. > > > > I would appreciate any help or advice on getting this > > code actually usable. > > If you put your code somewhere, the people on this list who are both > interested in WebKit and SIP experts can take a look at it. > The code was attached to my original posting, a breach of netiquette, I know. However, I figured since the tarball was smaller than some posts (1.8K) to the list, it wouldn't raise too many hackles. Of course, if people would rather download it from a website, I can easily post it somewhere as well. > David (neither a WebKit expert nor a SIP expert) > > ___ > PyQt mailing listPyQt@riverbankcomputing.com > http://www.riverbankcomputing.com/mailman/listinfo/pyqt > ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Need Help Wrapping WebKit
Hey everyone, I've been away from the PyQt world for too long. Last time I used it was back in the 3.3 days. But recently, I've found myself playing with a personal project on Linux (and trying to get it run on Mac/Windows as well...), and I decided to go back and see what PyQT4 was all about. I must say that I like the more modular layout. But, now I've hit my first snag. I'm trying to wrap WebKitQt up for use in the project, and following the example at riverbankcompting.com/Docs, (which looks like it was written for qt3, since I couldn't find qt/qtmod.sip) I have come up with something that compiles but when I try to import I get: >>> import libQtWebKit Traceback (most recent call last): File "", line 1, in ImportError: ./libQtWebKit.so: undefined symbol: _ZN8QWebPage11qt_metacastEPKc >>> Attached is a small example, and below is my build process. (it's convoluted, but I think that is because I'm not using sip quite right...any advice would be great.) 1) Follow directions here to build libWebKitQt: http://trac.webkit.org/projects/webkit/wiki/BuildingQtOnLinux 2) add /WebKit/WebKitBuild/Release/lib to my LD_LIBRARY_PATH 3) run python configure.py 4) open up the Makefile and add -I/WebKit/WebKitBuild/WebKitQt/Api to CPPFLAGS 5) Add -L/WebKit/WebKitBuild/Release/lib to LIBS 6) make Now, this seems to compile and link just fine... and all the world seems to be sunshine and roses... until I start a python interpreter and try to import, and I get the error message above. I would appreciate any help or advice on getting this code actually usable. binPbVRCgT5YT.bin Description: Binary data ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyKDE] Windows systray application
On Tue, 2005-06-28 at 14:11 +0300, basse wrote: > > Hi, I've been hunting for two days now a way to create an application with > PyQT > (on winXP), that will hide itself on systray. only things I found was some > references to WM_ messages and winEventFilters.. but no real example what that > means. 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. > and some references on QT examples of icontray-program.. but that was > outdated, > and I couldn't make it work in python.. > > so, is there anyone that has managed to do this? > and how? Yes, I have. Unfortunately the code was developed for a company I no longer work for. Otherwise, I would share. There is a pure win32 example here. The main changes are 1) create a hidden widget, and make that the parent of the notify icon. (The parent gets the events you are interested in.) Then override, winEvent (I'm 60% sure that is the name, I'm sure someone else (who has used QT more recently than I ) would remember the correct one). In that event handler examine the LPARAM(again, I think) and compare to the WM_ constants you found. This is a brief overview, but it should get you started, sorry I can't be more help. > > all information highly appreciated. > > thanks. > > .b > > ___ > PyKDE mailing listPyKDE@mats.imk.fraunhofer.de > http://mats.imk.fraunhofer.de/mailman/listinfo/pykde -- --- Rob "Myddrin" Knapp [EMAIL PROTECTED] http://www.myddrin.com ___ PyKDE mailing listPyKDE@mats.imk.fraunhofer.de http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
Re: [PyKDE] PyQT module size
On Thu, 2005-02-17 at 11:47 -0800, Brian Thomason wrote: > We've been using PyQT/PyKDE here at Linspire for some time now to > develop a handful of applications. One of these is Lsongs, and it has > grown quite large and has a very large memory footprint. We're trying > to reduce this a bit in various ways (switching to gstreamer from > libxine for instance) and I was curious if there was a way to reduce the > footprint size of pyqt/pykde. The shared object files themselves are > quite large - Larger than their C++ counterparts. I fought this battle while at a previous position (admittedly on windows, not linux). The only solution I could find was to compile QT with the absolute minimum set of classes required for my application. This got QT down to about 2Megs and PyQT down to about 3.5 or so. I can't remember the exact figures, but it doesn't matter since you are using a different compiler. I do recall that it was more than half for me, but I wasn't using several large modules. The other horrible hack you can do to change this is to manually edit the main sip file and remove (or comment out) the includes for the classes you don't need. This gives you a fully functional QT, but a hobbled pyqt. (And then I would suggest changing the name of qt.pyd to linQt.pyd or some such so that users can install their own full version of py qt) We also hit memory foot print issues, and the first thing I will say is watch your python strings! string A + string B creates a new string, so concatenating using the "+" operator uses a lot more memory than you think. Once you've done that, look on the web for options on optimizing memory with python. There are plenty of resources. If you are still having memory problems, the only thing I can suggest (and this is what we did), is explictly delete as many variables as you can. This also can help. If you get _really_ desperate, you can force garbage collection in a seperate (python) thread, but that lead to some stability issues for me. Finally, if you really are at the end of the loop, if there is a call like win32's SetWorkingSetSize that writes "unused" objects to virtual memory, you can sprinkle that at strategic locations or even in a background loop. (Probably need to expose whatever call it would be.) Of course there is a pretty large performance hit here, but it can be very effective in freeing up physical ram for other apps. It also isn't cross-platform, but considering that you work for a linux company, I doubt that is the end of the world. :) In my situation (a video conferencing suite), this was very useful as my UI application's performance was virtually irrelevant as along as the video and networking apps were running well. (long story, everything was in a seperate app so if one part failed, the conference could continue). None of this is probably what you want to hear. AFAICT, there is no magic bullet that shrinks PyQTs memory down. What I can say if applying everything except the SetWorkingSetSize, we went from about 50 Megs while in conference to about 20 Megs while in conference. We could have saved more in a couple of areas specific to our application (the skinning engine, and our interactions with zip files), but money ran out before we could do that. > I'm totally ignorant on python bindings so this may just be "the way it > is" and that's fine. Just curious if there's a way to "shrink" these > down a bit. > > Thanks, > > -Brian > -- > > This message contains information which may be confidential and privileged. > Unless you are the > addressee (or authorized to receive for the addressee), you may not use, copy > or disclose to anyone > the message or any information contained in the message. If you have received > the message in error, > please advise the sender and delete the message. Thank you. > > ___ > PyKDE mailing listPyKDE@mats.imk.fraunhofer.de > http://mats.imk.fraunhofer.de/mailman/listinfo/pykde -- --- Rob "Myddrin" Knapp [EMAIL PROTECTED] http://www.myddrin.com ___ PyKDE mailing listPyKDE@mats.imk.fraunhofer.de http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
Re: [PyKDE] PyQT 3.9 and QT 3.2.3 and the reparent method
I'm hoping you mean the 3.9 snapshots, not the 4.0 snapshots... I'm stuck with python 2.2 for a little while longer here. Thanks for the help. I will check into it. Detlev Offenbach wrote: This is a known issue with 3.9 and is fixed in the snapshot versions. I had the same problem in eric3 and had to incorporate a workaround that isn't using reparent. Detlev Am Dienstag, 13. Januar 2004 15:20 schrieb Rob Knapp: I'm trying to upgrade to 3.9 and QT 3.2.3 but I'm having issues with the reparent method. Below is an interactive session showing the issue. According to the newsgroups this error occurs when the extension returns NULL instead of Py_None. I've verified that I'm using sip 3.9 and not an earlier version. I've played around some and this appears to be the only affected method on QWidget. Any thoughts on what could be causing this? Can anyone else reproduce? >>> from qt import * >>> app = QApplication([]) >>> b = QWidget() >>> b.show() >>> b.repaint(1) >>> a = QWidget() >>> a.reparent(b, QPoint(0,0),1) Traceback (most recent call last): File "", line 1, in ? SystemError: error return without exception set ___ PyKDE mailing list[EMAIL PROTECTED] http://mats.imk.fraunhofer.de/mailman/listinfo/pykde ___ PyKDE mailing list[EMAIL PROTECTED] http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
[PyKDE] PyQT 3.9 and QT 3.2.3 and the reparent method
I'm trying to upgrade to 3.9 and QT 3.2.3 but I'm having issues with the reparent method. Below is an interactive session showing the issue. According to the newsgroups this error occurs when the extension returns NULL instead of Py_None. I've verified that I'm using sip 3.9 and not an earlier version. I've played around some and this appears to be the only affected method on QWidget. Any thoughts on what could be causing this? Can anyone else reproduce? >>> from qt import * >>> app = QApplication([]) >>> b = QWidget() >>> b.show() >>> b.repaint(1) >>> a = QWidget() >>> a.reparent(b, QPoint(0,0),1) Traceback (most recent call last): File "", line 1, in ? SystemError: error return without exception set ___ PyKDE mailing list[EMAIL PROTECTED] http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
[PyKDE] QT 3.2?
Is anyone running PyQT 3.7 with the newly released QT 3.2? There are some enhancments that would be very nice to have... ___ PyKDE mailing list[EMAIL PROTECTED] http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
Re: [PyKDE] More 3.7 compile issues
These issues have been resolved. I'm just noting them here in case anyone else has the same problem. Not sure how they would since it was my own idiocy...but I can't be the only one this unobservant, can I? The whole problem was that I wasn't watching the make processes for errors. Apparently the buid of sip was failing to copy libsip.dll and sip.exe over for some reason (in use by another app maybe?) And the second issue came from not realizing an error had occured during the make install. On Wed July 9 2003 12:30 pm, Phil Thompson wrote: > On Wednesday 09 July 2003 4:29 pm, Rob Knapp wrote: > > I'm currently compiling on a win32 platform and the build process > > reported that sipBadLengthForSlice was an unknown identifier. The line > > number provided was line 130 in spi/qstringlist.sip. > > Make sure you are using SIP v3.7. > Removing all versions of sip from my computer and re-making it did the trick. I'm not sure where how sip wasn't getting replaced. [snip] > > However, there is a larger problem. When I reach the end of my > > compilation and attempt to import qt I get this: > > [snip] > > That sounds like you have a 3.7 libqtc.pyd and a 3.6 qt.py. > > An explanation of both problems might be that you forgot to run "nmake > install" after building both SIP and PyQt. This also resolved the problem. The make of qtuic.pyd failed (because I don't have the XML module installed), which prevented nmake install from copying this over. Copying the .py files over manually resolved this issue. > Phil > > ___ > PyKDE mailing list[EMAIL PROTECTED] > http://mats.imk.fraunhofer.de/mailman/listinfo/pykde ___ PyKDE mailing list[EMAIL PROTECTED] http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
[PyKDE] More 3.7 compile issues
I'm currently compiling on a win32 platform and the build process reported that sipBadLengthForSlice was an unknown identifier. The line number provided was line 130 in spi/qstringlist.sip. For the time being I've hacked the .sip file to simply return NULL in those circumstances since my immediate needs don't require that class...however it would be nice to have the option of using it in future. However, there is a larger problem. When I reach the end of my compilation and attempt to import qt I get this: Traceback (most recent call last): File "" line 1, in ? File "d:\projects\lib\qt.py", line 924 in ? libqtc.sipRegisterClasses() SystemError: Unable to find class object for QSignalMapper I've tried defining QT_NO_SIGNALMAPPER in qconfig.h to get around this, but that just generates compile errors. ___ PyKDE mailing list[EMAIL PROTECTED] http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
Re: [PyKDE] Connecting PYSIGNALS to C++ slots
On Sun July 6 2003 11:42 am, Phil Thompson wrote: > What's a "python QT object"? > > Phil Ooops, some internal team jargon slipped in there I guess. It's a designation we use for an instance of a class that was written in python that inherits from a QT object. [Helps us keep straight the pieces written in PyQT and the pieces written in QT.] ___ PyKDE mailing list[EMAIL PROTECTED] http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
[PyKDE] Connecting PYSIGNALS to C++ slots
I am writting a C++ wrapper for some python QT objects. As a result, I need to recieve the PYSIGNALS from the python object and retransmit them so my container binary can connect to them. [This is a double post (kind of), I posted the same question on thursday (7/3/2003), but I've tried a bunch of new things so I thought I would include those as well.] >From the documentation it looks like I need to use sipConnectRX (please correct me if this is wrong). This is the code that I'm trying to use: PyObject * sipThisObject; sipThisObject = sipGetThisWrapper( this, qtQWidget); sipConnectRx(objPyWidget, "SomePythonSignal", sipThisObject, "slot_OnSomePythonSignal") qtQWidget is the pyobject representing the class that I get from the qt module. objPyWidget is a member variable in my class which is an instance of my pyqt widget. I've tried the following variations with no luck, sipThisObject is always null: haveing my wrapper inherit from sipQWidget trying to get a wrapper for QObject casting the this pointer to a sipQWidget pointer. Thanks, ___ PyKDE mailing list[EMAIL PROTECTED] http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
Re: [PyKDE] Using SIP to wrap python objects
On Thu June 12 2003 09:05 pm, Frederick Polgardy Jr wrote: > On Thursday 12 June 2003 18:31, Rob Knapp wrote: > > I've found myself in a position where I need to present a python object > > to a C++ object, and it needs to look like a C++ object. The target > > application knows nothing of python. > > [snip] > > Why not write what's called (in "Patterns" speak) an Adaptor class: one > which provides its own interface, and keeps track of the Python objects it > needs to use internally. What kind of interface is the target application > expecting? > Almost a month later (I got pulled off onto other things) I'm back at this and have concluded that an out and out adapter class (rather that inheritance) is the way to go as you suggested. I've written a nice little script that auto generates my classes, and just generally seems to make life good. :) Just generally, things go too confusing attempting this other ways. I've run into a snag though: When my python widget sends a signal, I need to pass this on to the application that contains my C++ object. It looks like sipConnectRx is the function I need, but when it requires a PyObject for both the transmitter and receiver, so I need to get a SIP wrapper for my wrapper class. The following code doesn't seem to work, even though this inherits from QWidget sipThisObject is always null. PyObject * sipThisObject; sipThisObject = sipGetThisWrapper( this, qtQWidget); sipConnectRx(objPyWidget, "SomePythonSignal", sipThisObject, "slot_OnSomePythonSignal") Legend: objPyWidget the custom python widget being wrapped qtQWidget is the python class QWidget retrieved from the qt module slot_OnSomePythonSignal is a slot on my c++ wrapper object Is there some other api call I should be using, or am I missing some piece that needs to make this work? ___ PyKDE mailing list[EMAIL PROTECTED] http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
Re: [PyKDE] Using SIP to wrap python objects
[snip] > > So, if I inherit a C++ object from QWidget and write a sip binding, then > > I'm set. That's what I thought, but what I was hoping for was some way > > to automatically generate this "in between" object. > > It can't be automatically generated if you are adding functionality (the > new methods and slots) to it. That's ok, I think what I layout below will work (using python introspection and maybe a little hand tweaking) [snip] > > From what I'm seeing in the responses, I would write a C++ > > class(QMyddrin) that inherits from QWidget and adds these methods. Then > > my python ocde I would inherit from QMyddrin and it should all work as > > long as I do the conversion from Py_Object to CppPointer (I forget the > > call name.) > > Yes - but where are you going to put the code that does that conversion? > Does the dialog include a method that will embed your QMyddrin instance? The API we are using provides a place that is perfect just for this. :) Thanks for the help, I think I have enough that I can start moving forward. And yes, I realize this makes for a bizarre sounding solution. I can't really go into why I think this is a good thing to do right now. But it meets our needs very well. ___ PyKDE mailing list[EMAIL PROTECTED] http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
Re: [PyKDE] Using SIP to wrap python objects
On Friday 13 June 2003 04:21 am, Phil Thompson wrote: > On Friday 13 June 2003 12:31 am, Rob Knapp wrote: > > I've found myself in a position where I need to present a python object > > to a C++ object, and it needs to look like a C++ object. The target > > application knows nothing of python. > > What C++ object does it need to look like? It needs to be a QObject, more specifically we want it to inherit from QWidget ...which is why SIP looks like such a good match. > > Would it be possible to create an object using SIP that I can inherit > > from and use the SIP api to convert into a CppPointer? > > If you have a C++ ctor for the object then that's exactly what SIP does, so > maybe what you want to do is more complicated than your are implying? So, if I inherit a C++ object from QWidget and write a sip binding, then I'm set. That's what I thought, but what I was hoping for was some way to automatically generate this "in between" object. Here is what I'm trying to do: Let's say I need to add some slots to QWidget and a couple of methods, I then need to embed this on a dialog box made by someone else in C++. That dialog box needs access to these additional methods and slots. >From what I'm seeing in the responses, I would write a C++ class(QMyddrin) that inherits from QWidget and adds these methods. Then my python ocde I would inherit from QMyddrin and it should all work as long as I do the conversion from Py_Object to CppPointer (I forget the call name.) That may be enough becuase I can probably modify some existing python introspection code that I have to spit out the .h, .cpp and .sip files fairly easily. > > Is there another/better way to achieve this? > > Phil > > The address of the PyKDE mailing list has changed. > > ___ > PyKDE mailing list[EMAIL PROTECTED] > http://mats.imk.fraunhofer.de/mailman/listinfo/pykde ___ PyKDE mailing list[EMAIL PROTECTED] http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
Re: [PyKDE] Using SIP to wrap python objects
On Thursday 12 June 2003 09:05 pm, Frederick Polgardy Jr wrote: > Why not write what's called (in "Patterns" speak) an Adaptor class: one > which provides its own interface, and keeps track of the Python objects it > needs to use internally. What kind of interface is the target application > expecting? That is basically what we would be looking for SIP to do, just as it does for C++ to python bindings. Basically, we would rather have someone send an hour writting a SIP definition than a few days writing a C++ class. The target interface is a QObject, so we though that sip would be a good start. > ___ > PyKDE mailing list[EMAIL PROTECTED] > http://mats.imk.fraunhofer.de/mailman/listinfo/pykde ___ PyKDE mailing list[EMAIL PROTECTED] http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
[PyKDE] Using SIP to wrap python objects
I've found myself in a position where I need to present a python object to a C++ object, and it needs to look like a C++ object. The target application knows nothing of python. Would it be possible to create an object using SIP that I can inherit from and use the SIP api to convert into a CppPointer? Is there another/better way to achieve this? ___ PyKDE mailing list[EMAIL PROTECTED] http://mats.imk.fraunhofer.de/mailman/listinfo/pykde