[PyQt] X Errors
If I run the following program, and scroll all the way down to the bottom of the window, I get a bunch of XErrors, like so: X Error: BadAlloc (insufficient resources for operation) 11 Major opcode: 53 (X_CreatePixmap) Resource id: 0x8a X Error: BadDrawable (invalid Pixmap or Window parameter) 9 Extension:152 (RENDER) Minor opcode: 4 (RenderCreatePicture) Resource id: 0x460042e X Error: RenderBadPicture (invalid Picture parameter) 169 Extension:152 (RENDER) Minor opcode: 7 (RenderFreePicture) Resource id: 0x460042f I'm not sure if this is a qt bug, a pyqt bug, or what. Any suggestions would be appreciated. --- import sys from PyQt4.QtGui import * from PyQt4.QtCore import * app = QApplication(sys.argv) main_window = QMainWindow() # Create a column of many QTextEdits in a QScrollArea scroll_area = QScrollArea() column = QGroupBox() column.setLayout(QVBoxLayout()) text_edits = [] for i in range(40): # Add a lot of text to each QTextEdit text_edit = QTextEdit(Testing * 1000) column.layout().addWidget(text_edit) text_edits.append(text_edit) main_window.setCentralWidget(scroll_area) scroll_area.setWidget(column) scroll_area.setWidgetResizable(True) main_window.resize(600,300) # Resize each QTextEdit so that it displays all of its text without # needing scrollbars for text_edit in text_edits: fm = QFontMetrics(text_edit.font()) bounding_rect = QRect(0,0, text_edit.width(), 0) bounding_rect = fm.boundingRect(bounding_rect, Qt.TextWrapAnywhere, text_edit.toPlainText()) text_edit.setFixedHeight(bounding_rect.height()) main_window.show() app.exec_() ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] PyQt/SIP snapshots
On Sun, 29 Mar 2009 04:22:14 +0200, David Boddie da...@boddie.org.uk wrote: On Sunday 29 March 2009, Phil Thompson wrote: On Sat, 28 Mar 2009 21:16:31 +0100, David Boddie da...@boddie.org.uk * pyrcc4 now requires you to pass -py2 for Python 2.x code - this breaks existing build environments. Is there a way that it could figure out which version of Python it is running with and use that to determine what kind of code to generate? I can't think of one (until pyrcc4 is re-written in Python). You only need to pass -py2 for Python 2.5.x and earlier. If it was for Python 2.x then I would have made it the default. Ah, I forgot that pyrcc4 is written in C++. Was it done so for performance reasons or was there something that couldn't easily be done in Python? Neither, it's a simple hack of rcc. I think a Python version would be fairly trivial to implement, but it's always been low priority. Phil ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Re: Incorrect HTML (Rich Text) parsing/rendering.
I finally got around to building an test of this in c++. The problems exist there too. So this is a QT bug, and has nothing to to with PyQt. amicitas On Sun, Mar 22, 2009 at 11:57 PM, mir amicitas amici...@gmail.com wrote: I am having problems with rendering HTML (Rich Text) in PyQt. I am using PyQt-Py2.6-gpl-4.4.4-2 with Python 2.6.1. These errors show up with any widget that can display Rich Text. For my HTML display example I am using a QTextBrowser. The problems involve incorrect closing of various tags. Even more strange is that the behavior is different if I use QTextBrowser.setHtml() or QTextBrowser.setSource(). For the example that I am attaching below there are two errors. 1. The div tags around the title are not being closed until after the next line of text. 2. The list is not closed until the end of the file (ol and li tags). Problem #1 happens with both setHtml() and setSource(). Problem #2 happens only with setSource. Clicking on a link has equivalent behavior to using setSource() Both the display of the HTML in the widget, and the output from QTextBrowser.toHtml() are incorrect. I do not know if this is a Qt or a PyQt issue, but I thought I would ask for help here first. Included at the bottom of this message is a representative program and the output (simplified). Attached is the program and output (raw). Thanks in advance for any help. Amicitas === html_display.py === from PyQt4 import QtCore, QtGui import sys # Set up the base window. class MainWindow(QtGui.QMainWindow): def __init__(self, parent): QtGui.QMainWindow.__init__(self, parent) html = r html body div align=centerThis should be centered./div br This should be left justified. ol liItem 1/li liItem 2/li /ol br brThis should not be part of a list. br bra href=simple.htmlsimple.html/a /body /html self.browser = QtGui.QTextBrowser(self) self.setCentralWidget(self.browser) self.resize(600,400) self.browser.setHtml(html) filename = 'output_setHtml.html' with open(filename, 'w') as file: file.write(self.browser.toHtml()) source = QtCore.QUrl('simple.html') self.browser.setSource(source) filename = 'output_setSource.html' with open(filename, 'w') as file: file.write(self.browser.toHtml()) # Initialize the Qt application app = QtGui.QApplication(sys.argv) # Start the program. if __name__ == '__main__': main_window = MainWindow(None) main_window.show() sys.exit(app.exec_()) === simple.html - Input HTML === html body div align=centerThis should be centered./div br This should be left justified. ol liItem 1/li liItem 2/li /ol br brThis should not be part of a list. br bra href=simple.htmlsimple.html/a /body /html === output_setHtml.html - Output HTML (For clarity I have removed all css and added white space) === !DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.0//EN http://www.w3.org/TR/REC-html40/strict.dtd; html head meta name=qrichtext content=1 / style type=text/css p, li { white-space: pre-wrap; } /style /head body p This should be centered. br /This should be left justified. /p ol liItem 1 /li liItem 2/li /ol p br / br /This should not be part of a list. br / br /a href=simple.htmlspansimple.html/span/a /p /body /html === output_setSource.html - Output HTML (For clarity I have removed all css and added white space) === !DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.0//EN http://www.w3.org/TR/REC-html40/strict.dtd; html head meta name=qrichtext content=1 / style type=text/css p, li { white-space: pre-wrap; } /style /head body p align=center This should be centered. br /This should be left justified. /p ol liItem 1 /li liItem 2 br / br /This should not be part of a list. br / br /a href=simple.htmlspansimple.html/span/a /li /ol /body /html ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Reach a line in a QTextEdit
Hello, I would like to go for example to the fourth line in a QTextEdit. Is-it possible to do that directly or must I have to walk along the three first lines so as to go to the start of the fourth one ? Best regards. Christophe ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Reach a line in a QTextEdit
projet...@club-internet.fr wrote: I would like to go for example to the fourth line in a QTextEdit. Is-it possible to do that directly or must I have to walk along the three first lines so as to go to the start of the fourth one ? Use either: 1. QTextEdit::moveCursor(), but you need a for loop to go up/down for multiple lines. Example: editor = QtGui.QTextEdit() [...] for l in range(4): editor.moveCursor(QtGui.QTextCursor.Down, QtGui.QTextCursor.MoveAnchor) 2. QTextEdit::textCursor() to get the cursor, then QTextCursor::movePosition() and then QTextEdit::setTextCursor() so that it takes effects. Example: editor = QtGui.QTextEdit() [...] cursor = editor.textCursor() cursor.movePosition(QtGui.QTextCursor.Down, QtGui.QTextCursor.MoveAnchor, 4) editor.setTextCursor(cursor) Regards, Cyril ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] caching qgraphicssvgitem is buggy
I am using qt4.5 with python-qt4.4.4 (ubuntu jaunty) In my application I have a qgraphicssvgitem. When I change the element to be rendered with setElementId(), this change does not do anything. I still see the old element displayed. Only after I invalidate the cache or resize the view (which also resizes the graphicssvgitem) the correct new element is shown. If I disable caching, I have no problems either. the two elements have the same size and the names TILE_1 and TILE_2 Could this be a problem with pyqt, or rather with qt4.5? The list of bugs to be fixed with 4.5.1 does not mention this. I checked the qt4.5 code: void QGraphicsSvgItem::setElementId(const QString id) { Q_D(QGraphicsSvgItem); d-elemId = id; d-updateDefaultSize(); update(); } -- Wolfgang ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Dead lock detected
On mercredi 25 mars 2009, Frédéric wrote: When executing my program, I have the following error: Qt: Dead lock detected while activating a BlockingQueuedConnection: Sender is PyQtProxy(0x2d12c20), receiver is PyQtProxy(0x2d14cb0) and the program freezes. What can cause such error? What is a PyQtProxy for? No idea what can cause this error? I can't find the problem... -- Frédéric http://www.gbiloba.org ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] QSVGWidget load method, python3
Okay I was playing around with python 3 and I found that the SVGWidget gives me a 'file not found error' when I use either the method #new data is a QString svg file serialized_data = newdata.toLocal8Bit() self.load(serialized_data) or if I use a connect statement, self.connect(self, QtCore.SIGNAL(ready( const QByteArray)),self.load) self.emit(QtCore.SIGNAL(ready( const QByteArray)),serialized_data) It appears that both ways are using the QSVGWidget.load(self,QString filename) method instead of the QSvgWidget.load(self,QByteArray contents) using: Qt 4.5.0 PyQt, Sip snapshots 20090324 python3.1a1 On a side note, maybe this is just the documentation not being up todate with python version three, QByteArray.fromRawData(str) was only working if I used a byte array, ie QByteArray.fromRawData(str.encode(my_string)) thanks mbs ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: Re: [PyQt] Reach a line in a QTextEdit
The first method works very well. Thanks a lot ! Christophe. I would like to go for example to the fourth line in a QTextEdit. Is-it possible to do that directly or must I have to walk along the three first lines so as to go to the start of the fourth one ? Use either: 1. QTextEdit::moveCursor(), but you need a for loop to go up/down for multiple lines. Example: editor = QtGui.QTextEdit() [...] for l in range(4): editor.moveCursor(QtGui.QTextCursor.Down, QtGui.QTextCursor.MoveAnchor) 2. QTextEdit::textCursor() to get the cursor, then QTextCursor::movePosition() and then QTextEdit::setTextCursor() so that it takes effects. Example: editor = QtGui.QTextEdit() [...] cursor = editor.textCursor() cursor.movePosition(QtGui.QTextCursor.Down, QtGui.QTextCursor.MoveAnchor, 4) editor.setTextCursor(cursor) Regards, Cyril ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] AttributeError: installTranslator
Hi, I had a bug report last week on PyQtShell Google Code site and I can't see what's wrong. Here it the traceback (where app is a QApplication instance and qt_translator is a QTranslator instance): traceback: Traceback (most recent call last): File /usr/bin/pydee, line 8, in module load_entry_point('PyQtShell==0.3.14', 'gui_scripts', 'pydee')() File /usr/lib/python2.5/site-packages/PyQtShell-0.3.14-py2.5.egg/PyQtShell/pydee.py, line 595, in main app.installTranslator(qt_translator) AttributeError: installTranslator Any guess? Thanks, Pierre ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt