-
Notifications
You must be signed in to change notification settings - Fork 8
/
calendar.rb
executable file
·45 lines (38 loc) · 1.14 KB
/
calendar.rb
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
#!/usr/bin/env ruby
########################################################################
# Example for calendar widget.
# [email protected] Apr-02-2014
########################################################################
#
require [File.expand_path(File.dirname(__FILE__)), '../..', 'lib', 'mrdialog'].join('/')
require 'date'
begin
ME = File.basename($0)
if ENV['CHANGE_TITLE']
if ME =~ /(.+)\.rb$/
base = $1
puts "\033]0;mrdialog - #{base}\007"
end
end
text = "Please choose a date..."
height = 0
width = 0
day = Date.today.mday
month =Date.today.mon
year =Date.today.year
dialog = MRDialog.new
dialog.logger = Logger.new(ENV["HOME"] + "/dialog_" + ME + ".log")
dialog.clear = true
dialog.title = "CALENDAR"
dialog.extra_button = true
dialog.ok_label = "Save"
dialog.extra_label = "Send"
dialog.cancel_label = "Quit"
date = dialog.calendar(text, height, width, day, month, year)
puts "Exit code: #{dialog.exit_code}"
puts "Result is: #{date.to_s}"
rescue => e
puts "#{$!}"
t = e.backtrace.join("\n\t")
puts "Error: #{t}"
end