-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbasic_table.cr
More file actions
45 lines (34 loc) · 942 Bytes
/
basic_table.cr
File metadata and controls
45 lines (34 loc) · 942 Bytes
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
require "../../src/uing"
UIng.init
main_window = UIng::Window.new("Table Example", 300, 100)
hbox = UIng::Box.new :horizontal
main_window.child = hbox
data = [
%w[Windows Microsoft],
%w[macOS Apple],
%w[Ubuntu Canonical],
]
model_handler = UIng::Table::Model::Handler.new do
num_columns { 2 }
column_type { |column| UIng::Table::Value::Type::String }
num_rows { data.size }
cell_value { |row, column| UIng::Table::Value.new(data[row][column]) }
set_cell_value { |row, column, value| }
end
table_model = UIng::Table::Model.new(model_handler)
table = UIng::Table.new(table_model) do
append_text_column("OS", 0, -1)
append_text_column("Vendor", 1, -1)
end
hbox.append(table, true)
main_window.show
main_window.on_closing do
# FIXME: https://github.com/kojix2/uing/issues/6
hbox.delete(0)
table.destroy # Destroy table firs
table_model.free # Then free model
UIng.quit
true
end
UIng.main
UIng.uninit