Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
(None, 'Information:'),
('Password', 'password'),
('Age', 30),
('Strength', 'slider'),
('volume.png', 'slider'),
('Sex', [0, 'Male', 'Female']),
('Sex', (0, 'Male', 'Female')),
('Size', 12.1),
Expand Down
Binary file added examples/volume.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 16 additions & 4 deletions formlayout.py
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,9 @@ def get_dialog(self):
return dialog

def setup(self):
global img_fmt
img_fmt = tuple(['.'+str(bytes(ext).decode()) for ext
in QImageReader.supportedImageFormats()])
for label, value in self.data:
if DEBUG_FORMLAYOUT:
print("value:", value)
Expand All @@ -569,8 +572,6 @@ def setup(self):
field = PushLayout(value, self)
self.formlayout.addRow(field)
else:
img_fmt = tuple(['.'+str(bytes(ext).decode()) for ext
in QImageReader.supportedImageFormats()])
if value.endswith(img_fmt):
# Image
pixmap = QPixmap(value)
Expand Down Expand Up @@ -752,10 +753,16 @@ def setup(self):
style = "background-color:" + self.widget_color + ";"
field.setStyleSheet(style)

if label.endswith(img_fmt):
pixmap = QPixmap(label)
label = QLabel()
label.setPixmap(pixmap)
else:
label = QLabel(label)
if self.type == 'form':
self.formlayout.addRow(label, field)
elif self.type == 'questions':
self.formlayout.addRow(QLabel(label))
self.formlayout.addRow(label)
self.formlayout.addRow(field)
self.widgets.append(field)

Expand Down Expand Up @@ -856,7 +863,12 @@ def get(self):
if label.endswith(' *'):
label = label[:-2]
required = 'true'
child = ET.SubElement(form, label)
if label.endswith(img_fmt):
rdot = label.rfind('.')
child = ET.SubElement(form, label[:rdot])
child.attrib['format'] = label[rdot+1:]
else:
child = ET.SubElement(form, label)
if isinstance(value, tuple):
child.text = to_text_string(value[0])
child.attrib['amount'] = to_text_string(value[1])
Expand Down