Re: [PyQt] QTestLib
I've found a solution. self.dialog = DlgLogin(self) self.dialog.setCallback(callback) self.dialog.setModal(True) dialog = self.findChild(QWidget, QString('dialog_login')) print dialog login = dialog.findChild(QWidget, QString('editLogin')) login.setText('rad') print login password = dialog.findChild(QWidget, QString('editPassword')) password.setText('q1') print password ok = dialog.findChild(QWidget, QString('buttonOk')) print ok I think to move second section of this code to separate thread and run it to test application. But I need to understand what result is and how to check this result from my testing thread. On Sun, Oct 17, 2010 at 12:46 AM, Ruslan Popov ruslan.po...@gmail.comwrote: It's time to back to this question. I want to implement simple action replaying framework to test PyQt apps. I have main window and one dialog with two lineedits. I can open this dialog but don't understand how to access it from my framework to fill lineedits with data and accepts the dialog. Any ideas? On Sun, Jan 17, 2010 at 1:28 AM, Andreas Pakulat ap...@gmx.de wrote: On 17.01.10 00:08:39, Ruslan Popov wrote: Can someone share an example of using QTestLib with GUI application? I've read manuals and some Qt4 books, but they talk about C++ way, not Python. I don't think QTestlib works so easily in python as it uses a special macro in C++ to generate the boilerplate code to start the unit-test. You could probably lookup what the QTEST_MAIN macro does in Qt's c++ code and create similar code in python, but it might just as well be easier to use an existing python unit-testing framework to drive your tests. And the function to trigger signals or send events don't need the QTestlib setup to be used. Andreas -- A visit to a fresh place will bring strange work. ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt -- Ruslan Popov phone: +7 916 926 1205 skype: rpopov -- Ruslan Popov phone: +7 916 926 1205 skype: rpopov ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] QThread and qRegisterMetaType
I want the output of a function that runs in a thread to be shown in a QPlainTextEdit on the main window. Now this crashes with a message that I sould use qRegisterMetaType. There are dozens of entries on the web on this but I could not find any that tells how to. At least not how to in python. My handicap is that I have not too much experience with oo-programming and none at all with c++. Thus suggestions like call qRegisterMetaType() to register the data type before you establish the connection. are of no help and I have no idea what to make of things like qRegisterMetaTypeVolumeType( VolumeType ); Please can someone tell me what to do with the small example below to get it working. #!/usr/bin/python Small test application for threaded output to a QPlainTextEdit. The main window consists of three buttons and the QPlainTextEdit - pressButtonInsert clicked is connected to slotInsert: append text to the edit widget - pressButtonThread clicked is connected to slotInsertThreaded: append text to edit widget from within a separate thread - pressButtonClear clicked is connected to slotClear: clear the edit widget import sys, time from PyQt4 import QtCore, QtGui from qPlainTextEditGui import Ui_Form #the main form containing the 4 widgets class MyForm(QtGui.QMainWindow): def __init__(self, parent=None): QtGui.QWidget.__init__(self, parent) self.ui = Ui_Form() self.ui.setupUi(self) def slotClear(self): print('ButtonClear triggered') self.ui.plainTextEdit.clear() def slotInsert(self): print('ButtonInsert triggered') append_to_edit(self.ui.plainTextEdit) def slotInsertThreaded(self): print('ButtonTreaded triggered') self.work = work_thread(self.ui.plainTextEdit) self.work.start() class work_thread(QtCore.QThread): After http://joplaete.wordpress.com/2010/07/21/threading-with-pyqt4/ def __init__(self, edit, parent=None): QtCore.QThread.__init__(self, parent) self.edit = edit def run(self): append_to_edit(self.edit) def append_to_edit(edit): for i in range(5): edit.appendPlainText('line %d' % i) time.sleep(0.5) if __name__ == __main__: app = QtGui.QApplication(sys.argv) myapp = MyForm() myapp.show() sys.exit(app.exec_()) Now it works fine when pressButtonInsert is triggered but returns this when pressButtonThread is triggered: QObject::connect: Cannot queue arguments of type 'QTextBlock' (Make sure 'QTextBlock' is registered using qRegisterMetaType().) QObject::connect: Cannot queue arguments of type 'QTextCursor' (Make sure 'QTextCursor' is registered using qRegisterMetaType().) Many thanks for helping me out, Janwillem ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Issue with latest Windows Installer and Windows 7
Hi, I have a little problem using PyQt4 on Windows 7. I used the latest stable installer for Python 3.1. The program pylupdate4 does not execute as a normal user. When it starts up, the UAC pops up asking me to allow to continue the program. What might be wrong with my setup? This prevents it to be started from with PyQt4 as a QProcess. Kind regards Detlev -- Detlev Offenbach det...@die-offenbachs.de ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] QThread and qRegisterMetaType
On Sunday 17 October 2010, 19:04:16 Janwillem van Dijk wrote: I want the output of a function that runs in a thread to be shown in a QPlainTextEdit on the main window. Now this crashes with a message that I sould use qRegisterMetaType. There are dozens of entries on the web on this but I could not find any that tells how to. At least not how to in python. My handicap is that I have not too much experience with oo-programming and none at all with c++. Thus suggestions like call qRegisterMetaType() to register the data type before you establish the connection. are of no help and I have no idea what to make of things like qRegisterMetaTypeVolumeType( VolumeType ); This isn't possible is PyQt anyway, but these are signs of you doing something fundamentally wrong here. Please can someone tell me what to do with the small example below to get it working. Please read the text: Reentrancy and Thread-Safety in Qt's documentation and use the back and forth links to explore this topic to some extend. 98% of what is said there is applicable to PyQt, too. The example, that your code refers to did it right by using signals and slots to communicate between the main thread and the worker thread. You are not allowed to access widgets directly. BTW, your example isn't runnable since your ui file is missing. #!/usr/bin/python Small test application for threaded output to a QPlainTextEdit. The main window consists of three buttons and the QPlainTextEdit - pressButtonInsert clicked is connected to slotInsert: append text to the edit widget - pressButtonThread clicked is connected to slotInsertThreaded: append text to edit widget from within a separate thread - pressButtonClear clicked is connected to slotClear: clear the edit widget import sys, time from PyQt4 import QtCore, QtGui from qPlainTextEditGui import Ui_Form #the main form containing the 4 widgets class MyForm(QtGui.QMainWindow): def __init__(self, parent=None): QtGui.QWidget.__init__(self, parent) self.ui = Ui_Form() self.ui.setupUi(self) def slotClear(self): print('ButtonClear triggered') self.ui.plainTextEdit.clear() def slotInsert(self): print('ButtonInsert triggered') append_to_edit(self.ui.plainTextEdit) def slotInsertThreaded(self): print('ButtonTreaded triggered') self.work = work_thread(self.ui.plainTextEdit) ^ Bad idea starts here self.work.start() class work_thread(QtCore.QThread): After http://joplaete.wordpress.com/2010/07/21/threading-with-pyqt4/ def __init__(self, edit, parent=None): QtCore.QThread.__init__(self, parent) self.edit = edit def run(self): append_to_edit(self.edit) def append_to_edit(edit): for i in range(5): edit.appendPlainText('line %d' % i) ^^^ *Bang* time.sleep(0.5) bad style, better use QThread.msleep() if __name__ == __main__: app = QtGui.QApplication(sys.argv) myapp = MyForm() myapp.show() sys.exit(app.exec_()) Now it works fine when pressButtonInsert is triggered but returns this when pressButtonThread is triggered: QObject::connect: Cannot queue arguments of type 'QTextBlock' (Make sure 'QTextBlock' is registered using qRegisterMetaType().) QObject::connect: Cannot queue arguments of type 'QTextCursor' (Make sure 'QTextCursor' is registered using qRegisterMetaType().) Many thanks for helping me out, Janwillem Good luck, Pete ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] QComboBox replacing edit text if case differs from existing item.
Hi I'm having a problem with QComboBox not allowing me to change the edit text to anything existing item of differing case. Example code is below. What I'd like to do is enter 'one' into a combo box already containing the item 'One' without the side effect of the text being changed to 'One'. Currently it's changed back to 'One' as soon as the combo box loses focus. Disabling AutoCompletionCaseSensitivity works, but it has the side effect of not being useful (Doesn't eg. show completions for 'one'). I've also tried overriding the focusOutEvent of QComboBox and restoring the correct text, but then things like copy-paste don't work. Changing the completer hasn't helped any either. The fact combo boxes behave this way is detrimental to my app. If anyone has any ideas (or I missed something obvious), please let me know. I'm using Qt 4.6.2 and PyQt 4.7.2 on Ubuntu 10.04, but have experienced this on other distros/Qt versions above 4.5. Thanks and Regards Code - from PyQt4.QtGui import * from PyQt4.QtCore import SIGNAL, Qt class Widget(QWidget): def __init__(self, parent=None): super(Widget, self).__init__(parent) combo = QComboBox() combo.setEditable(True) combo.addItems(['One', 'Two', 'Three']) lineedit = QLineEdit() layout = QVBoxLayout() layout.addWidget(combo) layout.addWidget(lineedit) self.setLayout(layout) app = QApplication([]) widget = Widget() widget.show() app.exec_() ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] QList Specialization Class SIP Error
On Sat, 16 Oct 2010 19:40:02 +0200, James Meyer jam...@lantic.net wrote: Hi I have a C++ class that extends QList, or more specifically QListPoint where Point is one of our custom classes. SIP gives me a syntax error as soon as I add the template parameter to the inheritance. In C++: class PointList : public QListPoint { ... }; In SIP: class PointList : QListPoint { %TypeHeaderCode #include PointList.h %End ... }; How am I suppose to specify this inheritance in the SIP file? You have to implement PointList as a %MappedType. Phil ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] QList Specialization Class SIP Error
On Sun, 17 Oct 2010 21:07:55 +0100, Phil Thompson p...@riverbankcomputing.com wrote: On Sat, 16 Oct 2010 19:40:02 +0200, James Meyer jam...@lantic.net wrote: Hi I have a C++ class that extends QList, or more specifically QListPoint where Point is one of our custom classes. SIP gives me a syntax error as soon as I add the template parameter to the inheritance. In C++: class PointList : public QListPoint { ... }; In SIP: class PointList : QListPoint { %TypeHeaderCode #include PointList.h %End ... }; How am I suppose to specify this inheritance in the SIP file? You have to implement PointList as a %MappedType. ...or as a class with no super-classes and explicitly define those QList methods you want to access from Python. See PyQt's implementation of QPolygon. Phil ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] QList Specialization Class SIP Error
Hi Thanks for the reply. Sorry to be a pain, but I'm quite new to SIP. How exactly would I implement this as a mapped type? Do I only need to specify the %ConvertToTypeCode and %ConvertFromTypeCode directives similar to QList itself. Will I reference QList at all in the mapped type specification? Thanks James On 2010/10/17 10:13 PM, Phil Thompson wrote: On Sun, 17 Oct 2010 21:07:55 +0100, Phil Thompson p...@riverbankcomputing.com wrote: On Sat, 16 Oct 2010 19:40:02 +0200, James Meyerjam...@lantic.net wrote: Hi I have a C++ class that extends QList, or more specifically QListPoint where Point is one of our custom classes. SIP gives me a syntax error as soon as I add the template parameter to the inheritance. In C++: class PointList : public QListPoint { ... }; In SIP: class PointList : QListPoint { %TypeHeaderCode #includePointList.h %End ... }; How am I suppose to specify this inheritance in the SIP file? You have to implement PointList as a %MappedType. ...or as a class with no super-classes and explicitly define those QList methods you want to access from Python. See PyQt's implementation of QPolygon. Phil ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt