from lino.forms import Form
class PrivacyForm(Form):
"""\
(imagine our privacy statement here)
Note that this form is not modal,
so you don't need to close it if you want to continue registering.
"""
title = "Privacy statement"
def layout(self,panel):
panel.okButton()
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.formButton(PrivacyForm())
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()
Refering articles:
- Setting buttons on a Panel as default button (code changes 21.01.05) — lino.forms currently responds to the form's default button only if the buttons are on the main panel (not on a horizontal buttonPanel). I didn't yet figure out how to achieve this in wxPython. more
- first lino.forms examples did work (code changes 15.01.05) — I have split the forms example into 3 parts (forms1.py, forms2.py and forms3.py) And the 2 first *did* work. But then I made some change and now the sizers are again messed up. It's true that wxPython can be frustrating! more