-
Notifications
You must be signed in to change notification settings - Fork 1
/
rtd.rb
79 lines (70 loc) · 1.49 KB
/
rtd.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
require 'tk'
class RTD
def load_todos
@todo_arr = IO.readlines("todo.txt")
end
def print_todos
@todo_arr.each { |e| print e }
end
def get_pri(pri)
ret=[]
@todo_arr.each do |td|
ret << td if td.start_with?("(#{pri})")
end
return ret
end
def init_tk
@root = TkRoot.new { title "Ruby To Do"}
@top_panes = TkPanedWindow.new(@root) do
orient 'horizontal'
pack 'fill' => 'both',
'expand' => 1
end
@bottom_panes = TkPanedWindow.new(@root) do
orient 'horizontal'
pack 'fill' => 'both',
'expand' => 1
end
@both_panes = TkPanedWindow.new(@root) do
width 400
height 800
orient 'vertical'
pack 'fill' => 'both',
'expand' => 1
end
@both_panes.add @top_panes
@both_panes.add @bottom_panes
end
def add_listbox(pri)
lbox = scroll = nil
lbox = TkListbox.new(@root) do
width 0
height 0
pack 'fill' => 'both',
'expand' => 1
end
scroll = TkScrollbar.new(lbox) do
pack 'fill' => 'y',
'side' => 'right'
orient 'vertical'
end
lbox.yscrollbar(scroll)
get_pri(pri).each do |td|
lbox.insert 0, td
end
return lbox
end
def run
load_todos
init_tk
@top_panes.add add_listbox("A")
@top_panes.add add_listbox("B")
@bottom_panes.add add_listbox("C")
@bottom_panes.add add_listbox("D")
print get_pri("A")
#print_todos
Tk.mainloop
end
end
obj = RTD.new
obj.run