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