From: Stephen Hansen on
On 6/12/10 8:22 PM, Gregory Ewing wrote:
> Terry Reedy wrote:
>
>> Would it be possible to write a program that converts a module that
>> uses ctypes to interface to a dll to a corresponding C extension
>> program that would compile to a drop in replacement extension module?
>
> Probably, but I don't see how that could be done automatically
> in a way that ensured the result would be any safer than the
> original ctypes-using version. If you preserve the semantics of
> the Python code, you also preserve any bugs it might have.

I dunno. This is exactly what Cython does. I have exactly one extension
module in Cython that uses it, and so very limited experience-- but it
seems very solid and very safe, from my admittedly limited attempts at
breaking it.

True, Cython != Python. But its close enough that Python programmers can
do it without knowing the pain of C, just following a certain limited
Python subset. Its very doable, very accessible, and *seems* to address
this very issue.

--

Stephen Hansen
... Also: Ixokai
... Mail: me+list/python (AT) ixokai (DOT) io
... Blog: http://meh.ixokai.io/

From: Jeremy Sanders on
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++.

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

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.

Jeremy

--
Jeremy Sanders
http://www.jeremysanders.net/
From: lkcl on
On Jun 13, 3:34 am, Gregory Ewing <greg.ew...(a)canterbury.ac.nz> 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.
>
> You essentially seem to be complaining here that pqyqt and
> pygtk are not HTML.

no, i'm not complaining - i'm pointing out that in my meandering
experiences to pick suitable technology, i found, very simply, that
both pyqt and pygtk didn't cut it. that's not a "complaint". so i'm
stating/implying that from the experience that i had with both
toolkits, pyqt and pygtk were not as easy to create layouts or widgets
with (but caveat: jeremy kindly points out that in pyqt there is
examples/layouts/flowlayout.py)

another way to put that: i'm stating that, in my search for suitable
technology to implement W3C-standards-like behaviour, such that i
could map an existing widget set API on top of it, i found both pygtk
and pyqt4's "bang per buck" as far as both extensibility and existing
functionality was concerned to be below an acceptable threshold *for
me*.

statement of "personal experience". not "complaint".

> They have their own auto-layout mechanisms
> that do what they're designed to do well enough -- they just
> happen to be based on a different model from HTML.

one which turns out to be sufficiently different from HTML as to make
it beyond my time and patience to implement one in terms of the
other. again - that's not a "complaint", just a statement that i
prefer to leverage technologies where the "bang per buck" or better
"bang per line-of-code" is way above average.


> I'm far from convinced that HTML and CSS are the One True Way
> to design GUIs these days,

if you have "HTML the fileformat" and "CSS the fileformat" in mind
when saying that, i can tell you right now that they're not.
fortunately, with the W3C DOM functions exposing properties and style
attributes, it's possible to manipulate the exact same attributes that
CSS and HTML "files" provide access to, using a declarative
programming style.

so with pyjamas you get the best of both worlds. (and i've found
that the combination of the advanced features of python, and
declarative DOM manipulation, is _definitely_ worthwhile exploring,
and i definitely find it to be far more powerful than pyqt4 or pygtk
programming).

it's the exact same thing for SVG image file-format. i'm
_definitely_ not convinced that "SVG the image fileformat" is The One
True Way to design images - but i'm equally definitely convinced of
the power of SVG manipulation libraries which allow for the creation
SVG images using declarative programming.

but, all that having been said, and returning to "HTML and CSS (the
fileformats)", there's a lot to be said for convincing people who are
stuck in those worlds of the benefits and freedom of declarative
programming... _without_ having to get involved directly in
javascript.

> that web apps are about to take over
> the world, etc. There is still a place for GUI toolkits that
> are not based on the DOM,

that there definitely are.

> or whatever the W3C technology of the month is.

:) don't underestimate how much time and money is going into the W3C
standards! and remember, someone's got to implement them, so the
actual proof of the pudding is not what the W3C thinks but whether the
technology ends up actually in the hands of users and is successful
_for users_.

l.

From: lkcl on
On Jun 13, 9:01 am, Jeremy Sanders <jeremy
+complangpyt...(a)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.
From: Stephen Hansen on
On 6/13/10 4:29 AM, lkcl wrote:
> 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.

Did you just call DOM manipulation simple with a straight face? I don't
think I've ever seen that before.

HTML+CSS have some very strong advantages. Simplicity is not one of
them. Precision web design these days is a dark art. (Go center an image
vertically and horizontally in an arbitrary sized field!)

--

Stephen Hansen
... Also: Ixokai
... Mail: me+list/python (AT) ixokai (DOT) io
... Blog: http://meh.ixokai.io/