mrdialog 1.0.3 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/ChangeLog.md +21 -1
- data/Gemfile +3 -2
- data/LICENSE.txt +1 -1
- data/README.md +137 -76
- data/Rakefile +3 -3
- data/VERSION +1 -1
- data/lib/mrdialog/mrdialog.rb +89 -78
- data/mrdialog.gemspec +124 -0
- data/pkg/md5.txt +1 -1
- data/pkg/mrdialog-1.0.5.gem +0 -0
- data/samples/extra_button/buildlist.rb +89 -0
- data/samples/extra_button/calendar.rb +45 -0
- data/samples/extra_button/checklist.rb +84 -0
- data/samples/extra_button/form1.rb +101 -0
- data/samples/extra_button/fselect.rb +36 -0
- data/samples/extra_button/inputbox.rb +48 -0
- data/samples/extra_button/menubox.rb +85 -0
- data/samples/extra_button/password.rb +44 -0
- data/samples/extra_button/radiolist.rb +86 -0
- data/samples/extra_button/timebox.rb +43 -0
- data/samples/extra_button/treeview.rb +112 -0
- data/samples/run_all.rb +1 -1
- data/samples/yesno.rb +1 -1
- metadata +40 -16
- data/Gemfile.lock +0 -82
- data/pkg/mrdialog-1.0.3.gem +0 -0
@@ -0,0 +1,45 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
########################################################################
|
4
|
+
# Example for calendar widget.
|
5
|
+
# muquit@muquit.com Apr-02-2014
|
6
|
+
########################################################################
|
7
|
+
#
|
8
|
+
require [File.expand_path(File.dirname(__FILE__)), '../..', 'lib', 'mrdialog'].join('/')
|
9
|
+
require 'date'
|
10
|
+
|
11
|
+
begin
|
12
|
+
ME = File.basename($0)
|
13
|
+
if ENV['CHANGE_TITLE']
|
14
|
+
if ME =~ /(.+)\.rb$/
|
15
|
+
base = $1
|
16
|
+
puts "\033]0;mrdialog - #{base}\007"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
text = "Please choose a date..."
|
21
|
+
|
22
|
+
height = 0
|
23
|
+
width = 0
|
24
|
+
day = Date.today.mday
|
25
|
+
month =Date.today.mon
|
26
|
+
year =Date.today.year
|
27
|
+
|
28
|
+
dialog = MRDialog.new
|
29
|
+
dialog.logger = Logger.new(ENV["HOME"] + "/dialog_" + ME + ".log")
|
30
|
+
dialog.clear = true
|
31
|
+
dialog.title = "CALENDAR"
|
32
|
+
dialog.extra_button = true
|
33
|
+
dialog.ok_label = "Save"
|
34
|
+
dialog.extra_label = "Send"
|
35
|
+
dialog.cancel_label = "Quit"
|
36
|
+
|
37
|
+
date = dialog.calendar(text, height, width, day, month, year)
|
38
|
+
puts "Exit code: #{dialog.exit_code}"
|
39
|
+
puts "Result is: #{date.to_s}"
|
40
|
+
|
41
|
+
rescue => e
|
42
|
+
puts "#{$!}"
|
43
|
+
t = e.backtrace.join("\n\t")
|
44
|
+
puts "Error: #{t}"
|
45
|
+
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require [File.expand_path(File.dirname(__FILE__)), '../..', 'lib', 'mrdialog'].join('/')
|
4
|
+
require 'pp'
|
5
|
+
|
6
|
+
begin
|
7
|
+
ME = File.basename($0)
|
8
|
+
if ENV['CHANGE_TITLE']
|
9
|
+
if ME =~ /(.+)\.rb$/
|
10
|
+
base = $1
|
11
|
+
puts "\033]0;mrdialog - #{base}\007"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
text = <<EOF
|
16
|
+
This example is taken from dialog/samples/radiolist
|
17
|
+
shell script.
|
18
|
+
|
19
|
+
Hi, this is a radiolist box. You can use this to
|
20
|
+
present a list of choices which can be turned on or
|
21
|
+
off. If there are more items than can fit on the
|
22
|
+
screen, the list will be scrolled. You can use the
|
23
|
+
UP/DOWN arrow keys, the first letter of the choice as a
|
24
|
+
hot key, or the number keys 1-9 to choose an option.
|
25
|
+
Press SPACE to toggle an option on/off. Set the option
|
26
|
+
notags to true if you don't want to diaplay the tags.
|
27
|
+
|
28
|
+
Which of the following are fruits?
|
29
|
+
|
30
|
+
EOF
|
31
|
+
items = []
|
32
|
+
checklist_data = Struct.new(:tag, :item, :select)
|
33
|
+
|
34
|
+
data = checklist_data.new
|
35
|
+
data.tag = "Apple"
|
36
|
+
data.item = "It's an applie"
|
37
|
+
data.select = false
|
38
|
+
items.push(data.to_a)
|
39
|
+
|
40
|
+
data = checklist_data.new
|
41
|
+
data.tag = "Dog"
|
42
|
+
data.item = "No it's not my dog"
|
43
|
+
data.select = true
|
44
|
+
items.push(data.to_a)
|
45
|
+
|
46
|
+
data = checklist_data.new
|
47
|
+
data.tag = "Orange"
|
48
|
+
data.item = "Yeah! it is juicy"
|
49
|
+
data.select = false
|
50
|
+
items.push(data.to_a)
|
51
|
+
|
52
|
+
data = checklist_data.new
|
53
|
+
data.tag = "Chicken"
|
54
|
+
data.item = "Normally not a pet"
|
55
|
+
data.select = true
|
56
|
+
items.push(data.to_a)
|
57
|
+
|
58
|
+
dialog = MRDialog.new
|
59
|
+
# dialog.notags = false
|
60
|
+
# dialog.dialog_options = "--no-tags"
|
61
|
+
dialog.clear = true
|
62
|
+
dialog.title = "CHECKLIST"
|
63
|
+
dialog.logger = Logger.new(ENV["HOME"] + "/dialog_" + ME + ".log")
|
64
|
+
dialog.extra_button = true
|
65
|
+
dialog.ok_label = "Send"
|
66
|
+
dialog.extra_label = "Save"
|
67
|
+
dialog.cancel_label = "Quit"
|
68
|
+
|
69
|
+
selected_items = dialog.checklist(text, items)
|
70
|
+
exit_code = dialog.exit_code
|
71
|
+
puts selected_items.class
|
72
|
+
puts "Exit code: #{exit_code}"
|
73
|
+
if selected_items
|
74
|
+
puts "Selected Items:"
|
75
|
+
selected_items.each do |item|
|
76
|
+
puts " '#{item}'"
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
rescue => e
|
81
|
+
puts "#{$!}"
|
82
|
+
t = e.backtrace.join("\n\t")
|
83
|
+
puts "Error: #{t}"
|
84
|
+
end
|
@@ -0,0 +1,101 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# muquit@muquit.com Apr-01-2014
|
4
|
+
require [File.expand_path(File.dirname(__FILE__)), '../..', 'lib', 'mrdialog'].join('/')
|
5
|
+
require 'pp'
|
6
|
+
|
7
|
+
begin
|
8
|
+
ME = File.basename($0)
|
9
|
+
if ENV['CHANGE_TITLE']
|
10
|
+
if ME =~ /(.+)\.rb$/
|
11
|
+
base = $1
|
12
|
+
puts "\033]0;mrdialog - #{base}\007"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
user = ''
|
17
|
+
uid = ''
|
18
|
+
gid = ''
|
19
|
+
home = ENV["HOME"]
|
20
|
+
|
21
|
+
id = `id`.chomp
|
22
|
+
if id =~ /^uid=(\d+)\((.+)\)\sgid=(\d+)\(.*$/
|
23
|
+
uid = $1
|
24
|
+
user = $2
|
25
|
+
gid = $3
|
26
|
+
end
|
27
|
+
|
28
|
+
dialog = MRDialog.new
|
29
|
+
dialog.clear = true
|
30
|
+
dialog.logger = Logger.new(ENV["HOME"] + "/dialog_" + ME + ".log")
|
31
|
+
|
32
|
+
text = <<EOF
|
33
|
+
Here is a possible piece of a configuration program.
|
34
|
+
EOF
|
35
|
+
items = []
|
36
|
+
form_data = Struct.new(:label, :ly, :lx, :item, :iy, :ix, :flen, :ilen)
|
37
|
+
|
38
|
+
data = form_data.new
|
39
|
+
data.label = "Username:"
|
40
|
+
data.ly = 1
|
41
|
+
data.lx = 1
|
42
|
+
data.item = user
|
43
|
+
data.iy = 1
|
44
|
+
data.ix = 10
|
45
|
+
data.flen = user.length + 10
|
46
|
+
data.ilen = 0
|
47
|
+
items.push(data.to_a)
|
48
|
+
|
49
|
+
data = form_data.new
|
50
|
+
data.label = "UID:"
|
51
|
+
data.ly = 2
|
52
|
+
data.lx = 1
|
53
|
+
data.item = uid.to_s
|
54
|
+
data.iy = 2
|
55
|
+
data.ix = 10
|
56
|
+
data.flen = uid.length + 10
|
57
|
+
data.ilen = 0
|
58
|
+
items.push(data.to_a)
|
59
|
+
|
60
|
+
data = form_data.new
|
61
|
+
data.label = "GID:"
|
62
|
+
data.ly = 3
|
63
|
+
data.lx = 1
|
64
|
+
data.item = gid.to_s
|
65
|
+
data.iy =3
|
66
|
+
data.ix = 10
|
67
|
+
data.flen = gid.length + 2
|
68
|
+
data.ilen = 0
|
69
|
+
items.push(data.to_a)
|
70
|
+
|
71
|
+
data = form_data.new
|
72
|
+
data.label = "HOME:"
|
73
|
+
data.ly = 4
|
74
|
+
data.lx = 1
|
75
|
+
data.item = home
|
76
|
+
data.iy = 4
|
77
|
+
data.ix = 10
|
78
|
+
data.flen = home.length + 40
|
79
|
+
data.ilen = 0
|
80
|
+
items.push(data.to_a)
|
81
|
+
|
82
|
+
dialog.title = "FORM"
|
83
|
+
dialog.extra_button = true
|
84
|
+
dialog.ok_label = "Save"
|
85
|
+
dialog.extra_label = "Submit"
|
86
|
+
dialog.cancel_label = "Quit"
|
87
|
+
|
88
|
+
result_hash = dialog.form(text, items, 20, 50, 0)
|
89
|
+
if result_hash
|
90
|
+
puts "Resulting data:"
|
91
|
+
result_hash.each do |key, val|
|
92
|
+
puts " #{key} = #{val}"
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
|
97
|
+
rescue => e
|
98
|
+
puts "#{$!}"
|
99
|
+
t = e.backtrace.join("\n\t")
|
100
|
+
puts "Error: #{t}"
|
101
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# muquit@muquit.com Apr-01-2014
|
4
|
+
require [File.expand_path(File.dirname(__FILE__)), '../..', 'lib', 'mrdialog'].join('/')
|
5
|
+
require 'pp'
|
6
|
+
|
7
|
+
begin
|
8
|
+
ME = File.basename($0)
|
9
|
+
if ENV['CHANGE_TITLE']
|
10
|
+
if ME =~ /(.+)\.rb$/
|
11
|
+
base = $1
|
12
|
+
puts "\033]0;mrdialog - #{base}\007"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
dialog = MRDialog.new
|
17
|
+
dialog.clear = true
|
18
|
+
dialog.title = "Please choose a file"
|
19
|
+
dialog.extra_button = true
|
20
|
+
dialog.ok_label = "Copy"
|
21
|
+
dialog.extra_label = "Delete"
|
22
|
+
dialog.cancel_label = "Quit"
|
23
|
+
|
24
|
+
h = 14
|
25
|
+
w = 48
|
26
|
+
file_path = ENV["HOME"] + "/"
|
27
|
+
file = dialog.fselect(file_path, h, w)
|
28
|
+
|
29
|
+
puts "Exit code: #{dialog.exit_code}"
|
30
|
+
puts "Result is: #{file}"
|
31
|
+
|
32
|
+
rescue => e
|
33
|
+
puts "#{$!}"
|
34
|
+
t = e.backtrace.join("\n\t")
|
35
|
+
puts "Error: #{t}"
|
36
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# muquit@muquit.com Apr-01-2014
|
4
|
+
require [File.expand_path(File.dirname(__FILE__)), '../..', 'lib', 'mrdialog'].join('/')
|
5
|
+
require 'pp'
|
6
|
+
|
7
|
+
begin
|
8
|
+
ME = File.basename($0)
|
9
|
+
if ENV['CHANGE_TITLE']
|
10
|
+
if ME =~ /(.+)\.rb$/
|
11
|
+
base = $1
|
12
|
+
puts "\033]0;mrdialog - #{base}\007"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
text = <<EOF
|
17
|
+
Hi, this is an input dialog box. You can use
|
18
|
+
this to ask questions that require the user
|
19
|
+
to input a string as the answer. You can
|
20
|
+
input strings of length longer than the
|
21
|
+
width of the input box, in that case, the
|
22
|
+
input field will be automatically scrolled.
|
23
|
+
You can use BACKSPACE to correct errors.
|
24
|
+
Try entering your name below:
|
25
|
+
|
26
|
+
EOF
|
27
|
+
dialog = MRDialog.new
|
28
|
+
dialog.logger = Logger.new(ENV["HOME"] + "/dialog_" + ME + ".log")
|
29
|
+
dialog.clear = true
|
30
|
+
dialog.title = "INPUT BOX"
|
31
|
+
dialog.extra_button = true
|
32
|
+
dialog.ok_label = "Send"
|
33
|
+
dialog.extra_label = "Save"
|
34
|
+
dialog.cancel_label = "Quit"
|
35
|
+
|
36
|
+
height = 16
|
37
|
+
width = 51
|
38
|
+
init = "blah"
|
39
|
+
result = dialog.inputbox(text, height, width, init)
|
40
|
+
|
41
|
+
puts "Exit Code: #{dialog.exit_code}"
|
42
|
+
puts "Result is: #{result}"
|
43
|
+
|
44
|
+
rescue => e
|
45
|
+
puts "#{$!}"
|
46
|
+
t = e.backtrace.join("\n\t")
|
47
|
+
puts "Error: #{t}"
|
48
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# muquit@muquit.com Apr-01-2014
|
4
|
+
require [File.expand_path(File.dirname(__FILE__)), '../..', 'lib', 'mrdialog'].join('/')
|
5
|
+
begin
|
6
|
+
ME = File.basename($0)
|
7
|
+
if ENV['CHANGE_TITLE']
|
8
|
+
if ME =~ /(.+)\.rb$/
|
9
|
+
base = $1
|
10
|
+
puts "\033]0;mrdialog - #{base}\007"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
dialog = MRDialog.new
|
15
|
+
dialog.logger = Logger.new(ENV["HOME"] + "/dialog_" + ME + ".log")
|
16
|
+
dialog.clear = true
|
17
|
+
dialog.title = "MENU BOX"
|
18
|
+
dialog.extra_button = true
|
19
|
+
dialog.ok_label = "Send"
|
20
|
+
dialog.extra_label = "Save"
|
21
|
+
dialog.cancel_label = "Quit"
|
22
|
+
|
23
|
+
|
24
|
+
text = <<EOF
|
25
|
+
This example is taken from dialog/samples/menubox1
|
26
|
+
|
27
|
+
Hi, this is a menu box. You can use this to
|
28
|
+
present a list of choices for the user to
|
29
|
+
choose. If there are more items than can fit
|
30
|
+
on the screen, the menu will be scrolled.
|
31
|
+
You can use the UP/DOWN arrow keys, the first
|
32
|
+
letter of the choice as a hot key, or the
|
33
|
+
number keys 1-9 to choose an option.
|
34
|
+
Try it now!
|
35
|
+
|
36
|
+
Choose the OS you like:
|
37
|
+
|
38
|
+
EOF
|
39
|
+
items = []
|
40
|
+
menu_data = Struct.new(:tag, :item)
|
41
|
+
data = menu_data.new
|
42
|
+
data.tag = "Linux"
|
43
|
+
data.item = "The Great Unix Clone for 386/486"
|
44
|
+
items.push(data.to_a)
|
45
|
+
|
46
|
+
data = menu_data.new
|
47
|
+
data.tag = "NetBSD"
|
48
|
+
data.item = "Another free Unix Clone for 386/486"
|
49
|
+
items.push(data.to_a)
|
50
|
+
|
51
|
+
data = menu_data.new
|
52
|
+
data.tag = "OS/2"
|
53
|
+
data.item = "IBM OS/2"
|
54
|
+
items.push(data.to_a)
|
55
|
+
|
56
|
+
data = menu_data.new
|
57
|
+
data.tag = "WIN NT"
|
58
|
+
data.item = "Microsoft Windows NT"
|
59
|
+
items.push(data.to_a)
|
60
|
+
|
61
|
+
data = menu_data.new
|
62
|
+
data.tag = "PCDOS"
|
63
|
+
data.item = "IBM PC DOS"
|
64
|
+
items.push(data.to_a)
|
65
|
+
|
66
|
+
data = menu_data.new
|
67
|
+
data.tag = "MSDOS"
|
68
|
+
data.item = "Microsoft DOS"
|
69
|
+
items.push(data.to_a)
|
70
|
+
|
71
|
+
|
72
|
+
height = 0
|
73
|
+
width = 0
|
74
|
+
menu_height = 4
|
75
|
+
|
76
|
+
selected_item = dialog.menu(text, items, height, width, menu_height)
|
77
|
+
|
78
|
+
puts "Exit Code: #{dialog.exit_code}"
|
79
|
+
puts "Selected item: #{selected_item}"
|
80
|
+
|
81
|
+
rescue => e
|
82
|
+
puts "#{$!}"
|
83
|
+
t = e.backtrace.join("\n\t")
|
84
|
+
puts "Error: #{t}"
|
85
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# muquit@muquit.com Apr-01-2014
|
3
|
+
require [File.expand_path(File.dirname(__FILE__)), '../..', 'lib', 'mrdialog'].join('/')
|
4
|
+
require 'pp'
|
5
|
+
|
6
|
+
begin
|
7
|
+
ME = File.basename($0)
|
8
|
+
if ENV['CHANGE_TITLE']
|
9
|
+
if ME =~ /(.+)\.rb$/
|
10
|
+
base = $1
|
11
|
+
puts "\033]0;mrdialog - #{base}\007"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
text = <<EOF
|
16
|
+
Hi, this is an password dialog box. You can use
|
17
|
+
this to ask questions that require the user
|
18
|
+
to input a string as the answer. You can
|
19
|
+
input strings of length longer than the
|
20
|
+
width of the input box, in that case, the
|
21
|
+
input field will be automatically scrolled.
|
22
|
+
You can use BACKSPACE to correct errors.
|
23
|
+
Try entering your name below:
|
24
|
+
|
25
|
+
EOF
|
26
|
+
dialog = MRDialog.new
|
27
|
+
dialog.logger = Logger.new(ENV["HOME"] + "/dialog_" + ME + ".log")
|
28
|
+
dialog.clear = true
|
29
|
+
dialog.title = "Password box"
|
30
|
+
dialog.extra_button = true
|
31
|
+
dialog.ok_label = "Login"
|
32
|
+
dialog.extra_label = "Reset"
|
33
|
+
dialog.cancel_label = "Quit"
|
34
|
+
|
35
|
+
result = dialog.passwordbox(text)
|
36
|
+
|
37
|
+
puts "Exit Code: #{dialog.exit_code}"
|
38
|
+
puts "Result is: #{result}"
|
39
|
+
|
40
|
+
rescue => e
|
41
|
+
puts "#{$!}"
|
42
|
+
t = e.backtrace.join("\n\t")
|
43
|
+
puts "Error: #{t}"
|
44
|
+
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# muquit@muquit.com Apr-01-2014
|
4
|
+
require [File.expand_path(File.dirname(__FILE__)), '../..', 'lib', 'mrdialog'].join('/')
|
5
|
+
require 'pp'
|
6
|
+
|
7
|
+
class TestRadiolist
|
8
|
+
ME = File.basename($0)
|
9
|
+
|
10
|
+
def initialize
|
11
|
+
if ENV['CHANGE_TITLE']
|
12
|
+
if ME =~ /(.+)\.rb$/
|
13
|
+
base = $1
|
14
|
+
puts "\033]0;mrdialog - #{base}\007"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def doit
|
20
|
+
dialog = MRDialog.new
|
21
|
+
dialog.clear = true
|
22
|
+
dialog.logger = Logger.new(ENV["HOME"] + "/dialog_" + ME + ".log")
|
23
|
+
|
24
|
+
text = <<EOF
|
25
|
+
This example is taken from dialog/samples/radiolist
|
26
|
+
shell script.
|
27
|
+
|
28
|
+
Hi, this is a radiolist box. You can use this to
|
29
|
+
present a list of choices which can be turned on or
|
30
|
+
off. If there are more items than can fit on the
|
31
|
+
screen, the list will be scrolled. You can use the
|
32
|
+
UP/DOWN arrow keys, the first letter of the choice as a
|
33
|
+
hot key, or the number keys 1-9 to choose an option.
|
34
|
+
Press SPACE to toggle an option on/off.
|
35
|
+
|
36
|
+
Which of the following are fruits?
|
37
|
+
|
38
|
+
EOF
|
39
|
+
items = []
|
40
|
+
radiolist_data = Struct.new(:tag, :item, :select)
|
41
|
+
|
42
|
+
data = radiolist_data.new
|
43
|
+
data.tag = "Apple"
|
44
|
+
data.item = "It's an applie"
|
45
|
+
data.select = false
|
46
|
+
items.push(data.to_a)
|
47
|
+
|
48
|
+
data = radiolist_data.new
|
49
|
+
data.tag = "Dog"
|
50
|
+
data.item = "No it's not my dog"
|
51
|
+
data.select = true
|
52
|
+
items.push(data.to_a)
|
53
|
+
|
54
|
+
data = radiolist_data.new
|
55
|
+
data.tag = "Orange"
|
56
|
+
data.item = "Yeah! it is juicy"
|
57
|
+
data.select = false
|
58
|
+
items.push(data.to_a)
|
59
|
+
|
60
|
+
dialog.title = "RADIOLIST"
|
61
|
+
dialog.extra_button = true
|
62
|
+
dialog.ok_label = "Edit"
|
63
|
+
dialog.extra_label = "Delete"
|
64
|
+
dialog.cancel_label = "Quit"
|
65
|
+
|
66
|
+
selected_item = dialog.radiolist(text, items)
|
67
|
+
exit_code = dialog.exit_code
|
68
|
+
case exit_code
|
69
|
+
when dialog.dialog_ok
|
70
|
+
puts "OK Pressed"
|
71
|
+
when dialog.dialog_extra
|
72
|
+
puts "Extra Pressed"
|
73
|
+
when dialog.dialog_cancel
|
74
|
+
puts "Cancel Pressed"
|
75
|
+
when dialog.dialog_esc
|
76
|
+
puts "Escape Pressed"
|
77
|
+
end
|
78
|
+
|
79
|
+
puts "Selected item: #{selected_item}"
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
if __FILE__ == $0
|
84
|
+
TestRadiolist.new.doit
|
85
|
+
end
|
86
|
+
|
@@ -0,0 +1,43 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# muquit@muquit.com Apr-01-2014
|
4
|
+
require [File.expand_path(File.dirname(__FILE__)), '../..', 'lib', 'mrdialog'].join('/')
|
5
|
+
require 'pp'
|
6
|
+
|
7
|
+
begin
|
8
|
+
ME = File.basename($0)
|
9
|
+
if ENV['CHANGE_TITLE']
|
10
|
+
if ME =~ /(.+)\.rb$/
|
11
|
+
base = $1
|
12
|
+
puts "\033]0;mrdialog - #{base}\007"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
text = <<EOF
|
17
|
+
Please set the time...
|
18
|
+
EOF
|
19
|
+
|
20
|
+
h = 0
|
21
|
+
w = 0
|
22
|
+
t = Time.new
|
23
|
+
|
24
|
+
dialog = MRDialog.new
|
25
|
+
dialog.logger = Logger.new(ENV["HOME"] + "/dialog_" + ME + ".log")
|
26
|
+
dialog.clear = true
|
27
|
+
dialog.title = "TIEMBOX"
|
28
|
+
dialog.extra_button = true
|
29
|
+
dialog.ok_label = "Event"
|
30
|
+
dialog.extra_label = "Alert"
|
31
|
+
dialog.cancel_label = "Quit"
|
32
|
+
|
33
|
+
# return Time
|
34
|
+
time = dialog.timebox(text, h, w, t)
|
35
|
+
|
36
|
+
puts "Exit Code: #{dialog.exit_code}"
|
37
|
+
puts "time: #{time}"
|
38
|
+
|
39
|
+
rescue => e
|
40
|
+
puts "#{$!}"
|
41
|
+
t = e.backtrace.join("\n\t")
|
42
|
+
puts "Error: #{t}"
|
43
|
+
end
|
@@ -0,0 +1,112 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# muquit@muquit.com Apr-20-2014
|
4
|
+
require [File.expand_path(File.dirname(__FILE__)), '../..', 'lib', 'mrdialog'].join('/')
|
5
|
+
require 'pp'
|
6
|
+
|
7
|
+
begin
|
8
|
+
ME = File.basename($0)
|
9
|
+
if ENV['CHANGE_TITLE']
|
10
|
+
if ME =~ /(.+)\.rb$/
|
11
|
+
base = $1
|
12
|
+
puts "\033]0;mrdialog - #{base}\007"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
text = <<-EOF
|
17
|
+
This example is taken from dialog/samples/treeview1
|
18
|
+
shell script.
|
19
|
+
|
20
|
+
EOF
|
21
|
+
items = []
|
22
|
+
Struct.new("TreeviewData", :tag, :item, :status, :depth)
|
23
|
+
data = Struct::TreeviewData.new
|
24
|
+
|
25
|
+
data.tag = "tag1"
|
26
|
+
data.item = "Item number 1"
|
27
|
+
data.status = false
|
28
|
+
data.depth = 0
|
29
|
+
items.push(data.to_a)
|
30
|
+
|
31
|
+
data = Struct::TreeviewData.new
|
32
|
+
data.tag = "tag2"
|
33
|
+
data.item = "Item number 2"
|
34
|
+
data.status = false
|
35
|
+
data.depth = 1
|
36
|
+
items.push(data.to_a)
|
37
|
+
|
38
|
+
data = Struct::TreeviewData.new
|
39
|
+
data.tag = "tag3"
|
40
|
+
data.item = "Item number 3"
|
41
|
+
data.status = true
|
42
|
+
data.depth = 2
|
43
|
+
items.push(data.to_a)
|
44
|
+
|
45
|
+
data = Struct::TreeviewData.new
|
46
|
+
data.tag = "tag4"
|
47
|
+
data.item = "Item number 4"
|
48
|
+
data.status = false
|
49
|
+
data.depth = 1
|
50
|
+
items.push(data.to_a)
|
51
|
+
|
52
|
+
data = Struct::TreeviewData.new
|
53
|
+
data.tag = "tag5"
|
54
|
+
data.item = "Item number 5"
|
55
|
+
data.status = false
|
56
|
+
data.depth = 2
|
57
|
+
items.push(data.to_a)
|
58
|
+
|
59
|
+
data = Struct::TreeviewData.new
|
60
|
+
data.tag = "tag6"
|
61
|
+
data.item = "Item number 6"
|
62
|
+
data.status = false
|
63
|
+
data.depth = 3
|
64
|
+
items.push(data.to_a)
|
65
|
+
|
66
|
+
data = Struct::TreeviewData.new
|
67
|
+
data.tag = "tag7"
|
68
|
+
data.item = "Item number 7"
|
69
|
+
data.status = false
|
70
|
+
data.depth = 3
|
71
|
+
items.push(data.to_a)
|
72
|
+
|
73
|
+
data = Struct::TreeviewData.new
|
74
|
+
data.tag = "tag8"
|
75
|
+
data.item = "Item number 8"
|
76
|
+
data.status = false
|
77
|
+
data.depth = 4
|
78
|
+
items.push(data.to_a)
|
79
|
+
|
80
|
+
data = Struct::TreeviewData.new
|
81
|
+
data.tag = "tag9"
|
82
|
+
data.item = "Item number 9"
|
83
|
+
data.status = false
|
84
|
+
data.depth = 1
|
85
|
+
items.push(data.to_a)
|
86
|
+
|
87
|
+
dialog = MRDialog.new
|
88
|
+
dialog.clear = true
|
89
|
+
dialog.title = "TREEVIEW"
|
90
|
+
dialog.logger = Logger.new(ENV["HOME"] + "/dialog_" + ME + ".log")
|
91
|
+
dialog.extra_button = true
|
92
|
+
dialog.ok_label = "Edit"
|
93
|
+
dialog.extra_label = "Delete"
|
94
|
+
dialog.cancel_label = "Quit"
|
95
|
+
|
96
|
+
|
97
|
+
height = 0
|
98
|
+
width = 0
|
99
|
+
listheight = 0
|
100
|
+
|
101
|
+
selected_tag = dialog.treeview(text, items, height, width, listheight)
|
102
|
+
exit_code = dialog.exit_code
|
103
|
+
puts "Exit code: #{exit_code}"
|
104
|
+
if exit_code != 1
|
105
|
+
puts "Selected tag: #{selected_tag}"
|
106
|
+
end
|
107
|
+
|
108
|
+
rescue => e
|
109
|
+
puts "#{$!}"
|
110
|
+
t = e.backtrace.join("\n\t")
|
111
|
+
puts "Error: #{t}"
|
112
|
+
end
|
data/samples/run_all.rb
CHANGED