up with PyGUI!

Carlos Ribeiro carribeiro at gmail.com
Thu Sep 23 07:52:44 EDT 2004


On Thu, 23 Sep 2004 14:44:52 +0400, anton muhin <antonmuhin at rambler.ru> wrote:
> I beg your pardon for possibly stupid comment---I haven't practice GUI
> programming for a long time, especially in Python. However I mostly
> prefer declarative approach for the problems like that. Therefore,
> wouldn't it be interesting to describe the structure with class and
> metaclass mechanism, like:
> 
> class MainFrame(FrameDescription):
> 
>    class b1(ButtonDescription):
>      size = (40, 40)
>      text = "b1"
> 
> etc.

Thats *exaclty* what I'm doing, after spending a long time evaluating
a lot of GUI packages, Wax included. Not that I didn't like Wax -- I
think the design is very good, and I would put it in the same class as
Greg Ewing's PyGUI, with the advantage that Wax runs in Windows. But I
miss the ability to write a declaration like you've done.

I have tested a metaclass engine yesterday that does something like
you wrote. In my particular case, I'm going to work with automatic
layout generation, so I'm not providing absolute positioning
parameters. But the mechanism is about the same. Here are two
declarations from my test script:

class UserForm(Form):
    nickname = TextBox(length=15, default="")
    password = TextBox(length=10, default="", password=True)
    name     = TextBox(length=40, default="")

class ComplexForm(Form):
    class Header(Form):
        nickname = TextBox(length=15, default="")
        password = TextBox(length=10, default="", password=True)
        name     = TextBox(length=40, default="")
    class Comment(Form):
        comments = TextBox(length=200, default="", multiline=True)

It already accepts nested classes and some special attributes. There
are a few catches involving hacks to detect the original order of the
attributes in the class declaration. That's going to make a
difference, because one would implicitly assume that the tab order of
the data entry elements is the same as the declaration order. Solved
that, I'm working today on the code generation engine that will
generate the UI from the class declaration. I'll post a note here as
soon as I have something working.

-- 
Carlos Ribeiro
Consultoria em Projetos
blog: http://rascunhosrotos.blogspot.com
blog: http://pythonnotes.blogspot.com
mail: carribeiro at gmail.com
mail: carribeiro at yahoo.com



More information about the Python-list mailing list