Lino Website

Merge gendoc and forms?

Friday, 26. May 2006 17:02.

Just an idea: I could extend lino.forms so that it can replace lino.gendoc...

Rename the methods that are used during Form.setupForm() to add components to the form:

before after
addLabel() label()
addButton() button()
addOkButton() okbutton()
addEntry() entry()
addDataEntry() dataentry()
addDataGrid() report()
addHPanel() hpanel()
addVPanel() vpanel()

To avoid name collisions, move those methods to a Document instance. The document of a Form provides these methods and holds the components (elements) that they create during Form.setupForm(). It is responsible for the Form's layout. It is the same as a Gendoc document. It provides also the Gendoc methods who are more used for printed forms (par(), pre(), memo(), ul(), ol(), report()...) report() is in fact the same as the old addDataGrid()

Rename Form.setupForm() to Form.layout() because I prefer to use simple names for often used things.

A fragment from forms1.py before and after the planned change:

    def setupForm(self):
        self.addLabel("""Please enter your personal data.
Don't worry about your privacy.
You can trust us.
    """)
        self.firstName = self.addEntry(label="First name")
        self.name = self.addEntry(label="Name")
        self.addOkButton()
        self.addCancelButton()

after:

    def layout(self,doc):
        doc.label("""Please enter your personal data.
Don't worry about your privacy.
You can trust us.
    """)
        self.firstName = doc.entry(label="First name")
        self.name = doc.entry(label="Name")
        doc.okButton()
        doc.cancelButton()

I can then create a new HTML toolkit.

Refering articles:

Copyright 2001-2007 Luc Saffre.
http://lino.saffre-rumma.ee
Generated 2007-06-07 16:22:44