-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathtest_app.py
66 lines (51 loc) · 1.75 KB
/
test_app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# -*- coding: utf-8 -*-
from formcreator import *
man_desc = markdown(u"""
Example using _man_
===========
And showing that you can use markdown on a form description.
""")
man = Form("man", name="man", desc=man_desc, dirs=["updir"])
man += Boolean( u'Apropos mode'
, cmd_opt="-k")
man += Boolean( u'Whatis mode'
, cmd_opt="-f")
man += Text( u'Page'
, u'What manual page do you want?')
wc = Form("wc")
wc += File("File to count", upload_directory="wc-files")
wc += SelectFile("Or select a uploaded file", files_directory="wc-files")
wc += Boolean("Lines", cmd_opt="-l")
wc += Boolean("Characters", cmd_opt="-c")
wc += Boolean("Words", cmd_opt="-w")
def calc(num, exp=1, to_exp=False):
if to_exp:
return 2*(num**exp)
else:
return 2*num
dup = Form(calc, name="function", output_type="html")
dup += Integer( u'Number')
dup += Integer( u'Exponent'
, cmd_opt='exp')
dup += Doc("""
Calculate the function:
f(n,e) = 2*(n**e)
But just use the exponent if asked.
""")
dup += Boolean( u'Use exponent?'
, cmd_opt='to_exp')
cowsay = Form("cowsay")
cowsay += Doc("""
What the cow needs to say?
===========
![Typical cowsay output](http://upload.wikimedia.org/wikipedia/commons/8/80/Cowsay_Typical_Output.png)
And you can see here that you can use markdown text to create text content in your forms.
""")
cowsay += TextArea("Texto")
convert = Form("convert", dirs=["images"], inline=True)
convert += Integer("Degrees", cmd_opt="-rotate")
convert += File("Image", upload_directory="images")
convert += SelectFile("Or select an image below", files_directory="images")
convert += Text("New image name")
test_app = MainApp('Testing', [man, dup, cowsay, convert], not_public=True)
test_app.run()