GUIs - A Modest Proposal

lkcl luke.leighton at gmail.com
Sun Jun 13 07:29:31 EDT 2010


On Jun 13, 9:01 am, Jeremy Sanders <jeremy
+complangpyt... at jeremysanders.net> wrote:
> lkcl wrote:
> >  * in neither gtk nor qt does there exist an "auto-layout" widget
> > that's equivalent to putting some <span /> DOM objects into a <div />,
> > to "flow" widgets that wrap around.  yes, you can put words into a
> > Label and get them to flow, but not _widgets_.
>
> I'm pretty sure in PyQt4 that you can derive your own layout class from
> QLayout to get what you want. No C++ is required. You can easily extend PyQt
> without using C++.

 really?  drat.  i could have done with knowing that at the time.
hmmm, perhaps i will return to the pyqt4 port after all.

> There is even an example in the PyQt examples which does something similar
> to what you want: see examples/layouts/flowlayout.py

 excellent!  that actually makes it worthwhile carrying on.  the only
other thing that needs solving is that RichText is forced to have its
width and height set.  but it mayyy be possible to create an
appropriate QLayout derivative: i'll have to see.


> Personally I find the Qt layout to be much better than anything provided by
> CSS and HTML. Personally I'd rather be writing complex C++ templates that
> those, though it does give you a feeling of achievement when you get what
> you want with CSS.

 i didn't point this out at the time (and have done so to graham's
post, but it's worth reiterating briefly here): remember that you're
not _entirely_ stuck with "CSS the file-format" - you _can_ do
declarative DOM manipulation (from python):

 self.element.style.backgroundColor = "#ffcc00"

 that's python _not_ javascript :)

 so, now you can create **kwargs jobbies, you can store properties in
xml fileformats, read them and then "apply" them using **kwargs to the
stylesheets; you can create functions which set multiple CSS
properties at once, based on some calculations and so on.

 so, yah - when you're "stuck" with "just CSS the fileformat", it's a
complete dog.  joy.  lovely.  you can set the width and the
background.  wow, big deal.  but when you start combining it with
python, you've opened up a completely new dimension.

 it's in fact how the entire pyjamas UI widget set is created, by
doing nothing more than direct manipulation of bits of DOM and direct
manipulation of the style properties.  really really simple.

 l.



More information about the Python-list mailing list