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