Skip to content

Commit 91ce2fd

Browse files
committed
Allow adding stle and pictures
1 parent bcb8358 commit 91ce2fd

2 files changed

Lines changed: 28 additions & 2 deletions

File tree

in.aryank.openforms.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
{
3131
"type" : "git",
3232
"url" : "https://github.com/Aryan20/open_forms.git",
33-
"branch" : "a121c7e3b24094dd42ff6fc57c503ad54da2a1f0"
33+
"branch" : "main"
3434
}
3535
],
3636
"config-opts" : [

src/form_page.py

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,14 @@ def _create_field(self, label_text: str, field: dict):
6969
label=label_text,
7070
halign=Gtk.Align.START,
7171
)
72-
if field_type != "check":
72+
73+
if field_type == "label":
74+
if "style" in field:
75+
style_list = field.get("style")
76+
for style in style_list:
77+
label.add_css_class(style)
78+
79+
if field_type != "check" and field_type != "picture":
7380
row.append(label)
7481

7582
if field_type == "entry":
@@ -103,9 +110,28 @@ def _create_field(self, label_text: str, field: dict):
103110
row.append(widget)
104111
elif field_type == "label":
105112
return row, None
113+
elif field_type == "picture":
114+
widget = Gtk.Picture.new_for_resource(field.get("uri"))
115+
widget.set_halign(3)
116+
widget.set_valign(3)
117+
widget.set_hexpand(True)
118+
widget.set_vexpand(True)
119+
widget.can_shrink = True
120+
width = field.get("width")
121+
height = field.get("height")
122+
widget.set_size_request(width, height)
123+
widget.set_content_fit(Gtk.ContentFit.CONTAIN)
124+
widget.set_margin_top(10)
125+
widget.set_margin_bottom(10)
126+
row.append(widget)
106127
else:
107128
return None, None
108129

130+
if "style" in field:
131+
style_list = field.get("style")
132+
for style in style_list:
133+
label.add_css_class(style)
134+
109135
return row, widget
110136

111137
@Gtk.Template.Callback()

0 commit comments

Comments
 (0)