-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathUI.py
87 lines (77 loc) · 2.52 KB
/
UI.py
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
80
81
82
83
84
85
86
import gi
gi.require_version("Gtk","4.0")
gi.require_version("Adw","1")
from gi.repository import Gtk,Adw
settings={
'fill':Gtk.Align(0),
'start':Gtk.Align(1),
'end':Gtk.Align(2),
'center':Gtk.Align(3),
'baseline':Gtk.Align(4),
'horizontal':Gtk.Orientation(0),
'vertical':Gtk.Orientation(1)
}
class UI():
class Box(Gtk.Box):
def create(orientation="horizontal",
homogeneous=False,
spacing=0,
height=-1,
width=-1,
css=[],
hexpand=False,
vexpand=False,
halign="fill",
valign="fill",
margin_bottom=-1,
margin_top=-1,
margin_start=-1,
margin_end=-1,
):
box = Gtk.Box.new(settings[orientation],spacing)
box.set_homogeneous(homogeneous)
box.set_size_request(width,height)
box.set_css_classes(css)
box.set_hexpand(hexpand)
box.set_vexpand(vexpand)
box.set_halign(settings[halign])
box.set_valign(settings[valign])
box.set_margin_bottom(margin_bottom)
box.set_margin_top(margin_top)
box.set_margin_start(margin_start)
box.set_margin_end(margin_end)
return box
class ListBoxRow(Gtk.ListBoxRow):
def create(text=""):
listboxrow = Gtk.ListBoxRow()
label = Gtk.Label(label=text)
listboxrow.set_child(label)
return listboxrow
class Button(Gtk.Button):
def create(
text="",
hexpand=False,
vexpand=False,
halign="fill",
valign="start"
):
button = Gtk.Button(label=text)
button.set_hexpand(hexpand)
button.set_vexpand(vexpand)
button.set_halign(settings[halign])
button.set_valign(settings[valign])
return button
class ListBoxRow(Gtk.ListBoxRow):
def create(
text="",
hexpand=False,
vexpand=False,
halign='fill',
valign="start",
css=[]
):
label = Gtk.Label(label=text)
listboxrow = Gtk.ListBoxRow()
listboxrow.set_child(label)
listboxrow.set_css_classes(css)
return listboxrow