Re: [PyQt] Re: dialogs and extentions
On 2008-10-29, Wim Verhavert wrote: Thanks for your reply Mark. I tried the discussed procedure this afternoon, and yes this works, but as you said, this will not allow for user resize, which is a pitty. The older approach did allow for resize, so I consider this a step back. Do you see any reason why they want to remove this from the API? I don't know why they made that change. If you don't call setSizeConstraint() the dialog is resizable and is the right size when you start and the right size when the extension is shown. But when the extension is hidden again the dialog does not resize down, so that's the only case you have to fix---but I don't think it is easy to do! Thanks again, and by the way: your book is great! Thanks:-D Wim On Wed, Oct 29, 2008 at 4:02 PM, Mark Summerfield [EMAIL PROTECTED] wrote: On 2008-10-29, Wim Verhavert wrote: I already found out that you can set the orientation with a call to 'setOrientation(Qt.Vertical)'. That solves my problem for now. But while I was searching for a solution I found the following: http://doc.trolltech.com/4.4/qdialog-obsolete.html. There they state that my solution is obsolete and we strongly advise against using them in new code. But the new method they propose, i.e. simply hide or show the widgets, will not resize my dialog properly (it will only grow and not shrink). I played around with this for a while but couldn't get it to working. Has anybody done it using this new method. Does it shrink properly again? How do you do it? A technique for doing what you want is to: (1) Put all the widgets that belong in the extension inside a QFrame that is itself laid out as usual (2) In the form's __init__ (a) hide the frame (thus hiding all the widgets it contains) (b) call: self.layout().setSizeConstraint(QLayout.SetFixedSize) (c) connect the button widget you're using to hide/show the extension's toggled(bool) signal to the frame's setVisible(bool) slot. Using this approach the dialog shrinks or grows as appropriate. The only downside is that it is not user resizeable. An example is in my book Rapid GUI Programming with Python and Qt, and you can download the examples from here: http://www.qtrac.eu/pyqtbook.html The example is: eg/chap09/findandreplace.{py,pyw} (the .pyw version is all in code the .py version's form is a .ui file) -- Mark Summerfield, Qtrac Ltd, www.qtrac.eu C++, Python, Qt, PyQt - training and consultancy C++ GUI Programming with Qt 4 - ISBN 0132354160 -- Mark Summerfield, Qtrac Ltd, www.qtrac.eu C++, Python, Qt, PyQt - training and consultancy Rapid GUI Programming with Python and Qt - ISBN 0132354187 ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] [PyKDE4] Bug? missing KTextEditor.Editor.setSimpleMode
Hi, I would like to embed KTextEditor in a configurable way in my application, but unfortunately PyKDE4 does not have the setSimpleMode() method on the KTextEditor.Editor object. It seems it's missing from the sip file in KDE 4.1.2 Is this a bug? with best regards, Wilbert Berendsen -- http://www.wilbertberendsen.nl/ You must be the change you wish to see in the world. -- Mahatma Gandhi ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Adding Codes to UI
HI all... I'm starting in Pyqt and have look in some examples and open sources.. I've noticed some people extend the class generated by pyui, putting your own code.. but.. if the UI needs to be change?? or how can i add this code in makefile?? is the right thing to do? Thanks in advance. Tobias ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] qlistview
hi, I'm quite newbie in pyqt, so maybe my question is silly but I couldn't find answer with google helps. I want to know when the user clicks on my listview. Now I'm using void clicked (const QModelIndex) signal but it isn't what I want, signal is emitted only when then index is valid. It is also interesting for me when index is invalid. How can I do this? Thanks in advance for help. Regards Krzychu ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] PyQt4 QComboBox, open upwards by default
I've worked for awhile without anything conclussive. I want a QComboBox that opens upwards by default. Right now if I open the list it will drop down, below its parent widget, but if I place the whole application near the bottom of the screen it will pop upwards. I want it to pop upwards by default. I have been going through the view, model, and the Qwidget properties, and I don't see what changes between it popping up, and dropping down. thank you mbs ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Crash (segfault) when using PyQt4 Qthread
Hi there, I'm getting a systematic crash when trying to log the output of a Qthread to a parent window. I'm using Qt 4 on Fedora Core 9 with Python 2.5.1: rpm -q PyQt4 python PyQt4-4.4.2-2.fc9.i386 python-2.5.1-26.fc9.i386 The following sample code crashes after a few iterations when clicking in and out of the log window, moving it around, etc... sufficiently. If you don't touch the window at all it doesn't crash though. Can someone explain what's going on here ? Is there something wrong with my threading architecture ? I guess the code should not give a segfault anyway. Thanks for your help, Chris snip---snip--- #!/usr/bin/python import sys import logging import time from PyQt4 import QtGui, QtCore, uic from PyQt4.QtCore import QString, QThread from PyQt4.QtGui import * logging.basicConfig(level=logging.INFO) class Page: def __init__(self): self.log = logging.getLogger('u.crawler') def analyze(self): for i in xrange(30): self.log.info('Line %d', i) time.sleep(2) class CrawlerThread(QThread): def __init__(self, page): self.page = page QThread.__init__ (self) def run(self): page = self.page page.log.info('Starting') page.analyze() class WindowLogger(logging.Handler): def __init__(self, window): self.window = window logging.Handler.__init__(self) def emit(self, record): self.window.appendPlainText(record.getMessage()) (urlFormUi, urlFormBase) = uic.loadUiType('urlForm.ui') class UrlCrawler(urlFormUi, urlFormBase): threadList = [] def __init__(self): urlFormBase.__init__(self) self.setupUi(self) self.log = logging.getLogger('u.crawler') self.log.addHandler(WindowLogger(self.winlog)) def accept(self): thread = CrawlerThread(Page()) UrlCrawler.threadList.append(thread) thread.start() def reject(self): self.close() def closeEvent(self, event): event.accept() if __name__ == __main__: app = QtGui.QApplication([]) app.main = UrlCrawler() app.main.show() sys.exit(app.exec_()) snip---snip--- You'll also need the following urlForm.ui file in ordre to run the sample. Click Ok to start the thread. snip---snip--- ui version=4.0 classdialog/class widget class=QDialog name=dialog property name=geometry rect x0/x y0/y width435/width height472/height /rect /property property name=windowTitle stringTest/string /property widget class=QDialogButtonBox name=buttonBox property name=geometry rect x250/x y10/y width181/width height32/height /rect /property property name=orientation enumQt::Horizontal/enum /property property name=standardButtons setQDialogButtonBox::Cancel|QDialogButtonBox::Ok/set /property /widget widget class=QPlainTextEdit name=winlog property name=geometry rect x10/x y50/y width421/width height411/height /rect /property property name=horizontalScrollBarPolicy enumQt::ScrollBarAlwaysOff/enum /property property name=readOnly booltrue/bool /property /widget /widget resources/ connections connection senderbuttonBox/sender signalaccepted()/signal receiverdialog/receiver slotaccept()/slot hints hint type=sourcelabel x248/x y254/y /hint hint type=destinationlabel x157/x y274/y /hint /hints /connection connection senderbuttonBox/sender signalrejected()/signal receiverdialog/receiver slotreject()/slot hints hint type=sourcelabel x316/x y260/y /hint hint type=destinationlabel x286/x y274/y /hint /hints /connection /connections /ui snip---snip--- -- View this message in context: http://www.nabble.com/Crash-%28segfault%29-when-using-PyQt4-Qthread-tp20255394p20255394.html Sent from the PyQt mailing list archive at Nabble.com. ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] qlistview
kachim kachim wrote: hi, I'm quite newbie in pyqt, so maybe my question is silly but I couldn't find answer with google helps. I want to know when the user clicks on my listview. Now I'm using void clicked (const QModelIndex) signal but it isn't what I want, signal is emitted only when then index is valid. It is also interesting for me when index is invalid. How can I do this? class ListView(QListView): def __init__(self, parent): QListView.__init__(self, parent) def mousePressEvent(self, event): if not self.indexAt(event.pos()).isValid(): print 'invalid index' QListView.mousePressEvent(self, event) Regards Baz Walter ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] QXmlQuery (Xpath...)
On Tue, 28 Oct 2008 05:56:06 -0700 (PDT), celsowm wrote: celsowm wrote: I tried a simple xptah sample, like this: from PyQt4 import QtXmlPatterns, QtCore query.setQuery(doc('index.htm')/html/body/p[1]); x = QtCore.QStringList; myFile = QtCore.QFile(index.htm) serializer = QtXmlPatterns.QXmlSerializer(query,myFile); query.evaluateTo(x); #dll error if use serealizer... Can you post the output, the versions of Qt and PyQt, and details of the platform you are using, please? If you really are getting a crash when you call this method, there's something seriously wrong somewhere. David ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt