Lino Website

Documentation · Modules · adamo · Examples

forms1.py

A most simple form with two entry fields.

from lino.forms import Form

class MyForm(Form):
    
    title = "The First Lino Form"
    
    def layout(self,panel):
    
        panel.label("""\
Please enter your personal data.
Don't worry about your privacy.
You can trust us.
    """)
        self.firstName = panel.entry(label="First name")
        self.name = panel.entry(label="Name")
        panel.okButton()
        panel.cancelButton()

    def ok(self):
        if not self.firstName.getValue():
            self.notice("First name is mandatory")
            return
        if not self.name.getValue():
            self.notice("Name is mandatory")
            return
        self.message(
            "Hello %s %s. Thank you for registering.",
            self.firstName.getValue(),
            self.name.getValue())
        self.close()
        
    def cancel(self):
        if self.confirm("This will end our relation. Are you sure?"):
            self.close()

if __name__ == '__main__':
    MyForm().main()

forms1.jpg

Refering articles:

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