1--[[
2  Sample script using the dialog module
3--]]
4
5-- Create the new dialog box
6local dlg=dialog.new("Login", { "_Yes", "_No", "Cance_l" } )
7
8
9dlg:label("\nThis is just a demo - it really doesn't do anything...\n")
10
11-- Show some basic login stuff
12dlg:heading("Credentials:")
13dlg:text("name", "anonymous","Username:")
14dlg:password("pass", nil,  "Password:")
15dlg:checkbox("kept", false,"Remember me")
16
17
18
19-- Create a radio group "auth" with default value "none"
20dlg:group("auth", "none", "Authentication:")
21
22-- Add some buttons to "auth" group...
23dlg:radio("auth", "basic", "BASIC")
24dlg:radio("auth", "ssl",   "SSL")
25dlg:radio("auth", "none",  "NONE")
26
27
28
29-- Create a drop-down list "proto" with default "http"
30dlg:select("proto", "http",  "Protocol:")
31
32-- Add some items to "proto" list...
33dlg:option("proto", "dict",  "DICT")
34dlg:option("proto", "file",  "FILE")
35dlg:option("proto", "ftp",   "FTP")
36dlg:option("proto", "http",  "HTTP")
37dlg:option("proto", "scp",   "SSH")
38dlg:option("proto", "tftp",  "TFTP")
39
40
41-- Show off the other widgets
42dlg:textarea("remarks", nil, "Comments: ")
43dlg:color("color", nil, "Favorite color:");
44dlg:font("font", nil, "Preferred font:");
45dlg:file("filename", nil, "Upload file:")
46
47
48-- Show the dialog
49local button, results = dlg:run()
50
51
52-- Display the results
53if ( button == 1 ) and results then
54  local msg=""
55   -- Combine the results table back into a single string
56  for key,value in pairs(results)
57  do
58    msg=msg.."\n"..key..":\t"..value
59  end
60  -- Show the results
61  local msgbox=dialog.new("Results", {"OK"})
62  msgbox:label("     ---  Results table  ---     ")
63  msgbox:label(msg.."\n")
64  msgbox:run()
65else
66   local errbox=dialog.new("Cancelled", {"OK"})
67   errbox:label("     Cancelled with button #"..button.."     ")
68   errbox:run()
69end
70