Re: [PyQt] Bugs galore in QAbstractTableModel???
On Sat, Nov 27, 2010 at 9:42 PM, Baz Walter wrote: > On 27/11/10 23:02, Ian wrote: >> >> On 27/11/2010 22:23, Baz Walter wrote: >>> >>> the python version andreas is referring to is "modeltest.py". it can >>> be found in the pyqt source in the contrib/pymodeltest directory. >>> >> I found the version I think I need (4.7.4) at >> >> http://python-qt4.sourcearchive.com/documentation/4.7.4-0ubuntu1/modeltest_8py-source.html >> >> >> I have been unable to find out how to run it - so guessing I tried this. > > that link doesn't show all of the contents of the source - it's missing the > README file. here's the relevant part: > > > > To Use the model test do the following: > > 1) Include the modeltest.py file in your project directory > > 2) Then in your source import "modeltest" and instantiate ModelTest > with your model so the test can live for the lifetime of your model. > > For example: > > from modeltest import ModelTest > > self.model = QDirModel(self) > self.modeltest = ModelTest(self.model, self) > > 3) That is it. When the test finds a problem it will throw an > AssertionError. modeltest.py contains some hints on how to fix > problems that the test finds. > > > ___ > PyQt mailing list p...@riverbankcomputing.com > http://www.riverbankcomputing.com/mailman/listinfo/pyqt > I found an updated version of the file here: http://bazaar.launchpad.net/~bzr/ubuntu/maverick/qbzr/bzr-ppa/annotate/head:/lib/tests/modeltest.py -- Steve Borho ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Bugs galore in QAbstractTableModel???
On 27/11/10 23:02, Ian wrote: On 27/11/2010 22:23, Baz Walter wrote: the python version andreas is referring to is "modeltest.py". it can be found in the pyqt source in the contrib/pymodeltest directory. I found the version I think I need (4.7.4) at http://python-qt4.sourcearchive.com/documentation/4.7.4-0ubuntu1/modeltest_8py-source.html I have been unable to find out how to run it - so guessing I tried this. that link doesn't show all of the contents of the source - it's missing the README file. here's the relevant part: To Use the model test do the following: 1) Include the modeltest.py file in your project directory 2) Then in your source import "modeltest" and instantiate ModelTest with your model so the test can live for the lifetime of your model. For example: from modeltest import ModelTest self.model = QDirModel(self) self.modeltest = ModelTest(self.model, self) 3) That is it. When the test finds a problem it will throw an AssertionError. modeltest.py contains some hints on how to fix problems that the test finds. ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] embedding iconic pushButton in TableView and/or TreeView
>Just remember, that small self contained examples of such issues are the >ultimate weapon to engage them... >Pete lol, totally,...I went back to Mark Summerfield's book again (and other examples)... I'm soo close...but still a step or two go... Finally figured out how to use my delegate's "sizeHint" to adjust the row height in a QTreeView.. def sizeHint(self, option, index): fm = option.fontMetrics if index.column() == 2: # LongName, but could be any column # text = index.model().data(index) document = QTextDocument() document.setDefaultFont(option.font) return QSize(document.idealWidth() + 5, 50) return QStyledItemDelegate.sizeHint(self, option, index) ...the "50" being the height I needed for a 50x50 icon image in the first column So,...it finally occurred to me that when MarkS says a delegate can have "total control"...then that must mean everything must pass thru the "paint" function...which strikes me as more of a filter than a function,..but anyways... Right now, I have def paint(self, painter, option, index): if index.column() == 0: # Thumbnail parent = self.parent() iconFile = index.model().data(index, Qt.DisplayRole) button = QPushButton("&Icon", parent) icon = QIcon(iconFile) pixmap = icon.pixmap(QSize(50, 50) ) button.setIcon(icon) painter.save() painter.drawPixmap(0, 0, 50, 50, pixmap ) painter.restore() else: QStyledItemDelegate.paint(self, painter, option, index) So, even though there's a PushButton definition in there, I still can't get it to display at startup. I have been able though to define an Icon and Pixmap, (passing the image filename from data() ) but painter only wants (it appears) to draw a pixmap, and not a pushbutton...so I'm kinda' stuck there at the moment... But I do have these pixmaps showing at startup...so I'm think I'm tantalizing close to a solution... Now it might be,...that I may not absolutely need a pushbutton type.. I just need to enable the user that once they click on pixmap/button that it would execute a function. Even that could be argued away with,...by proving a RMB (rightmousebutton) pulldown menu in the main view...Even so, I'd still like to understand and know how to do the former,etc.. Anyways,...Any suggestions greatly appreciated...and Thanks again, Pete, for your help and interest, Cheers, -James ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] GTK+ theme and anti-aliased fonts on CentOS 5.5
On 27 November 2010 20:49, Rex Dieter wrote: > Almar Klein wrote: > > > I've build an application using PyQt running in Python 3. I am using > > CentOS 5.5 (using a virtual box) to build binaries which can be used on > ... > > My questions are: > > - Why is the GTK+ theme not available on CentOS, since it's GNOME? > > iirc, rhel5's qt is too old (ie, doesnt include the gtk+ theme which was > introduced in qt-4.5.x). > Ah sorry, I should've said that I build the latest (well, a few weeks ago) Qt from source, as well as PyQt. Almar ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Bugs galore in QAbstractTableModel???
On 27/11/2010 23:00, Andreas Pakulat wrote: On 27.11.10 21:27:55, Ian wrote: On 27/11/2010 21:07, Andreas Pakulat wrote: On 27.11.10 20:54:01, Ian wrote: I am trying to use QAbstractTableModel and I am having more than some difficulty. If I return the correct number to columnCount I get no headers. If I return a number that is too big, I get headers, but the model is asked for headers and data for columns that don't exist! Everywhere I return a String in the data() routine, this is displayed with a check box - even if I cast it to QVariant. There's a C++ class called QModelText which sanity-checks models, I believe that an older version was converted to python and is included in PyQt4. Run it on your model, fix the problems and see wether that helps. Thanks for your reply Andreas, I can find nothing about QModelText, and QModelTest appears to have Sorry, typo :) a few bug reports and nowhere to download it and no instructions as to how to run it, and is not on my hard disks. Ah, right I totally forgot that its been 'dropped' into /dev/null by Nokia at the point where qtlabs was closed. Unfortunately Nokia doesn't provide it yet at some other place. There's a copy of the last svn version of the C++ code here: https://projects.kde.org/projects/extragear/kdevelop/kdevplatform/repository/revisions/master/show/tests def rowCount(self, parent = None): ''' return No of rows of data. parent is a QModelIndex ''' return len(self.view) This is wrong, even for table models you have to take care to return the right number of rows depending on the parent. That means if your model gets asked for the rowCount with a valid parent, you want to return 0 (as you don't have childs under any of your rows). So check for parent.isValid(). def columnCount(self, parent = None): ''' return number of columns. parent = QModelIndex() id, name, cubref, address, town, contacts ''' return 6 Basically the same here as above, though I think this is not quite as critical. def data(self, index, role): ''' return data as QVariant at index.row and index.col ''' key = self.view.rows[index.row()].key idx = index.column() if idx< len(key): val = key[idx] if val is None: return QVariant() return QVariant(val) return QVariant() This can potentially throw exceptions because index may be invalid in which case index.row() is return -1. So again check the index for validity. Also you should only return data for role's you really want to handle and return QVariant() for anything else, i.e. check for role == DisplayRole. def headerData(self, col, orientation, role): ''' return the header data ''' if orientation == Qt.Horizontal: tab = ['Name','Cub Ref','Street','Town','Contacts'] if col< len(tab): return tab[col] return None I'm not sure about PyQt's constraints on this, but its common to return a dummy QVariant from these functions. Oh and again the role-thing from above applies. And yes all of this is not documented in Qt's API docs, though its visible in the example models that Qt ships. Maybe there's already a bugreport open for an improvement. Andreas Thanks Andreas, The hint about testing role in data removed the (uncheckable) check boxes, and calling resizeColumnsToContents() now sets the columns to the width (but not the window). However, setting the number of fields to 5, still removes the headers. Regards Ian ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Bugs galore in QAbstractTableModel???
On 27/11/2010 22:23, Baz Walter wrote: On 27/11/10 21:27, Ian wrote: On 27/11/2010 21:07, Andreas Pakulat wrote: On 27.11.10 20:54:01, Ian wrote: I am trying to use QAbstractTableModel and I am having more than some difficulty. If I return the correct number to columnCount I get no headers. If I return a number that is too big, I get headers, but the model is asked for headers and data for columns that don't exist! Everywhere I return a String in the data() routine, this is displayed with a check box - even if I cast it to QVariant. There's a C++ class called QModelText which sanity-checks models, I believe that an older version was converted to python and is included in PyQt4. Run it on your model, fix the problems and see wether that helps. Thanks for your reply Andreas, I can find nothing about QModelText, and QModelTest appears to have a few bug reports and nowhere to download it and no instructions as to how to run it, and is not on my hard disks. the python version andreas is referring to is "modeltest.py". it can be found in the pyqt source in the contrib/pymodeltest directory. I found the version I think I need (4.7.4) at http://python-qt4.sourcearchive.com/documentation/4.7.4-0ubuntu1/modeltest_8py-source.html I have been unable to find out how to run it - so guessing I tried this. # coding=utf8 from companyListModel import CompanyListModel from modelTest import ModelTest model = CompanyListModel() tester = ModelTest(model, None) tester.runAllTests() This didn't initialise ModelTest Traceback (most recent call last): File "testing.py", line 8, in tester = ModelTest(model, None) File "D:\work\C-U-B\modelTest.py", line 41, in __init__ self.connect( self.model, QtCore.SIGNAL("columnsAboutToBeInserted(const QtCore.QModelIndex&, int, int)"), self.runAllTests) TypeError: type 'QtCore.QModelIndex' is not supported as a slot argument type I'm way out of my depth. (That usually means I'm about to learn something.) Help needed! Ian ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Bugs galore in QAbstractTableModel???
On 27.11.10 21:27:55, Ian wrote: > On 27/11/2010 21:07, Andreas Pakulat wrote: > >On 27.11.10 20:54:01, Ian wrote: > >>I am trying to use QAbstractTableModel and I am having more than > >>some difficulty. > >> > >>If I return the correct number to columnCount I get no headers. If I > >>return a number that is too big, I get headers, but the model is > >>asked for headers and data for columns that don't exist! > >> > >>Everywhere I return a String in the data() routine, this is > >>displayed with a check box - even if I cast it to QVariant. > >There's a C++ class called QModelText which sanity-checks models, I > >believe that an older version was converted to python and is included in > >PyQt4. Run it on your model, fix the problems and see wether that helps. > > > Thanks for your reply Andreas, > I can find nothing about QModelText, and QModelTest appears to have Sorry, typo :) > a few bug reports and > nowhere to download it and no instructions as to how to run it, and > is not on my hard disks. Ah, right I totally forgot that its been 'dropped' into /dev/null by Nokia at the point where qtlabs was closed. Unfortunately Nokia doesn't provide it yet at some other place. There's a copy of the last svn version of the C++ code here: https://projects.kde.org/projects/extragear/kdevelop/kdevplatform/repository/revisions/master/show/tests > def rowCount(self, parent = None): > ''' return No of rows of data. parent is a QModelIndex ''' > return len(self.view) This is wrong, even for table models you have to take care to return the right number of rows depending on the parent. That means if your model gets asked for the rowCount with a valid parent, you want to return 0 (as you don't have childs under any of your rows). So check for parent.isValid(). > def columnCount(self, parent = None): > ''' return number of columns. parent = QModelIndex() >id, name, cubref, address, town, contacts > ''' > return 6 Basically the same here as above, though I think this is not quite as critical. > def data(self, index, role): > ''' return data as QVariant at index.row and index.col ''' > key = self.view.rows[index.row()].key > idx = index.column() > if idx < len(key): > val = key[idx] > if val is None: > return QVariant() > return QVariant(val) > return QVariant() This can potentially throw exceptions because index may be invalid in which case index.row() is return -1. So again check the index for validity. Also you should only return data for role's you really want to handle and return QVariant() for anything else, i.e. check for role == DisplayRole. > def headerData(self, col, orientation, role): > ''' return the header data ''' > if orientation == Qt.Horizontal: > tab = ['Name','Cub Ref','Street','Town','Contacts'] > if col < len(tab): > return tab[col] > return None I'm not sure about PyQt's constraints on this, but its common to return a dummy QVariant from these functions. Oh and again the role-thing from above applies. And yes all of this is not documented in Qt's API docs, though its visible in the example models that Qt ships. Maybe there's already a bugreport open for an improvement. Andreas -- You fill a much-needed gap. ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Bugs galore in QAbstractTableModel???
On Samstag 27 November 2010, Ian wrote: > So here are the model and view: you could try to add checks to your methods like in data(): if index.isValid(): if role == Qt.DisplayRole: data() will also be called with role == Qt.CheckStateRole in which case your code returns True or in headerData: if role == Qt.DisplayRole and orientation == Qt.Horizontal: return ...whatever... else: return QVariant() -- Wolfgang ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Bugs galore in QAbstractTableModel???
On 27/11/10 21:27, Ian wrote: On 27/11/2010 21:07, Andreas Pakulat wrote: On 27.11.10 20:54:01, Ian wrote: I am trying to use QAbstractTableModel and I am having more than some difficulty. If I return the correct number to columnCount I get no headers. If I return a number that is too big, I get headers, but the model is asked for headers and data for columns that don't exist! Everywhere I return a String in the data() routine, this is displayed with a check box - even if I cast it to QVariant. There's a C++ class called QModelText which sanity-checks models, I believe that an older version was converted to python and is included in PyQt4. Run it on your model, fix the problems and see wether that helps. Thanks for your reply Andreas, I can find nothing about QModelText, and QModelTest appears to have a few bug reports and nowhere to download it and no instructions as to how to run it, and is not on my hard disks. the python version andreas is referring to is "modeltest.py". it can be found in the pyqt source in the contrib/pymodeltest directory. ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] How does sip.setapi("QString", 2) work with translations?
Hello Brett, with sip.setapi("QString",2) you gets always an unicode string back, witch is a true python object. So there can't be any Qt methods any more. This is why your second example fails. You have two solutions. The one you mentioned or since Python 2.6 the new unicode format method: qApp.translate("test","Internationalize {0}").format(42) or with named arguments: qApp.translate("test","Internationalize {my_number}").format(my_number=42) There are many other options for the format method described in the Python documentation. Tobias Brett Stottlemyer schrieb am 27.11.2010 21:27: Hi, all- I'd like to use sip.setapi("QString",2), but I'm using internationalization as well and it is giving me some trouble. If I try: qApp.translate("test","Internationalize") I get Unicode "Internationalize" as the result (as expected) When I try: qApp.translate("test","Internationalize %1").arg("42") I get AttributeError: 'unicode' object has no attribute 'arg'. I guess this is expected, too, but I was hoping Phil had done some magic to have it work as expected. Is there a way to get this to work using Qt style formatting? Or do I need to convert everything to python-style, like this: qApp.translate("test","Internationalize %d")%42 Thanks, Brett ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Setting image as background in QListView
Thanks a lot Pete! I got to try it today and the images were indeed not getting added properly to the resource file, because I was not running pyrcc4 utility. Thanks, Abhishek. On Mon, Nov 22, 2010 at 10:23 AM, Hans-Peter Jansen wrote: > On Monday 22 November 2010, 18:21:21 absk82 wrote: > > Does anyone have any ideas about this? > > > > absk82 wrote: > > > For some reason, my post didn't make it through for 2 days, so > > > trying to send it through the mailing list. > > > > > > Hi, > > > I have been having some trouble setting the background image in a > > > QListView > > > using style sheets. I tried using both jpg as well as png images as > > > background. This is the stylesheet entry generated by QtDesigner. > > > "QListView{\n" > > > "background-image: url(:/icons/images/wood_texture_png.png);\n" > > > "}") > > Did you created and included the image(s) in the resource correctly. > The PyQt examples have plenty of hmm, examples of using resources. > > Hint: try to display the image with a Qlabel.. > > Pete > ___ > 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] Bugs galore in QAbstractTableModel???
On 27/11/2010 21:07, Andreas Pakulat wrote: On 27.11.10 20:54:01, Ian wrote: I am trying to use QAbstractTableModel and I am having more than some difficulty. If I return the correct number to columnCount I get no headers. If I return a number that is too big, I get headers, but the model is asked for headers and data for columns that don't exist! Everywhere I return a String in the data() routine, this is displayed with a check box - even if I cast it to QVariant. There's a C++ class called QModelText which sanity-checks models, I believe that an older version was converted to python and is included in PyQt4. Run it on your model, fix the problems and see wether that helps. Thanks for your reply Andreas, I can find nothing about QModelText, and QModelTest appears to have a few bug reports and nowhere to download it and no instructions as to how to run it, and is not on my hard disks. So here are the model and view: # coding=utf8 # companyListModel.py class of CompanyList import couchdb from couchObject import CouchObject import json from PyQt4.QtCore import * # so no internal routines starting with Q! from PyQt4.QtGui import * import pprint class CompanyListModel(QAbstractTableModel,CouchObject): ''' a company list holds data from a view of Companies ''' def __init__(self): ''' initialise - read the view ready ''' CouchObject.__init__(self) QAbstractTableModel.__init__(self) self.view = self.loadView('by_name') def rowCount(self, parent = None): ''' return No of rows of data. parent is a QModelIndex ''' return len(self.view) def columnCount(self, parent = None): ''' return number of columns. parent = QModelIndex() id, name, cubref, address, town, contacts ''' return 6 def data(self, index, role): ''' return data as QVariant at index.row and index.col ''' key = self.view.rows[index.row()].key idx = index.column() if idx < len(key): val = key[idx] if val is None: return QVariant() return QVariant(val) return QVariant() def all_fields(self): ''' return list of fields in view''' return [ '_id', 'name', 'cubref', 'street', 'town', 'contacts' ] def headerData(self, col, orientation, role): ''' return the header data ''' if orientation == Qt.Horizontal: tab = ['Name','Cub Ref','Street','Town','Contacts'] if col < len(tab): return tab[col] return None # coding=utf8 # companyListView - a company Listing window import couchdb from company import Company from couchDbServer import Couch from uuid import uuid4 import sys from PyQt4.QtCore import * # so no internal routines starting with Q! from PyQt4.QtGui import * from mainWindow import CubMainWindow from companyListModel import CompanyListModel # for testing import pprint class CompanyListView(CubMainWindow): ''' a window that lists Companies ''' def __init__(self, cubic, name=None, parent=None): ''' initialise CompanyListView window ''' super(CompanyListView,self).__init__(cubic,parent) print "NoteEditor initialising" self.setWindowTitle('Companies - No Company Selected') self.cubic = cubic self.model = CompanyListModel() # build panel with a VBoxLayout, a QTableView on top, and a HBoxLayout below with two buttons listPane = QWidget() layout = QVBoxLayout() # config tableView self.tableView = QTableView() self.tableView.setAlternatingRowColors(True) self.tableView.setModel(self.model) scrollArea = QScrollArea() scrollArea.setBackgroundRole(QPalette.Light) layout.addWidget(self.tableView) # add buttons addCompanyButton = QPushButton("&Add Company") removeCompanyButton = QPushButton("&Remove Company") quitButton = QPushButton("&Quit") buttonLayout = QHBoxLayout() buttonLayout.addWidget(addCompanyButton) buttonLayout.addWidget(removeCompanyButton) buttonLayout.addStretch() buttonLayout.addWidget(quitButton) layout.addLayout(buttonLayout) listPane.setLayout(layout) self.setCentralWidget(listPane) # link up headers to change order header = self.tableView.horizontalHeader() self.connect(header,SIGNAL("sectionClicked(int)"),self.sortTable) # link buttons self.connect(addCompanyButton, SIGNAL('clicked()'), self.addCompany) self.connect(removeCompanyButton, SIGNAL('clicked()'), self.removeCompany) self.connect(quitButton, SIGNAL('clicked()'), self.accept) QTimer.singleShot(10, self.initialLoad) def sortTable(self,section): ''' sortTable called ''' print "sortTable
Re: [PyQt] Bugs galore in QAbstractTableModel???
On 27.11.10 20:54:01, Ian wrote: > I am trying to use QAbstractTableModel and I am having more than > some difficulty. > > If I return the correct number to columnCount I get no headers. If I > return a number that is too big, I get headers, but the model is > asked for headers and data for columns that don't exist! > > Everywhere I return a String in the data() routine, this is > displayed with a check box - even if I cast it to QVariant. There's a C++ class called QModelText which sanity-checks models, I believe that an older version was converted to python and is included in PyQt4. Run it on your model, fix the problems and see wether that helps. If it doesn't, provide sample code, without it its not really possible to help you. Andreas -- You've been leading a dog's life. Stay off the furniture. ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Bugs galore in QAbstractTableModel???
Hi Everyone, I am trying to use QAbstractTableModel and I am having more than some difficulty. If I return the correct number to columnCount I get no headers. If I return a number that is too big, I get headers, but the model is asked for headers and data for columns that don't exist! Everywhere I return a String in the data() routine, this is displayed with a check box - even if I cast it to QVariant. If I call resizeColumnsToContents() on the view, all the columns are set to a very small size that shows only the check boxes. :( I am using Python 2.7, PyQt 4.7.4 and Windows 7 (64 bit). I don't believe that QAbstractTableModel can be quite that buggy. So what am I doing wrong? Anyone? Please? Ian ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] How does sip.setapi("QString",2) work with translations?
Hi, all- I'd like to use sip.setapi("QString",2), but I'm using internationalization as well and it is giving me some trouble. If I try: > qApp.translate("test","Internationalize") I get Unicode "Internationalize" as the result (as expected) When I try: > qApp.translate("test","Internationalize %1").arg("42") I get AttributeError: 'unicode' object has no attribute 'arg'. I guess this is expected, too, but I was hoping Phil had done some magic to have it work as expected. Is there a way to get this to work using Qt style formatting? Or do I need to convert everything to python-style, like this: > qApp.translate("test","Internationalize %d")%42 Thanks, Brett ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] GTK+ theme and anti-aliased fonts on CentOS 5.5
Almar Klein wrote: > I've build an application using PyQt running in Python 3. I am using > CentOS 5.5 (using a virtual box) to build binaries which can be used on ... > My questions are: > - Why is the GTK+ theme not available on CentOS, since it's GNOME? iirc, rhel5's qt is too old (ie, doesnt include the gtk+ theme which was introduced in qt-4.5.x). -- Rex ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] embedding iconic pushButton in TableView and/or TreeView
On Thursday 25 November 2010, 03:33:28 James Polk wrote: > WhoI got a custom delegate installedat least > partially, lol... Using the basic QItemDelegate > I've first tried a comboBox, which seems a little more > straightforward,.. Congrats, James. The world isn't as bad as it feels sometimes ;-) > When using QTableView,...the "index.column()" calls want text > matching the column headings,...but in QTreeView, the same call wants > an integer index#...so my code looks like... > > > def createEditor(self, parent, option, index): > if index.column() == 0: # Thumbnail > button = QPushButton(parent) > return button > if index.column() == 4: # Format > comboBox = QComboBox(parent) > comboBox.addItem("ma") > comboBox.addItem("mb") > comboBox.addItem("obj") > comboBox.setEditable(True) > return comboBox > return QItemDelegate.createEditor(self, parent, option, index) > > I was all in celebration mode,...until I began to add the initial > pushbutton/icon in the first column.Right now, I'm just using > QPushButton and will add the image/pixmap later... > > Well..the danged curious thing isthat when I run the code, > and double-click on the cells of the first column, the custom > delegate dutifully returns a nice PushButtonbut my conundrum > is that I still can't figure out how to add the PushButton to the > QTreeView on startup!... You need a item delegate, then. > You may recall the data layout I'm going for is something like... > > 1 [icon1] data data data etc > 2 [icon2] data data data etc > 3 etc > 4 etc > > ...and later,...when a user binks on the icon, it will need to > execute a command... > > So,...some progress, but still more jungle ahead,lol... > Maybe I'll go reread your stardelegate code again ;-) Just remember, that small self contained examples of such issues are the ultimate weapon to engage them... Pete ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Multiple widgets in one ui file?
Hello, Seems it's very simple or stupid question because I didn't find answer on it in google. :) I create MainWindow widget in Qt Designer and now planning create another (separate) dialog. Is this impossible create dialog (with Qt Designer again) in same (with MainWindow) ui file? Only separate file for every widget possible? I asking because less files - easy their managment... Thanks! regards, -vadym -- Vadym Honcharuk, nic-handle:vh20-uanic ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] x64 Windows packages
On Sat, 27 Nov 2010 12:03:25 -0600, Steve Borho wrote: > Is there any plan to make x64 Windows packages available for download? > > I found a package at: http://www.lfd.uci.edu/~gohlke/pythonlibs/ and > have built functional x64 installers with it, but their package is a > bit old. Yes - the next release (in a week or two) will include them. Phil ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] QStandardItemEditorCreator missing solved: coloreditorfactory example attached
On Sat, 27 Nov 2010 18:52:28 +0100, "Hans-Peter Jansen" wrote: > On Friday 26 November 2010, 15:15:32 Phil Thompson wrote: >> On Thu, 25 Nov 2010 22:57:42 +0100, "Hans-Peter Jansen" >> >> >> wrote: >> > [Missed to addressed you directly the last time, sorry] >> > >> > On Thursday 25 November 2010, 18:23:38 Hans-Peter Jansen wrote: >> >> On Thursday 25 November 2010, 14:44:33 Phil Thompson wrote: >> >> > On Thu, 25 Nov 2010 14:26:50 +0100, "Hans-Peter Jansen" >> >> > >> >> > >> >> > wrote: >> >> > > On Thursday 25 November 2010, 13:27:00 Phil Thompson wrote: >> >> > >> On Thu, 25 Nov 2010 13:11:13 +0100, "Hans-Peter Jansen" >> >> > >> >> >> > >> >> >> > >> wrote: >> >> > >> > Hi Phil, >> >> > >> > >> >> > >> > attached is an attempt to port the coloreditorfactory >> >> > >> > example to PyQt. This reveals a few issues, though. >> >> > >> > >> >> > >> > the most prominent thing, that stands out, is that >> >> > >> > QStandardItemEditorCreator is missing. This wouldn't harm >> >> > >> > as such, if I would be able to wrap my mind around PyQt's >> >> > >> > Qt property support, although it would make the task more >> >> > >> > convenient being able to subclass from the widget in >> >> > >> > question instead of >> >> > >> > QItemEditorCreatorBase. >> >> > >> >> >> > >> It's not supported because it is a template class. >> >> > >> >> >> > >> > This revealed another question: basing a custom item >> >> > >> > delegate editor on QItemEditorCreatorBase takes defining a >> >> > >> > Q_PROPERTY with a USER keyword. How could this be archived >> >> > >> > with PyQt? You mention the support of Qt properties by >> >> > >> > keyword. But how does this map to the READ/WRITE/WHATEVER >> >> > >> > pattern of Q_PROPERTY macros? >> >> > >> >> >> > >> Use pyqtProperty(). >> >> > > >> >> > > Sorry for being dense, but I still don't get how to set a USER >> >> > > property. >> >> > > >> >> > > IOW: create a property with the USER flag set to True as >> >> > > described here: >> >> > > >> >> > > QMetaObject::userProperty() >> >> > > >> >> > >>> from PyQt4.QtCore import pyqtProperty >> >> > >>> help(pyqtProperty) >> >> >> >> Duuh, silly me. Thanks for the reminder. >> >> >> >> Unfortunately, it's still not behaving right: the color chooser is >> >> created and shown correctly on double click, one can choose >> >> another value, but that isn't supplied back into the table >> >> correctly, although the property getter _is_ called and given the >> >> new value. >> >> >> >> What am I missing? >> > >> > Okay, the issue is related to QVariant vs. QColor handling. >> > Attached are two examples using both QVariant APIs with some debug >> > prints added. >> > >> > If you run the scripts, and press "Arrow left", "blank", "Arrow >> > down", "Return", "Return", something similar the following is >> > printed: >> > >> > ColorListEditor.setColor(#f0f8ff) > > 0xb567fdf4> True >> > item0: #f0f8ff >> > item1: #faebd7 >> > current index 0 >> > found index: 0 >> > ColorListEditor.getColor(): #faebd7 > > 0xb567fdf4> >> > ColorListEditor.setColor(#00) > > 0xb567fdf4> False >> > item0: #f0f8ff >> > item1: #faebd7 >> > current index 1 >> > found index: -1 >> > invalid index >> > >> > no matter, which QVariant API is used. For some reason, the QColor >> >> instance >> >> > is damaged between the first getColor() call (after selecting the >> > second item), >> > and the following setColor() call. >> > >> > This raises the question, what happened to this QColor instance >> > between these >> > calls? >> >> Should be fixed in tonight's snapshot. > > Confirmed. Your change from the attached diff does fix this issue. > > Thanks a lot. > > Attached is a streamlined version of the the coloreditorfactory script, > incorporating a few improvements from Baz' version and with the > copyright header intact. I'd already made similar changes... Phil ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] simplewidgetmapper.py, customsortfiltermodel.py, combowidgetmapper.py examples
Hi Phil, hi *, attached are a few missing itemview examples for the collection. While simplewidgetmapper.py and combowidgetmapper.py differ only in minor details, the customsortfiltermodel.py differs from the original in a major aspect: it actually works unlike the original ;-) - the filters are applied on startup (UI shows consistent values) - the date limiter contain sane values - the date filter works properly The last issue in MySortFilterProxyModel.dateInRange() results from a slight inconsistency in Qt: comparing QDate with QDateTime values doesn't work (at least not in a way, what would humans expect), hence the value has to be converted to a QDate before the comparison. Enjoy, Pete simplewidgetmapper.py Description: application/python customsortfiltermodel.py Description: application/python combowidgetmapper.py Description: application/python ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] x64 Windows packages
Is there any plan to make x64 Windows packages available for download? I found a package at: http://www.lfd.uci.edu/~gohlke/pythonlibs/ and have built functional x64 installers with it, but their package is a bit old. -- Steve Borho ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] QStandardItemEditorCreator missing solved: coloreditorfactory example attached
On Friday 26 November 2010, 15:15:32 Phil Thompson wrote: > On Thu, 25 Nov 2010 22:57:42 +0100, "Hans-Peter Jansen" > > > wrote: > > [Missed to addressed you directly the last time, sorry] > > > > On Thursday 25 November 2010, 18:23:38 Hans-Peter Jansen wrote: > >> On Thursday 25 November 2010, 14:44:33 Phil Thompson wrote: > >> > On Thu, 25 Nov 2010 14:26:50 +0100, "Hans-Peter Jansen" > >> > > >> > > >> > wrote: > >> > > On Thursday 25 November 2010, 13:27:00 Phil Thompson wrote: > >> > >> On Thu, 25 Nov 2010 13:11:13 +0100, "Hans-Peter Jansen" > >> > >> > >> > >> > >> > >> wrote: > >> > >> > Hi Phil, > >> > >> > > >> > >> > attached is an attempt to port the coloreditorfactory > >> > >> > example to PyQt. This reveals a few issues, though. > >> > >> > > >> > >> > the most prominent thing, that stands out, is that > >> > >> > QStandardItemEditorCreator is missing. This wouldn't harm > >> > >> > as such, if I would be able to wrap my mind around PyQt's > >> > >> > Qt property support, although it would make the task more > >> > >> > convenient being able to subclass from the widget in > >> > >> > question instead of > >> > >> > QItemEditorCreatorBase. > >> > >> > >> > >> It's not supported because it is a template class. > >> > >> > >> > >> > This revealed another question: basing a custom item > >> > >> > delegate editor on QItemEditorCreatorBase takes defining a > >> > >> > Q_PROPERTY with a USER keyword. How could this be archived > >> > >> > with PyQt? You mention the support of Qt properties by > >> > >> > keyword. But how does this map to the READ/WRITE/WHATEVER > >> > >> > pattern of Q_PROPERTY macros? > >> > >> > >> > >> Use pyqtProperty(). > >> > > > >> > > Sorry for being dense, but I still don't get how to set a USER > >> > > property. > >> > > > >> > > IOW: create a property with the USER flag set to True as > >> > > described here: > >> > > > >> > >QMetaObject::userProperty() > >> > > > >> > >>> from PyQt4.QtCore import pyqtProperty > >> > >>> help(pyqtProperty) > >> > >> Duuh, silly me. Thanks for the reminder. > >> > >> Unfortunately, it's still not behaving right: the color chooser is > >> created and shown correctly on double click, one can choose > >> another value, but that isn't supplied back into the table > >> correctly, although the property getter _is_ called and given the > >> new value. > >> > >> What am I missing? > > > > Okay, the issue is related to QVariant vs. QColor handling. > > Attached are two examples using both QVariant APIs with some debug > > prints added. > > > > If you run the scripts, and press "Arrow left", "blank", "Arrow > > down", "Return", "Return", something similar the following is > > printed: > > > > ColorListEditor.setColor(#f0f8ff) > 0xb567fdf4> True > > item0: #f0f8ff > > item1: #faebd7 > > current index 0 > > found index: 0 > > ColorListEditor.getColor(): #faebd7 > 0xb567fdf4> > > ColorListEditor.setColor(#00) > 0xb567fdf4> False > > item0: #f0f8ff > > item1: #faebd7 > > current index 1 > > found index: -1 > > invalid index > > > > no matter, which QVariant API is used. For some reason, the QColor > > instance > > > is damaged between the first getColor() call (after selecting the > > second item), > > and the following setColor() call. > > > > This raises the question, what happened to this QColor instance > > between these > > calls? > > Should be fixed in tonight's snapshot. Confirmed. Your change from the attached diff does fix this issue. Thanks a lot. Attached is a streamlined version of the the coloreditorfactory script, incorporating a few improvements from Baz' version and with the copyright header intact. Hans, I dimly remember your issues with model proxies and disappearing internalPointers.. The attached patch might be worth a try. Pete diff -up -r -x doc PyQt-x11-gpl-snapshot-4.8.2-f2b28c685066/qpy/QtCore/qpycore_qobject_helpers.cpp PyQt-x11-gpl-snapshot-4.8.2-a935ffc263c2/qpy/QtCore/qpycore_qobject_helpers.cpp --- PyQt-x11-gpl-snapshot-4.8.2-f2b28c685066/qpy/QtCore/qpycore_qobject_helpers.cpp 2010-11-23 04:44:01.0 +0100 +++ PyQt-x11-gpl-snapshot-4.8.2-a935ffc263c2/qpy/QtCore/qpycore_qobject_helpers.cpp 2010-11-27 04:43:52.0 +0100 @@ -158,11 +158,14 @@ static int qt_metacall_worker(sipSimpleW if (var) { -// This tells QMetaProperty::read() to use the new -// contents of the QVariant it provided. -_a[1] = 0; - ok = prop->pyqtprop_parsed_type->fromPyObject(py, var); + +// Make sure that _a[0] still points to the QVariant +// data (whose address we may have just changed) so +// that QMetaProperty::read() doesn't try to create a +// new QVariant. +if (ok) +_a[0] = var->data(); }
Re: [PyQt] SIP v5 Roadmap
On Monday 22 November 2010, 17:06:01 Phil Thompson wrote: > I've added a roadmap for SIP v5 at... > > http://www.riverbankcomputing.com/software/sip/roadmap >From the latest experience with PyQwt (with the still unexplained issues related to switching off a feature: see thread "[PyQt] sip snapshot problem with PyQwt"), one problem was a single dangling %End directive. While better error messages are greatly appreciated, I expect locating such problems will still going to be tough in a big library, because of the inherent ambiguity. Wouldn't unambiguous %End directives allow for much easier formal consistency verification (e.g. %EndIf, %EndTypeHeaderCode, %EndMethodCode, etc..). @all: How could class templates be supported in an easier way? As far as I understand it, one has to specify all different types one by one. How about a %TemplateTypes directive? Some thoughts for (Meta-)SIP v6: - transformation tool for gccxml output to sip - automated timeline/version management, based on gccxml output of different project versions - template based mix-in controller for injecting various directives, annotations, code segments targetting automated sip generation Pete ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Camelot 10.11.27 : leverage Python, PyQT and SQLAlchemy
Dear all, Camelot 10.11.27 has been released. This release uses the new style signal slots connections. Camelot is an open source RAD framework that leverages Python, Sqlalchemy and Qt to build database applications. Inspired by the Django admin interface, Camelot allows a developer to define the database model and Camelot will create the views. Homepage : http://www.python-camelot.com Demonstration video : http://www.youtube.com/watch?v=HZ5i257N6cc Regards, Erik New in this release : - tab based desktop - faster table view - improved search queries - much more dynamic field attributes : tooltip, background_color, editable, choices, prefix, suffix, arrow - SQLAlchemy 0.6.x support - Matplotlib integration - move to new style signal/slot connections - frozen columns in a table view ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] SIP v5 Roadmap
On Sat, 27 Nov 2010 00:21:39 -0800, Robin Dunn wrote: > On 11/22/10 8:06 AM, Phil Thompson wrote: >> I've added a roadmap for SIP v5 at... >> >> http://www.riverbankcomputing.com/software/sip/roadmap >> >> Comments welcome. > > """ > * Types will have to be declared in advance of being used. In SIP v4 the > names of types are resolved after all of the specification files have > been parsed. > """ > > Will we be able to forward declare types so they can be used before the > full declaration is seen, as in C/C++? Yes. Phil ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] [QtDesigner] Docs in Python ?
On Fri, 26 Nov 2010 18:21:11 -0800 (PST), James Polk wrote: > When I run QtDesigner (the one that lives in ../PyQt4/bin/)... > When I run "Help" from the menuBar, all of the examples (as far as I can > tell) are in C++... > Is there a version of this help in Python? Not yet. Phil ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] SIP v5 Roadmap
On 11/22/10 8:06 AM, Phil Thompson wrote: I've added a roadmap for SIP v5 at... http://www.riverbankcomputing.com/software/sip/roadmap Comments welcome. """ * Types will have to be declared in advance of being used. In SIP v4 the names of types are resolved after all of the specification files have been parsed. """ Will we be able to forward declare types so they can be used before the full declaration is seen, as in C/C++? -- Robin Dunn Software Craftsman http://wxPython.org ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt