Re: [PyQt] Testing PyQt using code with unit-tests and Mock
On 27.07.11 22:19:43, Phil Thompson wrote: On Wed, 27 Jul 2011 21:31:22 +0200, Andreas Pakulat ap...@gmx.de wrote: Hi, I've got a bit of a problem to test my PyQt based code via unit-tests involving mock objects (specifically minimock). I'd like to find a way to emit a signal with a mock-object instead of the real, but I can't seem to find a way to do that. The attached example demonstrates the problem. Instead of a real Param object I want to pass in a Mock object Is there a way to do this? PyQt 4.8.3, Qt 4.7.3 and sip 4.12.1 Andreas If the question is can you dynamically change a QMetaObject, then the answer is no. I see. Guess I'll have to create a subclass for the test than which re-defines the signal parameter... Andreas ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] negative index setWidget not working as expected
Hallo, inserting widgets with a negative index does not work as expected. I was expecting -1 to add a widget to the end and -2 to insert it right before the last widget in the layout. Is my assumption wrong? Demo code: from PyQt4.QtGui import QLineEdit, QCheckBox, QPushButton, QDialog, QFormLayout, \ QVBoxLayout, QApplication class Gui(QDialog): def __init__(self): QDialog.__init__(self) editLayout = QFormLayout() editLayout.addRow(enter something:, QLineEdit()) editLayout.addRow(enter another something:, QLineEdit()) button = QPushButton(press me) layout = QVBoxLayout() layout.addLayout(editLayout) layout.addWidget(button) self.setLayout(layout) self.layout().insertWidget(-2, QCheckBox(check me!)) app = QApplication([]) g = Gui() g.show() app.exec_() cheers Sebastian ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] negative index setWidget not working as expected
On Thu, 28 Jul 2011 11:59:53 +0200, Sebastian Elsner sebastianels...@freenet.de wrote: Hallo, inserting widgets with a negative index does not work as expected. I was expecting -1 to add a widget to the end and -2 to insert it right before the last widget in the layout. Is my assumption wrong? Yes. That's a Python convention, not a Qt/C++ convention. Phil ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Qt 4.8 beta, OSX Lion
Has anyone built using the Qt 4.8 beta release on OSX Lion yet? Here's what I get: ~/dev/PyQt-mac-gpl-4.8.4$ make g++ -c -pipe -O2 -arch x86_64 -Xarch_x86_64 -mmacosx-version-min=10.5 -fPIC -Wall -W -DQT_NO_DEBUG -DQT_OPENGL_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/local/Trolltech/Qt-4.8.0/mkspecs/macx-g++ -I. -I/usr/local/Trolltech/Qt-4.8.0/lib/QtCore.framework/Versions/4/Headers -I/usr/local/Trolltech/Qt-4.8.0/include/QtCore -I/usr/local/Trolltech/Qt-4.8.0/lib/QtGui.framework/Versions/4/Headers -I/usr/local/Trolltech/Qt-4.8.0/include/QtGui -I/usr/local/Trolltech/Qt-4.8.0/lib/QtOpenGL.framework/Versions/4/Headers -I/usr/local/Trolltech/Qt-4.8.0/include/QtOpenGL -I/usr/local/Trolltech/Qt-4.8.0/include -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -I../../QtOpenGL -I. -I/System/Library/Frameworks/OpenGL.framework/Versions/A/Headers -I/System/Library/Frameworks/AGL.framework/Headers -I. -F/usr/local/Trolltech/Qt-4.8.0/lib -o qpyopengl_attribute_array.o qpyopengl_attribute_array.cpp In file included from /usr/include/c++/4.2.1/ios:47, from /usr/include/c++/4.2.1/ostream:45, from /usr/include/c++/4.2.1/iterator:70, from /usr/local/Trolltech/Qt-4.8.0/include/QtCore/qlist.h:50, from /usr/local/Trolltech/Qt-4.8.0/include/QtCore/qobject.h:50, from /usr/local/Trolltech/Qt-4.8.0/include/QtGui/qwidget.h:46, from /usr/local/Trolltech/Qt-4.8.0/lib/QtOpenGL.framework/Versions/4/Headers/qgl.h:45, from qpyopengl_attribute_array.cpp:38: /usr/include/c++/4.2.1/bits/localefwd.h:58:34: error: macro isspace passed 2 arguments, but takes just 1 /usr/include/c++/4.2.1/bits/localefwd.h:70:34: error: macro isupper passed 2 arguments, but takes just 1 /usr/include/c++/4.2.1/bits/localefwd.h:74:34: error: macro islower passed 2 arguments, but takes just 1 /usr/include/c++/4.2.1/bits/localefwd.h:78:34: error: macro isalpha passed 2 arguments, but takes just 1 ... thanks, Randy ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] QTableWidget - pyuic does not compile several attributes
On Thursday 28 July 2011, 02:58:38 Protopia wrote: I am not sure whether anyone has found this problem before, however I can't find it in the archives on Gmane. I first came across this problem when I designed a table in QT Designer, and set fonts on certain cells. But when I ran the code, no formatting. Looking at the code generated by pyuic I could not see the code I would expect to set the fonts. So, I generated a test UI file in Designer with all properties on the table widget, the vertical and horizontal titles and cells themselves (attached) And then I ran the compiler and looked at the code (attached) and found the following things missing: QTableWidget: 1. .font.Kerning not compiled. 2. .font.Antialiasing not compiled 3. .QTableView.sortingEnabled is placed in reTranslateUI - however this does not seem to be concerned with internationalisation and I feel should be in the main code (though I could easily be wrong here) 4. .QTableWidget.rowCount .columnCount - if these are specified explicitly in QT Designer then they appear twice in the .py file. (Of course this won't cause major problems, but is nevertheless inappropriate.) QTableWidgetItem 1. Horizontal and Vertical header tooltips, whatsthis, fonts, textalign, background and foreground are not compiled at all. 2. Cell tooltips, whatsthis, fonts and textalign are not compiled at all. 3. Cell background and foreground are compiled, however sequence of statements is wrong - sets brush twice, then assigns second definition to both background and foreground. First of all, what are you trying to archive? In order to breathe life into these objects, you need to add some code, generated by yourself (brain and all..). Designers output is a suitable basement for this task (in terms of subclassing or calling into), but in no way it's meant to be exhaustive. If you question the output of pyuic4, the very next thing to do is comparing it with the output of uic. Since that is the reference implementation for pyuic4, any significant differences should be dealt with, and I guess, if nobody jumps up and provide patches, Phil will sometime (depending on his priorities and importance..). Whilst we are looking at this code, it would also be helpful if we were to leave a blank line between code for QTableWidget, Horizontal Headers, Vertical Headers and Cells. Since pyuic4 output is not meant for human consumption (apart from debugging purposes), a patch from you in this area is highly unlikely to be applied by Phil.. [Hint: sed is your friend for such tasks] Pete ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] QHostAddress is missing a method
On Sat, 16 Jul 2011 18:11:04 +0200, Detlev Offenbach det...@die-offenbachs.de wrote: Hello, I think the QHostAddress mappings are missing the method toIPv6Address. If I am right, would it be possible to add it? Tonight's snapshot. Implemented a 16-tuple of ints - using a str/bytes conflicts with the QString signatures. Phil ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] QHostAddress is missing a method
On Mittwoch, 27. Juli 2011, Phil Thompson wrote: On Wed, 27 Jul 2011 18:57:53 +0200, Detlev Offenbach det...@die-offenbachs.de wrote: On Dienstag, 26. Juli 2011, Phil Thompson wrote: On Sat, 16 Jul 2011 18:11:04 +0200, Detlev Offenbach det...@die-offenbachs.de wrote: Hello, I think the QHostAddress mappings are missing the method toIPv6Address. If I am right, would it be possible to add it? What's the most useful way to represent it? Would anything be better than the obvious 16 byte string? Phil ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt The Qt docs say: Returns the IPv6 address as a Q_IPV6ADDR structure. The structure consists of 16 unsigned characters. So in Python it should return a list (or tuple if it should be immutable) of 16 integers. Are you suggesting a list because that is the closest equivalent in Python? If so I would disagree. Or are you suggesting a list because of how you want to use the value? I should have thought a second longer. A 16 int tuple would be best (as you already implemented). Detlev -- Detlev Offenbach det...@die-offenbachs.de ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] QTableWidget - pyuic does not compile several attributes
On Thu, 28 Jul 2011 01:58:38 +0100, Protopia py...@protopia.co.uk wrote: I am not sure whether anyone has found this problem before, however I can't find it in the archives on Gmane. I first came across this problem when I designed a table in QT Designer, and set fonts on certain cells. But when I ran the code, no formatting. Looking at the code generated by pyuic I could not see the code I would expect to set the fonts. So, I generated a test UI file in Designer with all properties on the table widget, the vertical and horizontal titles and cells themselves (attached) And then I ran the compiler and looked at the code (attached) and found the following things missing: QTableWidget: 1. .font.Kerning not compiled. Fixed. 2. .font.Antialiasing not compiled Fixed. 3. .QTableView.sortingEnabled is placed in reTranslateUI - however this does not seem to be concerned with internationalisation and I feel should be in the main code (though I could easily be wrong here) This is a side effect of the way i18n support is implemented. 4. .QTableWidget.rowCount .columnCount - if these are specified explicitly in QT Designer then they appear twice in the .py file. (Of course this won't cause major problems, but is nevertheless inappropriate.) Fixed. QTableWidgetItem 1. Horizontal and Vertical header tooltips, whatsthis, fonts, textalign, background and foreground are not compiled at all. Fixed. 2. Cell tooltips, whatsthis, fonts and textalign are not compiled at all. Fixed. 3. Cell background and foreground are compiled, however sequence of statements is wrong - sets brush twice, then assigns second definition to both background and foreground. Fixed. Whilst we are looking at this code, it would also be helpful if we were to leave a blank line between code for QTableWidget, Horizontal Headers, Vertical Headers and Cells. Note: I am using python2.7.2 32-bit, and PyQt4.8.4-1 binary PyQt-Py2.7-x86-gpl-4.8.4-1.exe. P.S. I am trying to look at the uiparser.py and properties.py part of the Pyqt4 uic compiler to see if I can work out how to fix this - but as yet I have failed to understand the code well enough to work it out. Rgds, P I think QListWidgetItem and QTreeWidgetItem will have similar problems but I'll look at those tomorrow. Thanks, Phil ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] populate Qcombobox
Hi. I have some data into DB and i want to populate that into Combobox and get some errors for countries in cursor.execute(SELECT Country FROM iata_icao_codes;): self.connect(self.ui.country_list.addItem(0, str(countries))) error: TypeError: arguments did not match any overloaded call: QComboBox.addItem(QString, QVariant userData=QVariant()): argument 1 has unexpected type 'int' QComboBox.addItem(QIcon, QString, QVariant userData=QVariant()): argument 1 has unexpected type 'int' i Try with this form: for countries in cursor.execute(SELECT Country FROM iata_icao_codes;): self.connect(self.ui.country_list.insertItems(0, countries)) TypeError: arguments did not match any overloaded call: QObject.connect(QObject, SIGNAL(), QObject, SLOT(), Qt.ConnectionType=Qt.AutoConnection): argument 1 has unexpected type 'NoneType' QObject.connect(QObject, SIGNAL(), callable, Qt.ConnectionType=Qt.AutoConnection): argument 1 has unexpected type 'NoneType' QObject.connect(QObject, SIGNAL(), SLOT(), Qt.ConnectionType=Qt.AutoConnection): argument 1 has unexpected type 'NoneType' any idea? thanxs by the way -- Antonio Peña Secure email with PGP 0x8B021001 available at http://pgp.mit.edu Fingerprint: 74E6 2974 B090 366D CE71 7BB2 6476 FA09 8B02 1001 ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] populate Qcombobox
Le 28/07/11 20:22, Tony Peña a écrit : Hi. I have some data into DB and i want to populate that into Combobox and get some errors for countries in cursor.execute("SELECT Country FROM iata_icao_codes;"): self.connect(self.ui.country_list.addItem(0, str(countries))) error: TypeError: arguments did not match any overloaded call: QComboBox.addItem(QString, QVariant userData=QVariant()): argument 1 has unexpected type 'int' QComboBox.addItem(QIcon, QString, QVariant userData=QVariant()): argument 1 has unexpected type 'int' i Try with this form: for countries in cursor.execute("SELECT Country FROM iata_icao_codes;"): self.connect(self.ui.country_list.insertItems(0, countries)) TypeError: arguments did not match any overloaded call: QObject.connect(QObject, SIGNAL(), QObject, SLOT(), Qt.ConnectionType=Qt.AutoConnection): argument 1 has unexpected type 'NoneType' QObject.connect(QObject, SIGNAL(), callable, Qt.ConnectionType=Qt.AutoConnection): argument 1 has unexpected type 'NoneType' QObject.connect(QObject, SIGNAL(), SLOT(), Qt.ConnectionType=Qt.AutoConnection): argument 1 has unexpected type 'NoneType' any idea? thanxs by the way -- Antonio Peña Secure email with PGP 0x8B021001 available at http://pgp.mit.edu Fingerprint: 74E6 2974 B090 366D CE71 7BB2 6476 FA09 8B02 1001 ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt The return of addItem, insertItem and other is always None ... cb = QtGui.QComboBox() print cb.insertItem(0, "Item") None print cb.addItem("Item") None Why are you using 'connect' ? for countries in cursor.execute("SELECT Country FROM iata_icao_codes;"): self.ui.country_list.insertItems(0, countries) No ? -- Vincent V.V. Oqapy . Qarte+7 . PaQager ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] populate Qcombobox
oh .. ok.. i solved ok my trouble.. i'm complicated too much by anything with 2 lines i fix my problem :) countries = cursor.execute(SELECT DISTINCT(Country) FROM iata_icao_codes desc;) for line in countries: country = %s % line self.ui.country_list.addItem(country) thanxs any way for all :) 2011/7/28 Vincent Vande Vyvre vincent.vandevy...@swing.be ** Le 28/07/11 20:22, Tony Peña a écrit : Hi. I have some data into DB and i want to populate that into Combobox and get some errors for countries in cursor.execute(SELECT Country FROM iata_icao_codes;): self.connect(self.ui.country_list.addItem(0, str(countries))) error: TypeError: arguments did not match any overloaded call: QComboBox.addItem(QString, QVariant userData=QVariant()): argument 1 has unexpected type 'int' QComboBox.addItem(QIcon, QString, QVariant userData=QVariant()): argument 1 has unexpected type 'int' i Try with this form: for countries in cursor.execute(SELECT Country FROM iata_icao_codes;): self.connect(self.ui.country_list.insertItems(0, countries)) TypeError: arguments did not match any overloaded call: QObject.connect(QObject, SIGNAL(), QObject, SLOT(), Qt.ConnectionType=Qt.AutoConnection): argument 1 has unexpected type 'NoneType' QObject.connect(QObject, SIGNAL(), callable, Qt.ConnectionType=Qt.AutoConnection): argument 1 has unexpected type 'NoneType' QObject.connect(QObject, SIGNAL(), SLOT(), Qt.ConnectionType=Qt.AutoConnection): argument 1 has unexpected type 'NoneType' any idea? thanxs by the way -- Antonio Peña Secure email with PGP 0x8B021001 available at http://pgp.mit.edu Fingerprint: 74E6 2974 B090 366D CE71 7BB2 6476 FA09 8B02 1001 ___ PyQt mailing list PyQt@riverbankcomputing.comhttp://www.riverbankcomputing.com/mailman/listinfo/pyqt The return of addItem, insertItem and other is always None ... cb = QtGui.QComboBox() print cb.insertItem(0, Item) None print cb.addItem(Item) None Why are you using 'connect' ? for countries in cursor.execute(SELECT Country FROM iata_icao_codes;): self.ui.country_list.insertItems(0, countries) No ? -- Vincent V.V. Oqapy https://launchpad.net/oqapy . Qarte+7https://launchpad.net/qarte+7. PaQager https://launchpad.net/paqager ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt -- Antonio Peña Secure email with PGP 0x8B021001 available at http://pgp.mit.edu Fingerprint: 74E6 2974 B090 366D CE71 7BB2 6476 FA09 8B02 1001 ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt