Call for suggestions: Declaring data entry forms using Python classes

Paul Paterson paulpaterson at users.sourceforge.net
Fri Sep 24 03:30:33 CEST 2004


Carlos Ribeiro wrote:
> 
> I'm doing good progress on my form declarative language library. The
> idea (for those who haven't read about it) is to be able to specify a
> form declaration in the following format:
> 
> 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)
> 

[snip]

By a strange coincidence, this intermediate representation is eerily 
similar to the one used in vb2py when converting Visual Basic forms to 
Python ones (implemented in PythonCard).

The process is,

1. Read VB form
2. Write intermediate representation (see below)
3. Convert intermediate to a PythonCard (wxWidgets based) form

The intermediate representation looks like,

class vbobj_frmForm(resource.Form):
    Caption         =   "Form1"
    ClientHeight    =   3090
    ClientLeft      =   60
    ClientTop       =   450
    ClientWidth     =   4680

    class vbobj_btnCheckLike(resource.CommandButton):
       Caption         =   "Like ?"
       Height          =   375
       Left            =   1440
       TabIndex        =   2
       Top             =   1560
       Width           =   1815

    class vbobj_txtTwo(resource.TextBox):
       Height          =   405
       Left            =   240
       TabIndex        =   1
       Text            =   "Text2"
       Top             =   840
       Width           =   4095

    class vbobj_txtOne(resource.TextBox):
       Height          =   375
       Left            =   240
       TabIndex        =   0
       Text            =   "Text1"
       Top             =   240
       Width           =   4095


I've found that the inner class approach works pretty well although I 
must admit that the implementation of the transformation in vb2py is 
pretty ugly!

I'm very interested in where you are headed with this - what is your 
target UI? Are you planning on releasing this under an OS license?

Regards,

Paul


================================
vb2Py - Visual Basic to Python Conversion
http://vb2py.sourceforge.net



More information about the Python-list mailing list