Re: [PyQt] Python property in QObject masks AttributeErrors
On Mon, 2011-04-18 at 22:18 +0100, Phil Thompson wrote: > On Mon, 18 Apr 2011 14:07:13 +0200, Benjamin Kloster > wrote: > > Hi everyone, > > twice now I've stumbled over a subtle bug when subclassing QObject. When > > the getter of a python property raises an AttributeError for any > > attribute or object, PyQt seems to reraise this error improperly, > > clearing the traceback and often reporting a false object type and > > attribute name. See the attached script for a minimal example. > > > > Regards, > > Ben > > It's working as it should. > > If the getter raises an AttributeError Python then calls any __getattr__ > method. If there is no method then the exception raised by the getter is > propagated. If there is a __getattr__ then the getter exception is > discarded and the exception raised by __getattr__ is propagated. > > QObject implements __getattr__ so the exception raised by the failure of > QtCore.iDontExist is discarded. The exception that QObject.__getattr__ > raises is what you are seeing. > > Phil > The normal behavior of a Python object is to report the first AttributeError ("'module' object has no attribute 'iDontExist'). At least in Python 2.6, 2.7 and 3.2 it is. Just replace "QtCore.QObject" with "object" in the example to reproduce this. Especially if a getter is rather involved and maybe even calls third party libraries that produce the original AttributeError, debugging becomes confusing at best with PyQt's behavior. If it's not feasible to implement the correct (i.e. standard Python) error reporting, I can live with that. However, I couldn't find any note of this caveat in PyQt's documentation. So if it's really not there, it should probably be added. Ben ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Help with Design of Dialog interface
On Sun, 17 Apr 2011 19:43:17 +0100, alsaf wrote: > I am currently writing a project which takes vocabulary words from a XML > file which is created through the KDE application Parley and generates > sentences based on them. The project page is here: > > https://sourceforge.net/projects/languagesentenc/ [...] > The part I am stuck at is the maintenance of the sentence templates. > This part of the GUI will extract all the word types from the XML file > which will used to validate the input the user enters when creating the > sentence template. The only way I think I can do this is to create a > widget that contains a drop down list and a button. The user selects the > word type from the list and when the button is pressed the contents of > the drop down list is then appended to the sentence template. This > sounds a bit clunky and cumbersome to do. Is there any easier way like a > line edit button which has an auto-complete option or some other method > is input that I can use? There is a recipe for an auto-completing line edit in the Wiki: http://www.diotavelli.net/PyQtWiki/Adding_auto-completion_to_a_QLineEdit Another possibility is to present a menu when the user presses a certain key. The following recipe uses the Tab key for this: http://www.diotavelli.net/PyQtWiki/Adding_tab-completion_to_a_QLineEdit As the page says, it would probably be best to use a QCompleter instead of a list, so perhaps you could try taking the best parts from each of these examples. David ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Error while installing PyQtMobility 1.0 on Ubuntu 10.10
On Mon, 18 Apr 2011 11:24:13 +0100, Phil Thompson wrote: > On Mon, 18 Apr 2011 18:13:17 +0800, chinakr wrote: [...] > > Generating the C++ source for the QtContacts module... > > sip: > > /home/chinakr/src/PyQtMobility-gpl-1.0/sip/QtContacts/qcontactaddress.sip:37: > > Cannot mix %AccessCode and %GetCode or %SetCode > > Error: Unable to create the C++ code. > > > > I tried to google with 'Error: Unable to create the C++ code', but > > found nothing. > > What should I do now? Any suggestion? > > I can't reproduce this. Can you try with the current SIP snapshot? I encountered this on two, possibly three different systems, so I'll try to reproduce the problem and post more details. Since I was building everything from source, my workaround was to build PyQt then hack SIP to get PyQtMobility to build. David ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Python property in QObject masks AttributeErrors
On Mon, 18 Apr 2011 14:07:13 +0200, Benjamin Kloster wrote: > Hi everyone, > twice now I've stumbled over a subtle bug when subclassing QObject. When > the getter of a python property raises an AttributeError for any > attribute or object, PyQt seems to reraise this error improperly, > clearing the traceback and often reporting a false object type and > attribute name. See the attached script for a minimal example. > > Regards, > Ben It's working as it should. If the getter raises an AttributeError Python then calls any __getattr__ method. If there is no method then the exception raised by the getter is propagated. If there is a __getattr__ then the getter exception is discarded and the exception raised by __getattr__ is propagated. QObject implements __getattr__ so the exception raised by the failure of QtCore.iDontExist is discarded. The exception that QObject.__getattr__ raises is what you are seeing. Phil ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Qxt
I've been using Qxt on a c++/Qt project, but now I miss it on a pyqt project. http://libqxt.bitbucket.org/doc/ I've had a quick look at SIP with the intention of creating a pyQxt lib.. but have to admit that I'm slightly out of my depth and lacking time at the moment. Are there any tips or even support on how to do this; seems like I have to create a lot of *.sip files. Pete ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Python property in QObject masks AttributeErrors
Hi everyone, twice now I've stumbled over a subtle bug when subclassing QObject. When the getter of a python property raises an AttributeError for any attribute or object, PyQt seems to reraise this error improperly, clearing the traceback and often reporting a false object type and attribute name. See the attached script for a minimal example. Regards, Ben from PyQt4 import QtCore class Object(QtCore.QObject): def getX(self): # Raises AttributeError: 'module' object has no attribute 'iDontExist' return QtCore.iDontExist x = property(fget=getX) if __name__ == "__main__": o = Object() # Raises AttributeError: 'Object' object has no attribute 'x' o.x ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Error while installing PyQtMobility 1.0 on Ubuntu 10.10
On Mon, 18 Apr 2011 18:13:17 +0800, chinakr wrote: > I want to create a simple recorder and I tried QtMultimedia module. > Then I met 'ImportError: No module named QtMultimedia'. > I found the error reason via google, that is: > https://bugs.launchpad.net/ubuntu/+source/python-qt4/+bug/590140 > I also found PyQtMobility 1.0 and tried to install it on my Ubuntu 10.10. > I did it as follow: > > $ tar zxvf PyQtMobility-gpl-1.0.tar.gz > $ cd PyQtMobility-gpl-1.0/ > #official instruction > $ gvim README > $ sudo aptitude install qtmobility-dbg > $ sudo updatedb > $ sudo locate qmobilityglobal.h > /usr/include/qmobilityglobal.h > $ python configure.py --help > ... > -n DIRthe directory containing the QtMobility header file > directories [default: /usr/include/qt4] > ... > $ python configure.py -n /usr/include > This is the GPL version of PyQtMobility 1.0. > QtMobility 1.0.2 is being used. > PyQt 4.8.3 is being used. > Qt v4.7.0 free edition is being used. > SIP 4.12.1 is being used. > The QtMobility package will be installed in > /usr/lib/python2.6/dist-packages/PyQt4. > The QtMobility .sip files will be installed in /usr/share/sip/PyQt4. > The QtMobility modules are being built with generated docstrings. > The QtMobility modules are being built with 'protected' redefined as > 'public'. > Generating __init__.py for the package... > Generating the C++ source for the QtContacts module... > sip: > /home/chinakr/src/PyQtMobility-gpl-1.0/sip/QtContacts/qcontactaddress.sip:37: > Cannot mix %AccessCode and %GetCode or %SetCode > Error: Unable to create the C++ code. > > I tried to google with 'Error: Unable to create the C++ code', but > found nothing. > What should I do now? Any suggestion? I can't reproduce this. Can you try with the current SIP snapshot? Phil ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Error while installing PyQtMobility 1.0 on Ubuntu 10.10
I want to create a simple recorder and I tried QtMultimedia module. Then I met 'ImportError: No module named QtMultimedia'. I found the error reason via google, that is: https://bugs.launchpad.net/ubuntu/+source/python-qt4/+bug/590140 I also found PyQtMobility 1.0 and tried to install it on my Ubuntu 10.10. I did it as follow: $ tar zxvf PyQtMobility-gpl-1.0.tar.gz $ cd PyQtMobility-gpl-1.0/ #official instruction $ gvim README $ sudo aptitude install qtmobility-dbg $ sudo updatedb $ sudo locate qmobilityglobal.h /usr/include/qmobilityglobal.h $ python configure.py --help ... -n DIRthe directory containing the QtMobility header file directories [default: /usr/include/qt4] ... $ python configure.py -n /usr/include This is the GPL version of PyQtMobility 1.0. QtMobility 1.0.2 is being used. PyQt 4.8.3 is being used. Qt v4.7.0 free edition is being used. SIP 4.12.1 is being used. The QtMobility package will be installed in /usr/lib/python2.6/dist-packages/PyQt4. The QtMobility .sip files will be installed in /usr/share/sip/PyQt4. The QtMobility modules are being built with generated docstrings. The QtMobility modules are being built with 'protected' redefined as 'public'. Generating __init__.py for the package... Generating the C++ source for the QtContacts module... sip: /home/chinakr/src/PyQtMobility-gpl-1.0/sip/QtContacts/qcontactaddress.sip:37: Cannot mix %AccessCode and %GetCode or %SetCode Error: Unable to create the C++ code. I tried to google with 'Error: Unable to create the C++ code', but found nothing. What should I do now? Any suggestion? ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] visualizing PDF files in PyQT WIndows
Gelonida G wrote: > Is there any recommended way to visualize PDF files with PyQT under > Windows? There's the poppler library, if you don't mind a GPLv2 library. There's a python interface to this http://svn.pardus.org.tr/uludag/trunk/playground/pypoppler-qt4/ (I haven't used this). There's also the muPDF library, but I don't know python wrappers. Alternatively you could just use ghostscript to render each page to a bitmap file and make a simple bitmap viewing window in PyQt. Jeremy -- http://www.jeremysanders.net/ ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] visualizing PDF files in PyQT WIndows
On 04/17/2011 05:31 PM, Gelonida G wrote: > Hi, > > Is there any recommended way to visualize PDF files with PyQT under Windows? > > > Thanks in advance for any pointers Well having received the answer to another question I had already one possible solution, though it is not optimal. I could create a QWebview, install a PDF viewer plugin and let it display the PDF. There is one issue though. The plugin will contain its own menus allowing to open other pdf files or saving the pdf file at another lcoation. I would like to display / navigate the pdf file, but to disable all other featers / decorations. Is there perhaps another way of displaying pdf contetns or is there a way to configure pdf plugins to be less permissive? ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Disable context menu of a plugin in QWebview
Hi, Now I am able to activate a flash plugin in my QWebview browser and things work as they should. There is just one minor problem The browser should always display a given context menu when the user clicks on the riht mouse button. The flash plugin however grabs the right mouse click and displays the plugin's menu. Is there any way to just display the default browser context menu. If really desired, then I could perhaps allow a second path (sub menu of my context menu) to access the plugins context menu. Thanks in advance for any ideas. ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Use QWebview with Flash plugin
Hi David, Thanks a lot for your help. Installing a normal Firefox Flash plugin and setting QWebSettings.PluginsEnabled to True did the trick. Thanks a gain 04/18/2011 02:31 AM, David Boddie wrote: > On Sat, 16 Apr 2011 18:55:43 +0200, Gelonida Gmail wrote: > >> I'd like to have a small QWebview window in our application, which could >> display the contents of a web page requiring Flash. >> >> >> Is this possible with PyQT? >> >> If yes, is it possible >> - on a Windows platform >> - on a linux platform > > Yes, on both, but much depends on the versions of the Flash plugin and the > WebKit library being used. It's probably best to ask people which versions > of Qt they are using successfully together with Flash then test those > combinations. > >> which version of Flash would be supported and what would be the procedure: >> - to install the flash plugin > > This would be the place used by Firefox. > >> - tell pyqt where the plugins are located > > The Qt 4.5 documentation had a section about this: > > http://doc.qt.nokia.com/4.5/qtwebkit.html#netscape-plugin-support > > In other words, it shouldn't be necessary to do anything. > >> - activate the plugin for a given QWebview window > > I don't think you can enable/disable plugins on a per-window basis. I could > be wrong, however, and I'm sure that there are people reading this that do > a lot more with WebKit than I do. > >> What versions would be supported. > > I'm not sure about this. Searching this mailing list's archives and those > for qt-interest might reveal some data. > > David ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] removeItemWidget bug
On Mon, 18 Apr 2011 00:34:44 +0100, Peter Morgan wrote: > I've experienced a bug which after a few hours found someone else is > experiencing also, and explained in detail > > In a Python program I use setItemWidget() to add widgets to columns > of QTreeWidgetItems (eg QPushButton, QComboBox, etc). > > When a widget is no longer needed it is removed using removeItemWidget(), > however this action causes the removal of the QTreeWidgetItem itself > instead of just removing the item widget attached by setItemWidget(). > > Problem goes away if extra references to QTreeWidgetItems are kept > somewhere outside the QTreeWidget instance. > > This problem does not occur in a C++ implementation. > > > http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=599612 > > Are the pyqt developers aware of this? > > Regards > > Pete Fixed in tonight's snapshot. Thanks for reporting it. If the Debian maintainers had pushed it upstream it would have been fixed 6 months ago. Phil ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt