From thomson.eric at gmail.com Mon Sep 1 23:08:43 2014 From: thomson.eric at gmail.com (Eric Thomson) Date: Mon, 1 Sep 2014 17:08:43 -0400 Subject: [PySide] Contributing to documentation? Message-ID: As I learn PySide, the online documentation is my lifeline, but there are quite a few gaps. For instance, at http://pyside.github.io/docs/pyside/PySide/QtCore/QMimeData.html, we have the following: "There are three approaches for storing custom data in a PySide.QtCore.QMimeData object: " And then...nothing. It does not list the three approaches, which are described at the Qt documentation in some detail (http://doc.qt.digia.com/4.6/qmimedata.html). There it is obviously for C++ users, obviously. I would really like to help translate some of this stuff into Python, where I can, but am not sure how to go about helping, or if such work would even last. For instance, would such contributions be lost when documentation is automatically updated? From nathan.warmerdam at gmail.com Sat Sep 13 01:22:27 2014 From: nathan.warmerdam at gmail.com (Nathan Warmerdam) Date: Fri, 12 Sep 2014 16:22:27 -0700 Subject: [PySide] PySide Pitfalls Message-ID: Hello all, First let me say that using PySide has been a real dream come true. Its easy, intuitive and fast. Combined with the Designer tools it really makes for an incredibly powerful (i would even venture fun) workflow for pumping out nice GUIs. I've created an application that where a QDialog opens up, allows the user to do a few things, and in some cases launches another QDialog that contains a bit more functionality. I used Designer to make the UI's and follow the appropriate steps to integrated them with my code (setupUI). It talks to a sqlite database behind the scenes and lets the user make a few changes. Nothing very complicated at all. Simple even. Everything was going so incredibly well until I had my first hard crash (of the "python stopped working" variety). With my limited means I've tried all that I know short of installing Visual Studio and debugging python to figure out what is going on. The event log suggests that the faulting module causing the issue is "PySide\pyside-python2.7.dll" The gist of my question is: Are there known gotchas that cause crashes? I cannot post my code however are there well known gotchas associated with QPushButton, QComboBox, QListWidget or even launching another Dialog which I could investigate or try? The crash doesn't come after a certain sequence of events but instead appears to be, dare i say it, random. I've commented code out and googled my butt off but i haven't found any one thing that seems to cause the problem. TL;DR - What are some common gotchas that can lead to a crash even in a simple PySide application. Thanks, Nathan Warmerdam -------------- next part -------------- An HTML attachment was scrubbed... URL: From sdeibel at wingware.com Mon Sep 15 16:12:40 2014 From: sdeibel at wingware.com (Stephan Deibel) Date: Mon, 15 Sep 2014 10:12:40 -0400 Subject: [PySide] PySide Pitfalls In-Reply-To: References: Message-ID: <5416F3D8.7010803@wingware.com> Nathan Warmerdam wrote: > TL;DR - What are some common gotchas that can lead to a crash even in > a simple PySide application. One is trying to keep a reference to any wrapped object that is not a descendent of QObject. There is no life cycle management so the underlying C++ object can be freed and the Python reference can even be replaced with another C++ object. I've seen this with QEvents in the context of event filters and it also applies to QIcon, QStandardItem, and QListWidgetItem, which maybe is a clue to why it crashed in your case. Not sure if this will be helpful or not but it's worth knowing about... - Stephan From dev at famillepinault.fr Mon Sep 15 22:26:55 2014 From: dev at famillepinault.fr (Nicolas Pinault) Date: Mon, 15 Sep 2014 22:26:55 +0200 Subject: [PySide] PySide Pitfalls In-Reply-To: <5416F3D8.7010803@wingware.com> References: <5416F3D8.7010803@wingware.com> Message-ID: <54174B8F.4080707@famillepinault.fr> Le 15/09/2014 16:12, Stephan Deibel a écrit : > Nathan Warmerdam wrote: >> TL;DR - What are some common gotchas that can lead to a crash even in >> a simple PySide application. > One is trying to keep a reference to any wrapped object that is not a > descendent of QObject. There is no life cycle management so the > underlying C++ object can be freed and the Python reference can even be > replaced with another C++ object. I've seen this with QEvents in the > context of event filters and it also applies to QIcon, QStandardItem, > and QListWidgetItem, which maybe is a clue to why it crashed in your case. > > Not sure if this will be helpful or not but it's worth knowing about... > > - Stephan This article link has been posted here few weeks ago : http://enki-editor.org/2014/08/23/Pyqt_mem_mgmt.html Nicolas > > _______________________________________________ > PySide mailing list > PySide at qt-project.org > http://lists.qt-project.org/mailman/listinfo/pyside From jmohler at gamry.com Tue Sep 16 13:31:28 2014 From: jmohler at gamry.com (Joel B. Mohler) Date: Tue, 16 Sep 2014 07:31:28 -0400 Subject: [PySide] PySide Pitfalls In-Reply-To: <5416F3D8.7010803@wingware.com> References: <5416F3D8.7010803@wingware.com> Message-ID: <54181F90.2080203@gamry.com> On 9/15/2014 10:12 AM, Stephan Deibel wrote: > Nathan Warmerdam wrote: >> TL;DR - What are some common gotchas that can lead to a crash even in >> a simple PySide application. > One is trying to keep a reference to any wrapped object that is not a > descendent of QObject. There is no life cycle management so the > underlying C++ object can be freed and the Python reference can even be > replaced with another C++ object. I've seen this with QEvents in the > context of event filters and it also applies to QIcon, QStandardItem, > and QListWidgetItem, which maybe is a clue to why it crashed in your case. In similar spirit (although these are QObject derived), I have had troubles with QMenu usages causing trouble if I don't hold a python reference to the QMenu. I have also have crashes when I don't hold a reference to the QItemSelectionModel returned from QAbstractItemView::selectionModel(). QItemSelectionModel issues: https://gist.github.com/jbmohler/861eb9e16b209cb938ff (no crashes as posted, but see OPTION comments); I think this is simply a ridiculous bug and I can't really fathom it. I have no luck reproducing the QMenu issue right now in a snippet so that's no help to you -- and it may be a figment of my imagination. Joel From me at the-compiler.org Tue Sep 16 13:38:39 2014 From: me at the-compiler.org (Florian Bruhin) Date: Tue, 16 Sep 2014 13:38:39 +0200 Subject: [PySide] PySide Pitfalls In-Reply-To: <54181F90.2080203@gamry.com> References: <5416F3D8.7010803@wingware.com> <54181F90.2080203@gamry.com> Message-ID: <20140916113839.GH2118@lupin> * Joel B. Mohler [2014-09-16 07:31:28 -0400]: > On 9/15/2014 10:12 AM, Stephan Deibel wrote: > > Nathan Warmerdam wrote: > >> TL;DR - What are some common gotchas that can lead to a crash even in > >> a simple PySide application. > > One is trying to keep a reference to any wrapped object that is not a > > descendent of QObject. There is no life cycle management so the > > underlying C++ object can be freed and the Python reference can even be > > replaced with another C++ object. I've seen this with QEvents in the > > context of event filters and it also applies to QIcon, QStandardItem, > > and QListWidgetItem, which maybe is a clue to why it crashed in your case. I already deleted the older mails in this thread, but today I just stumbled upon http://stackoverflow.com/a/11945184/2085149 which lists some other common reasons. While the question is for PyQt, the answer also elaborates on some PySide-specifics. Sorry if it was already mentioned before. Florian -- http://www.the-compiler.org | me at the-compiler.org (Mail/XMPP) GPG 0xFD55A072 | http://the-compiler.org/pubkey.asc I love long mails! | http://email.is-not-s.ms/ -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 819 bytes Desc: not available URL: From nathan.warmerdam at gmail.com Mon Sep 15 21:57:46 2014 From: nathan.warmerdam at gmail.com (Nathan Warmerdam) Date: Mon, 15 Sep 2014 12:57:46 -0700 Subject: [PySide] PySide Pitfalls In-Reply-To: <54172C36.2060104@wingware.com> References: <5416F3D8.7010803@wingware.com> <54172C36.2060104@wingware.com> Message-ID: Hi Stephen/All, Thank you again for responding. 1. Should I refrain from using QListWidget to avoid the QListWidgetItem and just go with QListView or does that really not make a difference in this context? 2. I've used some logging to figure out when the crash occurs and more often than not it happens when my main window is constructing a new dialog to open. I pass a pretty simple python class between the two. Should I refrain from doing that? 3. I use the Designer to create my window/dialog and call setupUi. Is this known to be stable? Thank you again, Nathan On Mon, Sep 15, 2014 at 11:13 AM, Stephan Deibel wrote: > Nathan Warmerdam wrote: > >> Thank you for your reply, it is greatly appreciated. Would such a crash >> appear to happen inconsistently? As in not necessarily when accessing a >> QListWidgetItem? Or would it definitely happen when the code was looking >> at the item? >> > > I think it's inconsistent except maybe in the simplest cases. I'm not > really sure of all the ramifications, although I've seen crashes in PySide > internals that seemed to result from mishandling QIcon. So it's not > necessarily when the item gets accessed by you but also internally. I've > not been able to debug the problem at the C/C++ level so I don't really > fully understand its constraints. > > - Stephan > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From me at the-compiler.org Tue Sep 16 15:56:45 2014 From: me at the-compiler.org (Florian Bruhin) Date: Tue, 16 Sep 2014 15:56:45 +0200 Subject: [PySide] PySide Pitfalls In-Reply-To: References: <5416F3D8.7010803@wingware.com> <54172C36.2060104@wingware.com> Message-ID: <20140916135645.GN2118@lupin> Hi again, * Nathan Warmerdam [2014-09-15 12:57:46 -0700]: > 2. I've used some logging to figure out when the crash occurs and more > often than not it happens when my main window is constructing a new dialog > to open. I pass a pretty simple python class between the two. Should I > refrain from doing that? Showing the exact code might help. Also, I've found using a trace function (which prints every line executed) is very useful for debugging segfaults. Here is the one I use: http://git.the-compiler.org/qutebrowser/tree/qutebrowser/utils/debug.py?id=6b8c597d18532d5c8ff33f380c43e8afbec8d56c#n93 utils.compact_text used there just removes newlines and elides long texts, it's defined here: http://git.the-compiler.org/qutebrowser/tree/qutebrowser/utils/utils.py?id=4caec2becbfb7156d58643ec083106adf3f31633#n41 Also using the faulthandler module helps a lot if the crash is happening outside the Qt mainloop as well, as it prints the Python stacktrace during a segfault. For python3.3+: https://docs.python.org/dev/library/faulthandler.html For older versions: https://pypi.python.org/pypi/faulthandler/ > 3. I use the Designer to create my window/dialog and call setupUi. Is this > known to be stable? I've never had problems with that. Florian -- http://www.the-compiler.org | me at the-compiler.org (Mail/XMPP) GPG 0xFD55A072 | http://the-compiler.org/pubkey.asc I love long mails! | http://email.is-not-s.ms/ -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 819 bytes Desc: not available URL: From nathan.warmerdam at gmail.com Tue Sep 16 17:47:46 2014 From: nathan.warmerdam at gmail.com (Nathan Warmerdam) Date: Tue, 16 Sep 2014 08:47:46 -0700 Subject: [PySide] PySide Pitfalls Message-ID: Thank you to all for responding, it is greatly appreciated. I will take these comments and grind on the code. Hopefully the offending code will be found and eradicated. I've been having too much fun to allow a little seg fault to stop me ;) Nathan Warmerdam -------------- next part -------------- An HTML attachment was scrubbed... URL: From nathan.warmerdam at gmail.com Tue Sep 16 19:41:31 2014 From: nathan.warmerdam at gmail.com (Nathan Warmerdam) Date: Tue, 16 Sep 2014 10:41:31 -0700 Subject: [PySide] PySide Pitfalls Message-ID: Success! I figured out my crash and fixed it. Using the hints supplied here on this mailing list I was able to narrow down the problem and figure it out through a little trial and error. So here is my contribution to the "PySide Gotchas": Beware populating a QListWidget using the addItems method. In my case I was calling "clear()" and "addItems" with a list of strings quite frequently. The crash tended to happen shortly after this code would execute (but never exactly at that point). When I changed this to use a loop with QListWidgetItem(string, some_list_widget), my crash went away. I'm assuming this has to do with explicitly making the QListWdigetItem instead of having it implicitly made behind the scenes, but that is pure speculation. You can certainly argue that perhaps I'm not using the QListWidget correctly but the above scenario should still be noted. Thanks again for all the tips! Nathan -------------- next part -------------- An HTML attachment was scrubbed... URL: From swdev.bali at gmail.com Mon Sep 22 01:24:19 2014 From: swdev.bali at gmail.com (Eko Wibowo) Date: Mon, 22 Sep 2014 06:24:19 +0700 Subject: [PySide] Pyside for iOS? Message-ID: <541F5E23.6000200@gmail.com> Hi, Currently I am researching whether we can do PySide for mobile development for Android and iOS. I have tried PySide for Android, and it works well : http://qt-project.org/wiki/PySide_for_Android_guide But, is there any work mentioned for the PySide for iOS? Haven't found any mention for that Thanks, Eko From pflegit at gmail.com Tue Sep 30 01:50:01 2014 From: pflegit at gmail.com (Pat Flegit) Date: Mon, 29 Sep 2014 19:50:01 -0400 Subject: [PySide] Catching WM_HOTKEY events In-Reply-To: References: Message-ID: Hi, first I should specify that I’m using PySide on Windows. I’m rigging together a custom global hotkey solution (there aren’t many existing libraries that have support for global hotkeys) on Win32, which is pretty easy to do. I already have it so that Windows sends my application a standard WM_HOTKEY event (message ID=786). I’ve tried a few ways of catching this event. The first way, which actually worked when using PyQt4, was using QAbstractEventDispatcher with setEventFilter, as exemplified here: http://www.riverbankcomputing.com/pipermail/pyqt/2011-March/029449.html . When message.message is 786, access message.wParam to get the details of which global hotkey was pressed. Success! However, PySide for some reason does not have a setEventFilter function, so I went looking for other solutions. Installing an event filter on my main window failed, it never gets any messages at all at the point in time at which I press the hotkey (although it does get messages when any non-global-hotkey keys are pressed). I also failed to create a custom event loop. I can create a loop to call app.processEvents() instead of using app.exec() directly, but what I really need is an infinite loop to catch Win32 events using GetMessage(), which doesn’t really work with my existing loop. Right now, I’m out of ideas. If only PySide had setEventFilter support… What do you think? Is there some way to catch the WM_HOTKEY event? -------------- next part -------------- An HTML attachment was scrubbed... URL: