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()
Refering articles:
- Merge gendoc and forms? (26.05.06) — Just an idea: I could extend lino.forms so that it can replace lino.gendoc... more
- Still working on tests (15.03.06) — I moved forms1.py to docs/examples because I wanted it to be covered by test 32. How to run a GUI application in a testcase? more
- accelerator keys (code changes 14.03.06) — The forms1.py example now reacts to pressing ESC. New parameter "hotkey" for Button.__init__(). New module lino.forms.keyboard. New method Form.addAccelerator(). more
- Working on tests (14.03.06) — Uff, project subclassable Forms can be considered done. Now it's time to get the tests running again. more
- Keeper's search dialog works (15.07.05) — Keeper's search form works! When user enters a word and presses Enter, the datagrid shows the files containing the word. If searchString is empty, datagrid is disabled and becomes empty. (Instead of showing all files as before...) more
- 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
- started lino.forms (code changes 13.01.05) — lino.forms is going to be similar to lino.reports, but for «forms» instead of reports. A Form is what other libraries call Window, Frame or Dialog. For lino.forms they are all just Forms. more