~ubuntu-branches/debian/sid/geany-plugins/sid

« back to all changes in this revision

Viewing changes to geanylua/examples/dialogs/complex-dialog.lua

  • Committer: Bazaar Package Importer
  • Author(s): Chow Loong Jin
  • Date: 2009-07-10 22:56:41 UTC
  • Revision ID: james.westby@ubuntu.com-20090710225641-xc1126t7pq0jmpos
Tags: upstream-0.17.1
ImportĀ upstreamĀ versionĀ 0.17.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
--[[
 
2
  Sample script using the dialog module
 
3
--]]
 
4
 
 
5
-- Create the new dialog box
 
6
local dlg=dialog.new("Login", { "_Yes", "_No", "Cance_l" } )
 
7
 
 
8
 
 
9
dlg:label("\nThis is just a demo - it really doesn't do anything...\n")
 
10
 
 
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")
 
16
 
 
17
 
 
18
 
 
19
-- Create a radio group "auth" with default value "none"
 
20
dlg:group("auth", "none", "Authentication:")
 
21
 
 
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")
 
26
 
 
27
 
 
28
 
 
29
-- Create a drop-down list "proto" with default "http"
 
30
dlg:select("proto", "http",  "Protocol:")
 
31
 
 
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")
 
39
 
 
40
 
 
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:")
 
46
 
 
47
 
 
48
-- Show the dialog
 
49
local button, results = dlg:run()
 
50
 
 
51
 
 
52
-- Display the results
 
53
if ( 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()
 
65
else
 
66
   local errbox=dialog.new("Cancelled", {"OK"})
 
67
   errbox:label("     Cancelled with button #"..button.."     ")
 
68
   errbox:run()
 
69
end