Nice work! Blur Studios have published all their pipeline scripts, and there's a pretty nice collapsible groupBox there. Might be interesting to have a look at.
You can download a Windows installer from http://code.google.com/p/blur-dev/. If you just want the groupbox script, I pasted it here: http://pastebin.com/ZFUrj7sm On Fri, May 11, 2012 at 8:03 AM, Manuel Macha <[email protected]> wrote: > I'm on pyqt 4.7.3. The mistake that I was making was that I defined the > signal inside my init method. > Thanks Justin, I'll definitely stick with the new syntax from now on. > p.s: here's a working example: http://pastebin.com/zcTVbat0 > > > > > On Fri, May 11, 2012 at 12:29 PM, Justin Israel <[email protected]>wrote: > >> New style signal slots were introduced in Qt 4.5. Maybe you are using a >> really old version of Qt? >> >> >> >> On May 10, 2012, at 7:20 PM, Manuel Macha <[email protected]> wrote: >> >> Hi Justin, >> many thanks for your help. >> I've cleaned up the mousePressEvent method as suggested (the original was >> eclipse's suggested default syntax for overriding a method) >> I'd prefer using the new-style signal-slots mechanism but in this case I >> couldn't get it to work, even trying several variations of the example that >> you've given. >> As for breaking the UI-setup into a bunch of smaller methods. I think I >> saw that in some book and found it helped me with breaking stuff into >> meaningful subtasks. I'm aware that it inflates the code and it's uncommon >> to do things that way but for me it's working. >> Anyways, here's how far I got with the frameLayout. I've added the >> collapse-arrow and a label: >> http://pastebin.com/qYgDDYsB >> >> Regards, >> Manuel >> >> >> On Fri, May 11, 2012 at 1:47 AM, Justin Israel <[email protected]>wrote: >> >>> I don't think there is anything wrong with the approach you are taking. >>> This is the norm. The framework can't provide every type of functionality, >>> but they do give you a ton of building blocks to make it easy to compose >>> your own. >>> >>> There isn't much to say about your code other than me nit picking a >>> little :-) >>> But here are some small things... >>> >>> def mousePressEvent(self, *args, **kwargs): >>> self.emit(QtCore.SIGNAL('clicked()')) >>> return QtGui.QFrame.mousePressEvent(self, *args, **kwargs) >>> >>> An event method will only receive a single event argument, and you don't >>> need to return anything. Right now this would be returning None all the >>> time. You can just take the single event arg, and then call the superclass >>> method with it. >>> >>> Also, you might want to consider using the new-style signal-slots if you >>> are just learning... >>> You can define signals as class attributes like this: >>> >>> class TitleFrame(QtGui.QFrame): >>> clicked = QtCore.pyqtSignal() >>> >>> ... And then you can emit like this: >>> >>> self.clicked.emit() >>> >>> ... And connections to the slot in your other class would be like: >>> >>> self.titleFrame.clicked.connect(self.printSomething) >>> >>> Its much cleaner and easier to use. And you can create signals with >>> different signatures and slots of the same name that take different >>> signatures. >>> >>> Thats pretty much it. Like I said, the rest is just nit-picking (I find >>> it more obscure to define your UI setup in a bunch of smaller methods that >>> you call in a row, when they depend on each other, such as needing to >>> connect the signal and knowing that the UI object is there). >>> >>> >>> On May 10, 2012, at 4:50 AM, Manuel Macha wrote: >>> >>> One thing I really miss with PyQt is having a Maya-style collapsible >>> frameLayout readily available, so I hacked this together: >>> http://pastebin.com/5y8tsBE7 >>> It's pretty simple at the moment. There's neither a label nor an icon >>> indicating the collapsed state. >>> Before I spend too much time on it, could you guys pls have a look and >>> tell me if this is a valid approach? (I just started familiarizing myself >>> with qt a few weeks ago) >>> In case this is way of doing things is not a good idea I'd appreciate if >>> someone could push me into the right direction (or ideally share their >>> working frameLayout code with the rest of us), otherwise any help in making >>> this better is greatly appreciated. >>> Regards, >>> m >>> p.s. are there any websites that have custom pyqt widgets for download? >>> I didn't really find anything through google. >>> >>> -- >>> view archives: http://groups.google.com/group/python_inside_maya >>> change your subscription settings: >>> http://groups.google.com/group/python_inside_maya/subscribe >>> >>> >>> -- >>> view archives: http://groups.google.com/group/python_inside_maya >>> change your subscription settings: >>> http://groups.google.com/group/python_inside_maya/subscribe >>> >> >> -- >> view archives: http://groups.google.com/group/python_inside_maya >> change your subscription settings: >> http://groups.google.com/group/python_inside_maya/subscribe >> >> -- >> view archives: http://groups.google.com/group/python_inside_maya >> change your subscription settings: >> http://groups.google.com/group/python_inside_maya/subscribe >> > > -- > view archives: http://groups.google.com/group/python_inside_maya > change your subscription settings: > http://groups.google.com/group/python_inside_maya/subscribe > -- view archives: http://groups.google.com/group/python_inside_maya change your subscription settings: http://groups.google.com/group/python_inside_maya/subscribe
