[PyQt] Composite widgets?
Hans-Peter Jansen
hpj at urpla.net
Mon Sep 6 21:15:24 BST 2010
On Monday 06 September 2010, 03:13:29 Peter Milliken wrote:
> Prior to embarking on learning PyQt, I wrote my GUI applications using
> Tkinter and Pmw. The Pmw widget set is quite nice and provides a library
> of composite classes using the Tkinter widgets.
>
> My question is:
>
> Is there any (similar) composite widgets in PyQt? i.e. Pmw has the
> EntryField widget, which combines the (commonly used case) of a Label and
> a LineEdit into the one class - much more convenient than always having
> to specify the two entities separately, which seems to be the case with
> PyQt? The EntryField widget offers far more than just conveniently
> creating a Label and a LineEdit in the one class, it also allows
> definition of entry validation as well, so you can see that the composite
> classes provide quite a high level of functional behaviour to the user.
Well, the powers of Pmw are undoubted, as long as you keep on the well
prepared route. The reason, why Qt and therefore PyQt doesn't follow this
route is flexibility. E.g. a label/editfield composite: usually you want
the labels and editfields align to some grid, where they all align
vertically, otherwise the UI looks pretty crowded. Given, I need more
editors, e.g. a date and a combo for a single item, I tend to combine them
ad hoc by a hbox layout from within designer instead of creating some
composite widgets.
> Pmw defines other composite widgets like: RadioSelect - which groups
> radio buttons (well, you have the choice of defining it to handle radio
> buttons, check buttons or "normal" buttons). Of course in PyQt I have
> found the QGroupBox class, but this only performs a (small) part of what
> the Pmw RadioSelect widget does.
All these exist as single items, just add them to your UI interactively in
designer, but there's no such thing in Pmw. In a very old project, where I
used Pmw until lately for historical reasons, I suffered from crashes in
newer versions of tix, that where related to unicode issues of edit
widgets. Such problems can drive you crazy, since looking into tix might
damage one's brain.
Try to create a table like window and different editors for all columns and
say 100000 rows with Pmw. Let it update hundreds of cells every second.
Will it still be usable?
I replaced that Pmw database frontend with a PyQt based one, where I halved
the number of lines, but _added_ a bulk of functionality, that simply
wouldn't been able with Pmw. Needless to say, it starts ten times quicker,
it has a quick full text search facility in _huge_ tables at nearly zero
cost, a table query tool, that creates persistent queries by dynamically
creating the widgets (field, operation, argument, join) in a dummy prove
way (this is an application where custom widgets make sense), print the
tables nicely, the app looks good and the usability improved greatly.
> Do such composite widgets exist? am I missing something in the PyQt
> documentation?
Start browsing the Qt documentation. Yes, it's a bit arkward to ignore the
C++ decoration, but after getting used to, you start to enjoy to be able to
ignore all the C++ related complexities and regret all those poor C++
hackers: hack, compile, link, crash, hack, compile, link, just for entering
the event loop two or three hundred microseconds earlier then us (on an
average system) when they finally fixed their self created headaches.
Pete
More information about the PyQt
mailing list