From frank at ohufx.com Mon Jan 4 08:15:12 2016 From: frank at ohufx.com (Frank Rueter | OHUfx) Date: Mon, 4 Jan 2016 20:15:12 +1300 Subject: [PySide] drawing text in dynamic box Message-ID: <568A1C00.5080300@ohufx.com> Happy 2016! I got a fun little challenge to kick off the new year: I need to draw some text in a custom painter() method. The incoming text is of arbitrary length and needs to be wrapped like so: painter.drawText(textbox, self._alignment|Qt.TextWordWrap, self._message) All good so far. I now need to paint a background box behind the text to make it more readable inside the main UI. Since the drawText() method is taking care of wrapping the text, I can't draw the background box before drawing the text like so: textbox = painter.drawText(textbox, self._alignment|Qt.TextWordWrap, self._message) painter.setBrush(QBrush(QColor(128,128,128))) painter.drawRect(textbox) This adjusts the box the way I need it to, but of course the box is now drawn on top of the text and occluding it. Two solutions spring to mind and I was what people with more QT experience would do: 1 - just draw the text again on top of the box like so: textbox = painter.drawText(textbox, self._alignment|Qt.TextWordWrap, self._message) # draw to get the bounding rectangle painter.setBrush(QBrush(QColor(128,128,128))) painter.drawRect(textbox) painter.setPen(Qt.white) painter.drawText(textbox, self._alignment|Qt.TextWordWrap, self._message) # draw again on top of the box 2 - invert the text and use it as an alpha channel to stencil out the background box so when it is painted after the text, it won't occlude it. Any opinions in terms of efficiency? Cheers, frank -- ohufxLogo 50x50 *vfx compositing | *workflow customisation and consulting * * -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: ohufxLogo_50x50.png Type: image/png Size: 2666 bytes Desc: not available URL: From frank at ohufx.com Sun Jan 10 21:48:06 2016 From: frank at ohufx.com (Frank Rueter | OHUfx) Date: Mon, 11 Jan 2016 09:48:06 +1300 Subject: [PySide] QStandardItemModel vs QAbstractItemModel Message-ID: <5692C386.9010307@ohufx.com> Hi, I am building a spreadsheet widget for custom data and will need many custom editors and item delegates. The amount of items will potentially be in the 100,000s and a lot of filtering will be going on. I started using the QStandardItemModel and so far things are working fine, but I haven't implemented the delegates or editors yet, and I will also have to override the data()/setData(). I'm wondering if I should switch to using the QAbstractItemModel before proceeding but can't make up my mind. I am using some of the QStandardItemModel's method's, such as clear() and item() and setItem(), but I guess those are easy to re-implement. The docs say that one should consider using QAbstractItemModel for efficiency and flexibility, but I am struggling to make an educated decision because I haven't used model/views often enough yet to know about all the pros and cons. Any advice on how to make that decision would be much appreciated. I'd hate to finish writing the code only to find out that it's too slow for large data sets, and then re-jig everything to use the QAbstractItemModel. Thanks, frank -- ohufxLogo 50x50 *vfx compositing | *workflow customisation and consulting * * -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: ohufxLogo_50x50.png Type: image/png Size: 2666 bytes Desc: not available URL: From frank at ohufx.com Tue Jan 12 21:22:04 2016 From: frank at ohufx.com (Frank Rueter | OHUfx) Date: Wed, 13 Jan 2016 09:22:04 +1300 Subject: [PySide] QStandardItemModel vs QAbstractItemModel In-Reply-To: <5692C386.9010307@ohufx.com> References: <5692C386.9010307@ohufx.com> Message-ID: <5695606C.6070001@ohufx.com> Anybody still on this list in 2016? :) On 11/01/16 9:48 am, Frank Rueter | OHUfx wrote: > Hi, > > I am building a spreadsheet widget for custom data and will need many > custom editors and item delegates. > The amount of items will potentially be in the 100,000s and a lot of > filtering will be going on. > > I started using the QStandardItemModel and so far things are working > fine, but I haven't implemented the delegates or editors yet, and I > will also have to override the data()/setData(). > > I'm wondering if I should switch to using the QAbstractItemModel > before proceeding but can't make up my mind. > I am using some of the QStandardItemModel's method's, such as clear() > and item() and setItem(), but I guess those are easy to re-implement. > > The docs say that one should consider using QAbstractItemModel for > efficiency and flexibility, but I am struggling to make an educated > decision because I haven't used model/views often enough yet to know > about all the pros and cons. > > Any advice on how to make that decision would be much appreciated. I'd > hate to finish writing the code only to find out that it's too slow > for large data sets, and then re-jig everything to use the > QAbstractItemModel. > > > Thanks, > frank > > -- > ohufxLogo 50x50 *vfx compositing > | *workflow customisation > and consulting * * > > > > _______________________________________________ > PySide mailing list > PySide at qt-project.org > http://lists.qt-project.org/mailman/listinfo/pyside -- ohufxLogo 50x50 *vfx compositing | *workflow customisation and consulting * * -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: image/png Size: 2666 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: ohufxLogo_50x50.png Type: image/png Size: 2666 bytes Desc: not available URL: From fries2 at llnl.gov Tue Jan 12 21:29:05 2016 From: fries2 at llnl.gov (Fries, Samuel) Date: Tue, 12 Jan 2016 20:29:05 +0000 Subject: [PySide] QStandardItemModel vs QAbstractItemModel In-Reply-To: <5695606C.6070001@ohufx.com> References: <5692C386.9010307@ohufx.com> <5695606C.6070001@ohufx.com> Message-ID: Hey Frank, I'm using QAbstractItemModel as the parent class in a couple of my MVC components. It was pretty easy to implement, and works nicely. I wrote the code using it a while back, so I don't really recall the impetus for not using QStandardItemModel (I'd wager it was my general preference to avoid QVariant). -Sam Fries AIMS Group, LLNL From: PySide > on behalf of Frank Rueter|OHUfx > Organization: OHUfx Date: Tuesday, January 12, 2016 12:22 PM To: PySide > Subject: Re: [PySide] QStandardItemModel vs QAbstractItemModel Anybody still on this list in 2016? :) On 11/01/16 9:48 am, Frank Rueter | OHUfx wrote: Hi, I am building a spreadsheet widget for custom data and will need many custom editors and item delegates. The amount of items will potentially be in the 100,000s and a lot of filtering will be going on. I started using the QStandardItemModel and so far things are working fine, but I haven't implemented the delegates or editors yet, and I will also have to override the data()/setData(). I'm wondering if I should switch to using the QAbstractItemModel before proceeding but can't make up my mind. I am using some of the QStandardItemModel's method's, such as clear() and item() and setItem(), but I guess those are easy to re-implement. The docs say that one should consider using QAbstractItemModel for efficiency and flexibility, but I am struggling to make an educated decision because I haven't used model/views often enough yet to know about all the pros and cons. Any advice on how to make that decision would be much appreciated. I'd hate to finish writing the code only to find out that it's too slow for large data sets, and then re-jig everything to use the QAbstractItemModel. Thanks, frank -- [ohufxLogo 50x50] vfx compositing | workflow customisation and consulting _______________________________________________ PySide mailing list PySide at qt-project.orghttp://lists.qt-project.org/mailman/listinfo/pyside -- [ohufxLogo 50x50] vfx compositing | workflow customisation and consulting -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: ATT00001.png Type: image/png Size: 2666 bytes Desc: ATT00001.png URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: ohufxLogo_50x50.png Type: image/png Size: 2666 bytes Desc: ohufxLogo_50x50.png URL: From frank at ohufx.com Tue Jan 12 21:32:04 2016 From: frank at ohufx.com (Frank Rueter | OHUfx) Date: Wed, 13 Jan 2016 09:32:04 +1300 Subject: [PySide] QStandardItemModel vs QAbstractItemModel In-Reply-To: References: <5692C386.9010307@ohufx.com> <5695606C.6070001@ohufx.com> Message-ID: <569562C4.3090907@ohufx.com> Thanks Sam, in PySide there is no QVariant anyway, so that's all good. I started yesterday trying to re-write what I already had going with QStandardItemModel using QAbstractTableModel, but it seems there is a lot I have to re-invent that QStandardTableModel already offered. I will keep going for learning purposes but would be very interested in any other opinions. Cheers, frank On 13/01/16 9:29 am, Fries, Samuel wrote: > Hey Frank, > > I'm using QAbstractItemModel as the parent class in a couple of my MVC > components. It was pretty easy to implement, and works nicely. I wrote > the code using it a while back, so I don't really recall the impetus > for not using QStandardItemModel (I'd wager it was my general > preference to avoid QVariant). > > -Sam Fries > AIMS Group, LLNL > > From: PySide > on behalf of Frank > Rueter|OHUfx > > Organization: OHUfx > Date: Tuesday, January 12, 2016 12:22 PM > To: PySide > > Subject: Re: [PySide] QStandardItemModel vs QAbstractItemModel > > Anybody still on this list in 2016? :) > > On 11/01/16 9:48 am, Frank Rueter | OHUfx wrote: >> Hi, >> >> I am building a spreadsheet widget for custom data and will need many >> custom editors and item delegates. >> The amount of items will potentially be in the 100,000s and a lot of >> filtering will be going on. >> >> I started using the QStandardItemModel and so far things are working >> fine, but I haven't implemented the delegates or editors yet, and I >> will also have to override the data()/setData(). >> >> I'm wondering if I should switch to using the QAbstractItemModel >> before proceeding but can't make up my mind. >> I am using some of the QStandardItemModel's method's, such as clear() >> and item() and setItem(), but I guess those are easy to re-implement. >> >> The docs say that one should consider using QAbstractItemModel for >> efficiency and flexibility, but I am struggling to make an educated >> decision because I haven't used model/views often enough yet to know >> about all the pros and cons. >> >> Any advice on how to make that decision would be much appreciated. >> I'd hate to finish writing the code only to find out that it's too >> slow for large data sets, and then re-jig everything to use the >> QAbstractItemModel. >> >> >> Thanks, >> frank >> >> -- >> ohufxLogo 50x50 *vfx compositing >> | *workflow >> customisation and consulting >> ** >> >> >> >> _______________________________________________ >> PySide mailing list >> PySide at qt-project.orghttp://lists.qt-project.org/mailman/listinfo/pyside > > -- > ohufxLogo 50x50 *vfx compositing > | *workflow customisation > and consulting ** > -- ohufxLogo 50x50 *vfx compositing | *workflow customisation and consulting * * -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: ohufxLogo_50x50.png Type: image/png Size: 2666 bytes Desc: not available URL: From chgans at gna.org Tue Jan 12 21:46:02 2016 From: chgans at gna.org (Ch'Gans) Date: Wed, 13 Jan 2016 09:46:02 +1300 Subject: [PySide] QStandardItemModel vs QAbstractItemModel In-Reply-To: <5692C386.9010307@ohufx.com> References: <5692C386.9010307@ohufx.com> Message-ID: Hi Frank, As you're question is not that specific to Python, you might have better luck asking on the qt-interest mailing list: http://lists.qt-project.org/mailman/listinfo/interest Chris On 11 January 2016 at 09:48, Frank Rueter | OHUfx wrote: > Hi, > > I am building a spreadsheet widget for custom data and will need many > custom editors and item delegates. > The amount of items will potentially be in the 100,000s and a lot of > filtering will be going on. > > I started using the QStandardItemModel and so far things are working fine, > but I haven't implemented the delegates or editors yet, and I will also > have to override the data()/setData(). > > I'm wondering if I should switch to using the QAbstractItemModel before > proceeding but can't make up my mind. > I am using some of the QStandardItemModel's method's, such as clear() and > item() and setItem(), but I guess those are easy to re-implement. > > The docs say that one should consider using QAbstractItemModel for > efficiency and flexibility, but I am struggling to make an educated > decision because I haven't used model/views often enough yet to know about > all the pros and cons. > > Any advice on how to make that decision would be much appreciated. I'd > hate to finish writing the code only to find out that it's too slow for > large data sets, and then re-jig everything to use the QAbstractItemModel. > > > Thanks, > frank > > -- > [image: ohufxLogo 50x50] *vfx compositing > | workflow customisation and > consulting * > > _______________________________________________ > PySide mailing list > PySide at qt-project.org > http://lists.qt-project.org/mailman/listinfo/pyside > > -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: ohufxLogo_50x50.png Type: image/png Size: 2666 bytes Desc: not available URL: From frank at ohufx.com Tue Jan 12 22:01:32 2016 From: frank at ohufx.com (Frank Rueter | OHUfx) Date: Wed, 13 Jan 2016 10:01:32 +1300 Subject: [PySide] QStandardItemModel vs QAbstractItemModel In-Reply-To: References: <5692C386.9010307@ohufx.com> Message-ID: <569569AC.50006@ohufx.com> Yikes, another mailing list. I'm running out of space in my email client. Thanks On 13/01/16 9:46 am, Ch'Gans wrote: > Hi Frank, > > As you're question is not that specific to Python, you might have > better luck asking on the qt-interest mailing list: > http://lists.qt-project.org/mailman/listinfo/interest > > Chris > > On 11 January 2016 at 09:48, Frank Rueter | OHUfx > wrote: > > Hi, > > I am building a spreadsheet widget for custom data and will need > many custom editors and item delegates. > The amount of items will potentially be in the 100,000s and a lot > of filtering will be going on. > > I started using the QStandardItemModel and so far things are > working fine, but I haven't implemented the delegates or editors > yet, and I will also have to override the data()/setData(). > > I'm wondering if I should switch to using the QAbstractItemModel > before proceeding but can't make up my mind. > I am using some of the QStandardItemModel's method's, such as > clear() and item() and setItem(), but I guess those are easy to > re-implement. > > The docs say that one should consider using QAbstractItemModel for > efficiency and flexibility, but I am struggling to make an > educated decision because I haven't used model/views often enough > yet to know about all the pros and cons. > > Any advice on how to make that decision would be much appreciated. > I'd hate to finish writing the code only to find out that it's too > slow for large data sets, and then re-jig everything to use the > QAbstractItemModel. > > > Thanks, > frank > > -- > ohufxLogo 50x50 *vfx compositing > | *workflow > customisation and consulting > * * > > > _______________________________________________ > PySide mailing list > PySide at qt-project.org > http://lists.qt-project.org/mailman/listinfo/pyside > > -- ohufxLogo 50x50 *vfx compositing | *workflow customisation and consulting * * -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: image/png Size: 2666 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: ohufxLogo_50x50.png Type: image/png Size: 2666 bytes Desc: not available URL: From me at the-compiler.org Wed Jan 13 08:15:36 2016 From: me at the-compiler.org (Florian Bruhin) Date: Wed, 13 Jan 2016 08:15:36 +0100 Subject: [PySide] QStandardItemModel vs QAbstractItemModel In-Reply-To: <569562C4.3090907@ohufx.com> References: <5692C386.9010307@ohufx.com> <5695606C.6070001@ohufx.com> <569562C4.3090907@ohufx.com> Message-ID: <20160113071536.GD6846@tonks> * Frank Rueter | OHUfx [2016-01-13 09:32:04 +1300]: > in PySide there is no QVariant anyway, so that's all good. > I started yesterday trying to re-write what I already had going with > QStandardItemModel using QAbstractTableModel, but it seems there is a lot I > have to re-invent that QStandardTableModel already offered. I will keep > going for learning purposes but would be very interested in any other > opinions. I can only tell you about my experience with PyQt5 and QAbstractItemModel. Granted, it was only a few months after I started learning PyQt (or Qt, for that matter) - but it wasn't really pleasant. I tried to create a simple QAbstractItemModel based on a Python dict. You can find the latest source (before I ditched it) which worked (I think) here: https://github.com/The-Compiler/qutebrowser/blob/bc02df0bded309331220472a076ddac976afbec0/qutebrowser/models/basecompletion.py While developing it, every small mistake would give me a segfault somewhere inside Qt. I then discovered QStandardItemModel: https://github.com/The-Compiler/qutebrowser/commit/1eabbfbfcf9da58975c00dbc190e198c28473921 The implementation using that turned out to be 300 lines of deleted code (compared to QSIM), noticably faster with some dozens of items (I'd dare to say almost double as fast), and probably more stable. I wrote some more specialized QAbstractItemModels since then and they were less of a pain, though. I can also recommend using the Qt5 modeltest to test if your model behaves properly. There's a PyQt5 port here which is standalone, but I don't think it works with PySide: https://github.com/bgr/PyQt5_modeltest I'm trying to integrate an updated version which works with PyQt4/PyQt5/PySide into pytest-qt: https://github.com/pytest-dev/pytest-qt/pull/63/files It shouldn't be too much work to get it to run standalone though, and it's sure worth the helpful information it gives you compared to painfully debugging stuff by hand ;) Florian -- http://www.the-compiler.org | me at the-compiler.org (Mail/XMPP) GPG: 916E B0C8 FD55 A072 | 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: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: From frank at ohufx.com Wed Jan 13 08:25:21 2016 From: frank at ohufx.com (Frank Rueter | OHUfx) Date: Wed, 13 Jan 2016 20:25:21 +1300 Subject: [PySide] QStandardItemModel vs QAbstractItemModel In-Reply-To: <20160113071536.GD6846@tonks> References: <5692C386.9010307@ohufx.com> <5695606C.6070001@ohufx.com> <569562C4.3090907@ohufx.com> <20160113071536.GD6846@tonks> Message-ID: <5695FBE1.505@ohufx.com> Thanks Florian, with QATM I got up to the point of implementing custom background colours depending on what row the cell belongs to, and I noticed it was so insanely slow with only a tiny bit of data that I switched back to StandardItemModel for now, which is nice and fast - so far. The slowness was due to me doing too many calls to the host application inside the data() method, and once I thought about how to do all that outside of data(), I realised the StandardItemModel would be much more suited for my approach. So I decided to keep going with that until I hit a road block that may turn me back and reconsider, but hopefully that won't happen. I have another issue now with item delegates but it's unrelated to this topic, so I will start a new thread shortly. Cheers and thanks again Florian andSam for your input, frank On 13/01/16 8:15 pm, Florian Bruhin wrote: > * Frank Rueter | OHUfx [2016-01-13 09:32:04 +1300]: >> in PySide there is no QVariant anyway, so that's all good. >> I started yesterday trying to re-write what I already had going with >> QStandardItemModel using QAbstractTableModel, but it seems there is a lot I >> have to re-invent that QStandardTableModel already offered. I will keep >> going for learning purposes but would be very interested in any other >> opinions. > I can only tell you about my experience with PyQt5 and > QAbstractItemModel. > > Granted, it was only a few months after I started learning PyQt > (or Qt, for that matter) - but it wasn't really pleasant. > > I tried to create a simple QAbstractItemModel based on a Python dict. > You can find the latest source (before I ditched it) which worked (I > think) here: > > https://github.com/The-Compiler/qutebrowser/blob/bc02df0bded309331220472a076ddac976afbec0/qutebrowser/models/basecompletion.py > > While developing it, every small mistake would give me a segfault > somewhere inside Qt. > > I then discovered QStandardItemModel: > > https://github.com/The-Compiler/qutebrowser/commit/1eabbfbfcf9da58975c00dbc190e198c28473921 > > The implementation using that turned out to be 300 lines of deleted > code (compared to QSIM), noticably faster with some dozens of items > (I'd dare to say almost double as fast), and probably more stable. > > I wrote some more specialized QAbstractItemModels since then and they > were less of a pain, though. > > I can also recommend using the Qt5 modeltest to test if your model > behaves properly. > > There's a PyQt5 port here which is standalone, but I don't think it > works with PySide: https://github.com/bgr/PyQt5_modeltest > > I'm trying to integrate an updated version which works with > PyQt4/PyQt5/PySide into pytest-qt: > > https://github.com/pytest-dev/pytest-qt/pull/63/files > > It shouldn't be too much work to get it to run standalone though, and > it's sure worth the helpful information it gives you compared to > painfully debugging stuff by hand ;) > > Florian > -- ohufxLogo 50x50 *vfx compositing | *workflow customisation and consulting * * -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: ohufxLogo_50x50.png Type: image/png Size: 2666 bytes Desc: not available URL: From htatein123 at gmail.com Thu Jan 14 22:57:38 2016 From: htatein123 at gmail.com (Hannu Tatein) Date: Thu, 14 Jan 2016 16:57:38 -0500 Subject: [PySide] QPixmap memory leak Message-ID: Hi Pyside Experts, I have written a GUI/Image viewer using Pyside. It works perfectly for my purpose except that as I browse through the images, the memory consumption of computer increases. The code snippet that is responsible for the memory leak is this: self.pixmap = QtGui.QPixmap(str(self.nb) + "_" + str(self.fig_type) + ".jpeg") self.pixmap = self.pixmap.scaled(1000, 4000, QtCore.Qt.KeepAspectRatio, mode=QtCore.Qt. SmoothTransformation) self.lbl.setPixmap(self.pixmap) if not self.added_lbl: self.layoutImW.addWidget(self.lbl) self.added_lbl = True self.lbl.setGeometry(500, 500, self.pixmap.width(), self.pixmap.height()) Actually it is the first statement of the code snippet that is the root of all the evil. If instead of the variables : 'self.nb' and 'self.fig_type', I try to load the same image, I don't face the problem. Is there any way to avoid the memory leak? I tried QtGui.QPixmap.deref() before the first image, it does seem to work. If any part of the code is not clear, please let me know and I will get back to you immediately. Thanks you very much, Hannu -------------- next part -------------- An HTML attachment was scrubbed... URL: From me at the-compiler.org Fri Jan 15 06:11:36 2016 From: me at the-compiler.org (Florian Bruhin) Date: Fri, 15 Jan 2016 06:11:36 +0100 Subject: [PySide] QPixmap memory leak In-Reply-To: References: Message-ID: <20160115051136.GC22730@tonks> * Hannu Tatein [2016-01-14 16:57:38 -0500]: > Hi Pyside Experts, I'm by no means a PySide expert (hell, I never used it :P) but let me share my thoughts anyways ;) > Is there any way to avoid the memory leak? I tried QtGui.QPixmap.deref() > before the first image, it does seem to work. Have you tried to do self.pixmap.deleteLater() when you're done with it? Maybe it works with the same image due to Qt's implicit data sharing: http://doc.qt.io/qt-4.8/implicit-sharing.html Florian -- http://www.the-compiler.org | me at the-compiler.org (Mail/XMPP) GPG: 916E B0C8 FD55 A072 | 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: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: From bazwal at gmail.com Fri Jan 15 18:06:07 2016 From: bazwal at gmail.com (Baz Walter) Date: Fri, 15 Jan 2016 17:06:07 +0000 Subject: [PySide] QPixmap memory leak In-Reply-To: References: Message-ID: <569926FF.50301@gmail.com> On 14/01/16 21:57, Hannu Tatein wrote: > Hi Pyside Experts, > > I have written a GUI/Image viewer using Pyside. It works perfectly for my > purpose except that as I browse through the images, the memory consumption > of computer increases. From the Qt docs[1]: Note that QPixmaps are automatically added to the QPixmapCache when loaded from a file If you're worried about memory consumption, you can periodically call: QPixmapCache.clear() [1] http://doc.qt.io/qt-4.8/qpixmap.html#load From heng at cantab.net Tue Jan 19 22:54:41 2016 From: heng at cantab.net (Henry Gomersall) Date: Tue, 19 Jan 2016 21:54:41 +0000 Subject: [PySide] building 64-bit pyside windows extensions Message-ID: <569EB0A1.2010009@cantab.net> I have a little qml utility that is written in C for adding a bit of functionality I need. I can compile this just fine on Linux and (just about) on Windows 32-bit, but I'm struggling to work out how to do this on Windows 64-bit. The problem is firstly that I'm not quite sure what the pyside 64-bit Qt was compiled with (perhaps the version recommended for python?), and secondly whether I then need to build Qt myself using the same approach so I have the necessary support libraries to build against. Or can I build against the installed libraries from pyside somehow? Any advice on this would be much appreciated. Thanks, Henry From frank at ohufx.com Sat Jan 23 01:07:06 2016 From: frank at ohufx.com (Frank Rueter | OHUfx) Date: Sat, 23 Jan 2016 13:07:06 +1300 Subject: [PySide] QTableView - auto check item when row is selecte Message-ID: <56A2C42A.4060700@ohufx.com> Hi all, I'm writing a simple table view to display a selection of files available in a repository for the user to select for download. Using the model/view approach I have set the item to isCheckable(True). The one tweak in behaviour I am trying to introduce is that I'd like the checkboxes to auto-adjust according to the respective rows selection state, so that the user can drag over a bunch of rows to check the boxes, rather than having to click multiple times. So I implemented the view's selectionChanged() virtual function to drive the checkboxes for the selected/deselected items. This works perfectly fine, the only hiccup I'm seeing is that when clicking on an unchecked checkbox directly, it won't be checked the first time, only the second time, when the respective row is selected as well, will the click cause the checkbox to be checked. Interestingly, the culprit seems to be this block in selectionChanged(): for i in selected.indexes(): # this causes checkboxes to not be checked unless the respective row is selected item = self.model().itemFromIndex(i) item.setCheckState(Qt.Checked) I also tried adding this to no avail: super(FileChoserView, self).selectionChanged(selected, deselected) How can I fix this little glitch? Or should I be doing this in an entirely different way? Below is the entire test code (raw and in pastebin link). Thanks in advance for any advise, frank http://pastebin.com/T3tSgWRr from PySide.QtGui import * from PySide.QtCore import * class FileModel(QStandardItemModel): def __init__(self, toolData, parent=None): super(FileModel, self).__init__(parent) self.containers = [] self.headerLabels = ['file name'] self.dataDict = toolData self.setUp() def setUp(self): '''fill model with data''' self.clear() for row, file_ in enumerate(self.dataDict['files']): fileItem = QStandardItem(file_['filename']) fileItem.setCheckable(True) font = QApplication.font() font.setPointSize(10) fileItem.setFont(font) self.setItem(row, 0, fileItem) self.setHorizontalHeaderLabels(self.headerLabels) class FileChoserView(QTableView): def __init__(self, parent=None): super(FileChoserView, self).__init__(parent) self.setSortingEnabled(True) self.setEditTriggers(QAbstractItemView.NoEditTriggers) self.horizontalHeader().setStretchLastSection(True) self.setSelectionBehavior(QAbstractItemView.SelectRows) self.setContextMenuPolicy(Qt.ActionsContextMenu) horizontalHeader = self.horizontalHeader() self.verticalHeader().hide() def selectionChanged(self, selected, deselected): '''Check item when row is selected''' for i in selected.indexes(): # this causes checkboxes to not be checked unless the respective row is selected self.model().itemFromIndex(i).setCheckState(Qt.Checked) for i in deselected.indexes(): self.model().itemFromIndex(i).setCheckState(Qt.Unchecked) if __name__ == '__main__': import sys app = QApplication([]) testData = {'files':[dict(filename='file_{}.zip'.format(i)) for i in xrange(10)]} w = FileChoserView() model = FileModel(testData) w.setModel(model) w.show() sys.exit(app.exec_()) -- ohufxLogo 50x50 *vfx compositing | *workflow customisation and consulting * * -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: ohufxLogo_50x50.png Type: image/png Size: 2666 bytes Desc: not available URL: From sebastian at risefx.com Sat Jan 23 13:19:06 2016 From: sebastian at risefx.com (Sebastian Elsner) Date: Sat, 23 Jan 2016 13:19:06 +0100 Subject: [PySide] QTableView - auto check item when row is selecte In-Reply-To: <56A2C42A.4060700@ohufx.com> References: <56A2C42A.4060700@ohufx.com> Message-ID: <56A36FBA.5000504@risefx.com> Hey, you could use the view's QItemSeletionModel and its "currentChanged" signal. However, I find this a bit weird from an UX point of view. This is what the |QAbstractItemView::ExtendedSelection and ||QAbstractItemView::MultiSelection are for if I understand you correctly. Cheers Sebastian | On 01/23/2016 01:07 AM, Frank Rueter | OHUfx wrote: > Hi all, > > I'm writing a simple table view to display a selection of files > available in a repository for the user to select for download. > Using the model/view approach I have set the item to isCheckable(True). > The one tweak in behaviour I am trying to introduce is that I'd like the > checkboxes to auto-adjust according to the respective rows selection > state, so that the user can drag over a bunch of rows to check the > boxes, rather than having to click multiple times. > So I implemented the view's selectionChanged() virtual function to drive > the checkboxes for the selected/deselected items. > > This works perfectly fine, the only hiccup I'm seeing is that when > clicking on an unchecked checkbox directly, it won't be checked the > first time, only the second time, when the respective row is selected > as well, will the click cause the checkbox to be checked. > Interestingly, the culprit seems to be this block in selectionChanged(): > for i in selected.indexes(): > # this causes checkboxes to not be checked unless the > respective row is selected > item = self.model().itemFromIndex(i) > item.setCheckState(Qt.Checked) > > > I also tried adding this to no avail: > super(FileChoserView, self).selectionChanged(selected, deselected) > > > How can I fix this little glitch? Or should I be doing this in an > entirely different way? > Below is the entire test code (raw and in pastebin link). > > Thanks in advance for any advise, > frank > > > > http://pastebin.com/T3tSgWRr > > > from PySide.QtGui import * > from PySide.QtCore import * > > > class FileModel(QStandardItemModel): > > def __init__(self, toolData, parent=None): > super(FileModel, self).__init__(parent) > self.containers = [] > self.headerLabels = ['file name'] > self.dataDict = toolData > self.setUp() > > def setUp(self): > '''fill model with data''' > > self.clear() > for row, file_ in enumerate(self.dataDict['files']): > fileItem = QStandardItem(file_['filename']) > fileItem.setCheckable(True) > font = QApplication.font() > font.setPointSize(10) > fileItem.setFont(font) > self.setItem(row, 0, fileItem) > > self.setHorizontalHeaderLabels(self.headerLabels) > > > class FileChoserView(QTableView): > > def __init__(self, parent=None): > super(FileChoserView, self).__init__(parent) > self.setSortingEnabled(True) > self.setEditTriggers(QAbstractItemView.NoEditTriggers) > self.horizontalHeader().setStretchLastSection(True) > self.setSelectionBehavior(QAbstractItemView.SelectRows) > self.setContextMenuPolicy(Qt.ActionsContextMenu) > horizontalHeader = self.horizontalHeader() > self.verticalHeader().hide() > > def selectionChanged(self, selected, deselected): > '''Check item when row is selected''' > > for i in selected.indexes(): > # this causes checkboxes to not be checked unless the > respective row is selected > self.model().itemFromIndex(i).setCheckState(Qt.Checked) > > for i in deselected.indexes(): > self.model().itemFromIndex(i).setCheckState(Qt.Unchecked) > > > if __name__ == '__main__': > import sys > app = QApplication([]) > testData = {'files':[dict(filename='file_{}.zip'.format(i)) for i > in xrange(10)]} > > w = FileChoserView() > model = FileModel(testData) > w.setModel(model) > w.show() > sys.exit(app.exec_()) > > > -- > ohufxLogo 50x50 *vfx compositing > | *workflow customisation > and consulting * * > > _______________________________________________ > PySide mailing list > PySide at qt-project.org > http://lists.qt-project.org/mailman/listinfo/pyside -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: image/png Size: 2666 bytes Desc: not available URL: From toddrme2178 at gmail.com Thu Jan 28 12:46:22 2016 From: toddrme2178 at gmail.com (Todd Rme) Date: Thu, 28 Jan 2016 12:46:22 +0100 Subject: [PySide] Python 3.5 support In-Reply-To: References: Message-ID: Any news on python 3.5 support? This and Cython are the only packages still preventing openSUSE from switching to python 3.5.1. On Nov 3, 2015 18:07, "Todd Rme" wrote: > Hi everyone, > > Currently, Shiboken has it hard-coded in its cmake files that it only > supports python up to 3.4. Python 3.5, however, has been out since > September. Would it be possible to allow Shiboken to install on > Python 3.5? > > Thanks a lot! > -------------- next part -------------- An HTML attachment was scrubbed... URL: