Re: [PyQt] Adding a widget to a layout that belongs to a QGroupBox changes that widget's parent?
On 13.08.09 15:34:44, Nate Reid wrote: > I'm using PyQt 4.5.1 > > For some reason the parent is changing, but only when a QGroupBox is used... No, if you have widget A added to a layout thats set on widget B and widget A's parent is not widget B then A is _always_ reparented to B. The code for that is in qwidget.cpp and qlayout.cpp. IIRC this is also documented in the QLayout api docs. > Another odd thing is that if I uncomment out the line > "self.layout.addWidget(self.box), it crashes (e.g. stalls out completely, and > I have to kill the shell) Recursive layouts are not supported by Qt, i.e. you can't add the box to the box' layout. Andreas -- Blow it out your ear. ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Adding a widget to a layout that belongs to a QGroupBox changes that widget's parent?
I'm using PyQt 4.5.1 For some reason the parent is changing, but only when a QGroupBox is used... Another odd thing is that if I uncomment out the line "self.layout.addWidget(self.box), it crashes (e.g. stalls out completely, and I have to kill the shell) Here is the sample script that produces the issue: # import sys from PyQt4 import QtCore, QtGui class MyWidget(QtGui.QWidget): def __init__(self, parent): QtGui.QWidget.__init__(self, parent) self.box = QtGui.QGroupBox() self.tree = QtGui.QTreeWidget(self) print "Tree's parent before being layed out:", self.tree.parent() self.layout = QtGui.QVBoxLayout() self.layout.addWidget(self.tree) self.box.setLayout(self.layout) print "Tree's parent after being layed out:", self.tree.parent() self.othertree = QtGui.QTreeWidget(self) print "Other Tree's parent before being layed out:", self.othertree.parent() self.otherlayout = QtGui.QVBoxLayout() self.otherlayout.addWidget(self.othertree) self.setLayout(self.otherlayout) print "Other Tree's after before being layed out:", self.othertree.parent() #self.layout.addWidget(self.box) if __name__ == '__main__': app = QtGui.QApplication(sys.argv) widget = MyWidget(None) widget.show() sys.exit(app.exec_()) # Thanks! -Nate ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Collapse/expand frame
Thanks for all the feedback. Are there any good tutorials for implementing your own custom widgets/layouts? (if no one has an implementation of this) Cheers, -Scott Alexei Puzikov wrote: I'm really looking for a frame that has the collapse/expand ability built into it. See the image in the link. You can see the Texture Map submenu collapsed/expanded. Any thoughts? www.scottballard.net/collapsibleFrame.jpg I see - why don't you BYO. This kind of widget is uncommon, and thus the reason not being available already. But it's pretty easy to combine basic widgets to a composite one. And due to Qts powerful layout machinery, you mostly don't need to care about the implicit widget resize. Actually, you do, as soon as you'll pass over some amount of controls. I have the editor here that reimplements the screenshot (it's Maya, btw) and in worst situations contains approx. 4500 controls. And I'm still unable to remove flickering on switch - basically, the layout refresh. If anybody can prototype something that works with big amount of controls - his help would be enormous. Really. A. __ Information from ESET NOD32 Antivirus, version of virus signature database 4333 (20090813) __ The message was checked by ESET NOD32 Antivirus. http://www.eset.com __ Information from ESET NOD32 Antivirus, version of virus signature database 4333 (20090813) __ The message was checked by ESET NOD32 Antivirus. http://www.eset.com ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] inheriting from QObject and dbus.service.Object
On Thu, Aug 13, 2009 at 09:59:30PM +0100, Phil Thompson wrote: > On Thu, 13 Aug 2009 17:12:52 +0200, Marcos Dione > wrote: > > meanwhile the above method works (or so I've read): create a class > > inheriting from the 2 metaclasses and use it as the metaclass of the > > inheriting > > class. > > Hmm, interesting... I'm nearer, but still no cigar. I think I've hit a dbus.service.Object bug. see: http://grulicueva.homelinux.net/~mdione/glob/posts/qobject-dbus/ -- (Not so) Random fortune: I'd like to get rid of some of the glass, and replace it with padding. Because you all know we'd all fit better in a padded room than a glass house.. -- Linus Torvalds ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Collapse/expand frame
>> I'm really looking for a frame that has the collapse/expand ability >> built into it. See the image in the link. You can see the Texture Map >> submenu collapsed/expanded. Any thoughts? >> >> www.scottballard.net/collapsibleFrame.jpg > > I see - why don't you BYO. This kind of widget is uncommon, and thus the > reason not being available already. > > But it's pretty easy to combine basic widgets to a composite one. And due to > Qts powerful layout machinery, you mostly don't need to care about the > implicit widget resize. Actually, you do, as soon as you'll pass over some amount of controls. I have the editor here that reimplements the screenshot (it's Maya, btw) and in worst situations contains approx. 4500 controls. And I'm still unable to remove flickering on switch - basically, the layout refresh. If anybody can prototype something that works with big amount of controls - his help would be enormous. Really. A. ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] lastQuery() from an QSqlRelationalTableModel
Hello, How can I view the last query submitted to an QSqlRelationalTableModel instance? I'm trying to debug a data-widget mapped form's submitAll() that is not storing one of it's mapped members. I've made numerous stabs at things like: theQuery = QtSql.QSqlQueryModel.query() theQuery = QSqlQuery.QSqlQueryModel.query() theQuery = QtSql.QSqlQuery.query() print "query: ", theQuery.lastQuery() But I haven't quite cracked it. Thanks in advance! Scott ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Collapse/expand frame
Well - have you tried to do that with 1500 controls? A. On Fri, Aug 14, 2009 at 9:24 AM, Håvard Gulldahl wrote: > On Thu, Aug 13, 2009 at 7:51 PM, Scott Ballard wrote: >> I'm really looking for a frame that has the collapse/expand ability built >> into it. See the image in the link. You can see the Texture Map submenu >> collapsed/expanded. Any thoughts? >> >> www.scottballard.net/collapsibleFrame.jpg >> > > I've done something similar, sans the arrow. I have a checkable > QGroupBox, whose sole child is a QFrame with no borders. All the > widgets I put into the QFrame. Then I connect the toggled(bool) signal > of the group box to the frame's setShown(bool) slot. That way, the > QFrame is hidden when the QGroupBox is un-checked. And you can do it > all from the Qt Designer: less hand-written code, yay! > > Originally I meant to figure out how to customize the QGroupBox so > that it has an arrow (like in the example you're referencing) and not > a cross, but it's not high on the list. The check box works fine, IMO. > > Cheers, > > Håvard > > >> Many thanks! >> -Scott >> >> >> Hans-Peter Jansen wrote: >>> >>> Am Mittwoch, 12. August 2009 schrieb Scott Ballard: >>> >>>> >>>> Does anyone know of a way to collapse/expand a frame or a group box that >>>> contains widgets in it? I don't see anything in the docs or Google about >>>> it, but it would seem like something common. >>>> >>> >>> Try .hide()/.show() resp. .setVisible(bool) >>> >>> Pete >>> ___ >>> PyQt mailing list p...@riverbankcomputing.com >>> http://www.riverbankcomputing.com/mailman/listinfo/pyqt >>> >>> __ Information from ESET NOD32 Antivirus, version of virus >>> signature database 4330 (20090812) __ >>> >>> The message was checked by ESET NOD32 Antivirus. >>> >>> http://www.eset.com >>> >>> >>> >>> >>> >> >> >> __ Information from ESET NOD32 Antivirus, version of virus signature >> database 4332 (20090813) __ >> >> The message was checked by ESET NOD32 Antivirus. >> >> http://www.eset.com >> >> >> ___ >> PyQt mailing list p...@riverbankcomputing.com >> http://www.riverbankcomputing.com/mailman/listinfo/pyqt >> > > > > -- > Håvard Gulldahl > Telefon: 9971 0615 > http://lurtgjort.no/ > > ___ > PyQt mailing list p...@riverbankcomputing.com > http://www.riverbankcomputing.com/mailman/listinfo/pyqt > ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Collapse/expand frame
On Thu, Aug 13, 2009 at 7:51 PM, Scott Ballard wrote: > I'm really looking for a frame that has the collapse/expand ability built > into it. See the image in the link. You can see the Texture Map submenu > collapsed/expanded. Any thoughts? > > www.scottballard.net/collapsibleFrame.jpg > I've done something similar, sans the arrow. I have a checkable QGroupBox, whose sole child is a QFrame with no borders. All the widgets I put into the QFrame. Then I connect the toggled(bool) signal of the group box to the frame's setShown(bool) slot. That way, the QFrame is hidden when the QGroupBox is un-checked. And you can do it all from the Qt Designer: less hand-written code, yay! Originally I meant to figure out how to customize the QGroupBox so that it has an arrow (like in the example you're referencing) and not a cross, but it's not high on the list. The check box works fine, IMO. Cheers, Håvard > Many thanks! > -Scott > > > Hans-Peter Jansen wrote: >> >> Am Mittwoch, 12. August 2009 schrieb Scott Ballard: >> >>> >>> Does anyone know of a way to collapse/expand a frame or a group box that >>> contains widgets in it? I don't see anything in the docs or Google about >>> it, but it would seem like something common. >>> >> >> Try .hide()/.show() resp. .setVisible(bool) >> >> Pete >> ___ >> PyQt mailing list p...@riverbankcomputing.com >> http://www.riverbankcomputing.com/mailman/listinfo/pyqt >> >> __ Information from ESET NOD32 Antivirus, version of virus >> signature database 4330 (20090812) __ >> >> The message was checked by ESET NOD32 Antivirus. >> >> http://www.eset.com >> >> >> >> >> > > > __ Information from ESET NOD32 Antivirus, version of virus signature > database 4332 (20090813) __ > > The message was checked by ESET NOD32 Antivirus. > > http://www.eset.com > > > ___ > PyQt mailing list p...@riverbankcomputing.com > http://www.riverbankcomputing.com/mailman/listinfo/pyqt > -- Håvard Gulldahl Telefon: 9971 0615 http://lurtgjort.no/ ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] inheriting from QObject and dbus.service.Object
On Thu, 13 Aug 2009 17:12:52 +0200, Marcos Dione wrote: > On Wed, Aug 12, 2009 at 09:23:07AM +0100, Phil Thompson wrote: >> PyQt defines its own metaclass (as "print type(QObject)" demonstrates). > > here's the output: > > In [47]: print type(QObject) > > > In [53]: QtCore.pyqtWrapperType > AttributeError: 'module' object has no attribute 'pyqtWrapperType' > > no cigar. is there any way to publish it? that way I will be able to do > something like this: > > In [52]: class meatbongs (QtCore.pyqtWrapperType, > dbus.service.InterfaceType): pass > > and then use it as the metaclass of the inheriting class. It is already available as type(QObject). However it is also available as QtCore.pyqtWrapperType in the current snapshot. >> It's a fundamental problem with Python's implementation that you get >> meta-class conflicts that prevent you using multiple inheritance when you >> might want to. It would be nice to be able to (somehow) specify multiple >> meta-class calls in a similar way that a derived class's __init__ >> explicitly calls the __init__ of each of its super-classes. > > meanwhile the above method works (or so I've read): create a class > inheriting from the 2 metaclasses and use it as the metaclass of the > inheriting > class. Hmm, interesting... Phil ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] inheriting from QObject and dbus.service.Object
On Wed, Aug 12, 2009 at 09:23:07AM +0100, Phil Thompson wrote: > PyQt defines its own metaclass (as "print type(QObject)" demonstrates). here's the output: In [47]: print type(QObject) In [53]: QtCore.pyqtWrapperType AttributeError: 'module' object has no attribute 'pyqtWrapperType' no cigar. is there any way to publish it? that way I will be able to do something like this: In [52]: class meatbongs (QtCore.pyqtWrapperType, dbus.service.InterfaceType): pass and then use it as the metaclass of the inheriting class. > It's a fundamental problem with Python's implementation that you get > meta-class conflicts that prevent you using multiple inheritance when you > might want to. It would be nice to be able to (somehow) specify multiple > meta-class calls in a similar way that a derived class's __init__ > explicitly calls the __init__ of each of its super-classes. meanwhile the above method works (or so I've read): create a class inheriting from the 2 metaclasses and use it as the metaclass of the inheriting class. -- (Not so) Random fortune: Tender is my heart / for screwing up my life Lord I need to find / someone who can heal my mind -- Blur, "Tender" ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Collapse/expand frame
Am Donnerstag, 13. August 2009 schrieb Scott Ballard: > I'm really looking for a frame that has the collapse/expand ability > built into it. See the image in the link. You can see the Texture Map > submenu collapsed/expanded. Any thoughts? > > www.scottballard.net/collapsibleFrame.jpg I see - why don't you BYO. This kind of widget is uncommon, and thus the reason not being available already. But it's pretty easy to combine basic widgets to a composite one. And due to Qts powerful layout machinery, you mostly don't need to care about the implicit widget resize. Custom composite widgets have some pitfalls in the details, but just start over, we will help you getting through. Pete ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Collapse/expand frame
I'm really looking for a frame that has the collapse/expand ability built into it. See the image in the link. You can see the Texture Map submenu collapsed/expanded. Any thoughts? www.scottballard.net/collapsibleFrame.jpg Many thanks! -Scott Hans-Peter Jansen wrote: Am Mittwoch, 12. August 2009 schrieb Scott Ballard: Does anyone know of a way to collapse/expand a frame or a group box that contains widgets in it? I don't see anything in the docs or Google about it, but it would seem like something common. Try .hide()/.show() resp. .setVisible(bool) Pete ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt __ Information from ESET NOD32 Antivirus, version of virus signature database 4330 (20090812) __ The message was checked by ESET NOD32 Antivirus. http://www.eset.com __ Information from ESET NOD32 Antivirus, version of virus signature database 4332 (20090813) __ The message was checked by ESET NOD32 Antivirus. http://www.eset.com ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Re: problem with createEditor method of QItemDelegate
Victor Noagbodji wrote: > Hello Julien, > > to fix it you have to set the contents margins on the layout object. > so your code should look like this: > > > qh = QtGui.QHBoxLayout( self ) > qh.setContentsMargins(0, 0, 0, 0) > self.qlabel = QtGui.QLabel() > self.qlabel.setText( "foobar" ) > qh.addWidget( self.qlabel ) > Thanks a lot. There is another problem: the fact that the layout is transparent. To work around this, I have added the following line: self.setAutoFillBackground( True ) Now, it works perfectly! Thanks Julien -- python -c "print ''.join([chr(154 - ord(c)) for c in '*9(9&(18%.\ 9&1+,\'Z4(55l4('])" "When a distinguished but elderly scientist states that something is possible, he is almost certainly right. When he states that something is impossible, he is very probably wrong." (first law of AC Clarke) ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Re: problem with createEditor method of QItemDelegate
Hello Julien, to fix it you have to set the contents margins on the layout object. so your code should look like this: qh = QtGui.QHBoxLayout( self ) qh.setContentsMargins(0, 0, 0, 0) self.qlabel = QtGui.QLabel() self.qlabel.setText( "foobar" ) qh.addWidget( self.qlabel ) cheers, -- paul victor noagbodji ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Calling slots in a QThread?
Am Donnerstag 13 August 2009 08:58:32 schrieb Arnold Krille: > [...] > Are these long-running functions implemented in python? Otherwise they will > release the GIL and your gui becomes snappy again. Yes, they are in Python. I think it works now, attached a simple script for demonstration. Comments are welcome ;) #!/usr/bin/env python # -*- coding: utf-8 -*- # Copyright (c) 2009 Lukas Hetzenecker import random from PyQt4.QtCore import * from PyQt4.QtGui import * class ThreadBase(QThread): def __init__(self, parent=None): QThread.__init__(self) self.parent = parent self._mutex = QMutex() self._action = None self._argument = None def action(self, action, argument=None): self._mutex.lock() self._action = action self._argument = argument self._mutex.unlock() class Thread(ThreadBase): def __init__(self, parent=None): ThreadBase.__init__(self) def run(self): print "Started Thread..." while True: self._mutex.lock() action = self._action argument = self._argument if action: if action == "hello": print "Hello World!" elif action == "random": print "Hello " + argument elif action == "quit": print "Bye bye!" self._action = None self._argument = None self._mutex.unlock() self.quit() break self._action = None self._argument = None self._mutex.unlock() qApp.processEvents() self.usleep(300) class Widget(QWidget): def __init__(self): QWidget.__init__(self) startBtn = QPushButton("Start") helloBtn = QPushButton("Say hello!") textBtn = QPushButton("Say random text!") endBtn = QPushButton("Quit Thread") self.thread = Thread() layout = QVBoxLayout(self) layout.addWidget(startBtn) layout.addWidget(helloBtn) layout.addWidget(textBtn) layout.addWidget(endBtn) self.setLayout(layout) self.connect(startBtn, SIGNAL("clicked()"), self.startThread) self.connect(helloBtn, SIGNAL("clicked()"), self.sayHello) self.connect(textBtn, SIGNAL("clicked()"), self.randomText) self.connect(endBtn, SIGNAL("clicked()"), self.quitThread) def startThread(self): self.thread.start() def sayHello(self): self.thread.action("hello") def randomText(self): text = str().join( [ chr(random.randint(ord("A"), ord("z"))) for i in range(10) ] ) self.thread.action("random", text) def quitThread(self): self.thread.action("quit") app = QApplication([]) w = Widget() w.show() app.exec_() ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
RE: [PyQt] Documentation
This problem seems to be unresolved. Suppose that one downloads the documentation separately, where should it be installed? In other words, where does the Demo documentation expect to find it? Colin W. Peter Stewart-2 wrote: > > Yes, I appreciate that I have access to the online documentation. However > I > cannot run the tutorial or the examples script: qtdemo.pyw. In fact when I > try to run it, I'm presented with a warning message "If you are using the > GPL version on PyQt from the binary installer, then you will probably see > warning messages about missing documentation." I'd sure like to see that > tutorial. > Thanks for the response Arve. > Peter > > > Sorry, the link should be doc.trolltech.com. > > Arve > > On 7/14/09, Arve Knudsen wrote: >> An alternative at least is to browse the online documentation at >> docs.trolltech.com. >> >> Arve >> >> On 7/14/09, Peter Stewart wrote: >>> I've just downloaded Pyqt4 using the binary package for windows option. >>> The >>> documentation wasn't included as it was too big. Now the Assistant >>> won't >>> load anything that's not a .qch file and I can't find the documentation >>> to >>> download in this form..thanks Peter >>> > > ___ > PyQt mailing listPyQt@riverbankcomputing.com > http://www.riverbankcomputing.com/mailman/listinfo/pyqt > > -- View this message in context: http://www.nabble.com/Documentation-tp24473474p24954426.html Sent from the PyQt mailing list archive at Nabble.com. ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Mac OS-X 10.5 "two icons bouncing in the dock" problem
[Sorry for cross-posting] Hi, attached script demonstrates an ugly issue, I'm fighting with since a couple of days. Issue: when starting the app via double click, single click on dock icon, dropping a plain/text file on dock or application icon, all actions lead to two icons bouncing. The one with the blue spot is the good one, that stops bouncing after start-up. The bad one will stop bouncing eventually, and shows "Application not responding" in its context menu then. As long as the bad one exists, dropping files on the good one will be ignored. After killing (and sometimes removing from the dock is necessary) all is well - one can drop files one the good one, and it behaves well, up to the point of being terminated, then the game starts again. It's not depending on the arch, but on OS-X 10.5. It does not happen with 10.4. It is may be related to pyinstaller, but since I need to deploy the app on arbitrary 10.4 and later systems, omitting it is not an option. Pre conditions: OS-X 10.5(.7/.8) with ppc or x86 arch Xcode 3.1.3 Python-2.6.2 Qt-4.5.2 sip-4.8.2 PyQt-4.5.4 Build it this way: tar xvzf launchprob.tar.gz && cd launchprob && ./build.sh -release This command will fetch pyinstaller's SVN trunk, build pyinstaller, generate the app itself: LaunchProb.app. It can be moved to any system, as long as all required packages are cleanly built for both archs and the minimum OS-X release is 10.4. Any ideas to solve the problem are highly appreciated. Thanks, Pete launchprob.tar.gz Description: application/tgz ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Calling slots in a QThread?
Hi, On Thursday 13 August 2009 00:15:13 Lukas Hetzenecker wrote: > But If I call long-running funtions in a run() method everything works as > expected. Are these long-running functions implemented in python? Otherwise they will release the GIL and your gui becomes snappy again. > > 2) Use processes instead of threads. Then you can run several instances > > of the python interpreter at the same time. > This seems too complicated for this simple task. A "simple" task that really needs threads? Looking at my students learning python/programming, I would say using threads is already pretty complicated and not needed for a simple task. (Of course if you get to know them, it becomes easier. But then you also know about starting processes and communicate via shared-memory/named-pipes/etc.) Have fun, Arnold signature.asc Description: This is a digitally signed message part. ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt