This repository was archived by the owner on Dec 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathGtkGrid3.lua
More file actions
62 lines (52 loc) · 1.28 KB
/
Copy pathGtkGrid3.lua
File metadata and controls
62 lines (52 loc) · 1.28 KB
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
local lgi = require("lgi")
local Gtk = lgi.require("Gtk", "3.0")
local App = Gtk.Application({
application_id = "com.github.Miqueas.Lua-GTK3-Examples.GtkGrid3"
})
function App:on_startup()
Gtk.ApplicationWindow({
application = self,
default_width = 400,
default_height = 400,
border_width = 10
})
end
function App:on_activate()
self.active_window:set_titlebar(Gtk.HeaderBar({
visible = true,
show_close_button = true,
title = "GtkGrid",
subtitle = "Example 3"
}))
--[[ GtkGrid:
A container that acts like a grid, with columns, rows and cells.
Just look at this example:
]]
local Grid = Gtk.Grid({
visible = true,
-- This makes all columns of the same width
column_homogeneous = true,
-- Same, but for rows
row_homogeneous = true,
-- Sets the spacing between all columns
column_spacing = 10,
-- Same, but for rows
row_spacing = 10,
halign = Gtk.Align.CENTER,
valign = Gtk.Align.CENTER,
})
for top = 0, 2 do
for left = 0, 2 do
Grid:attach(
Gtk.Label({
visible = true,
label = ("Top: %d. Left: %d."):format(top, left)
}),
left, top, 1, 1
)
end
end
self.active_window:add(Grid)
self.active_window:present()
end
return App:run(arg)