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
54 changes: 47 additions & 7 deletions examples/advanced.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,17 @@ def create_datalist_example():
]
return test

def create_datagroup_example():
def create_combogroup_example():
datalist = create_datalist_example()
return ((datalist, "Category 1", "Category 1 comment"),
return [(datalist, "Category 1", "Category 1 comment"),
(datalist, "Category 2", "Category 2 comment"),
(datalist, "Category 3", "Category 3 comment"))
(datalist, "Category 3", "Category 3 comment")]

def create_tabgroup_example():
datalist = create_datalist_example()
return ((datalist, "Title 1", "Title 1 comment"),
(datalist, "Title 2", "Title 2 comment"),
(datalist, "Title 3", "Title 3 comment"))

def apply_function(result, widgets):
print('result:', result)
Expand Down Expand Up @@ -83,14 +89,48 @@ def second_function(result, widgets):
type='questions',
scrollbar=True))

#--------- datagroup example
datagroup = create_datagroup_example()
#--------- datagroup examples
datagroup = create_combogroup_example()
print("result:", fedit(datagroup, "Global title", result='JSON'))

#--------- datagroup inside a datagroup example
datagroup = create_tabgroup_example()
print("result:", fedit(datagroup, "Global title", result='JSON'))

#--------- datagroup inside a datagroup examples
datalist = create_datalist_example()
datagroup = create_tabgroup_example()
print("result:", fedit([(datagroup, "Category 1", "Category 1 comment"),
(datalist, "Category 2", "Category 2 comment"),
(datalist, "Category 3", "Category 3 comment")],
"Global title", result='XML'))

datalist = create_datalist_example()
datagroup = create_datagroup_example()
datagroup = create_combogroup_example()
print("result:", fedit(((datagroup, "Title 1", "Tab 1 comment"),
(datalist, "Title 2", "Tab 2 comment"),
(datalist, "Title 3", "Tab 3 comment")),
"Global title", result='XML'))

datalist = create_datalist_example()
datagroup = create_combogroup_example()
print("result:", fedit([(datagroup, "Category 1", "Category 1 comment"),
(datalist, "Category 2", "Category 2 comment"),
(datalist, "Category 3", "Category 3 comment")],
"Global title", result='XML'))

datalist = create_datalist_example()
datagroup = create_tabgroup_example()
print("result:", fedit(((datagroup, "Title 1", "Tab 1 comment"),
(datalist, "Title 2", "Tab 2 comment"),
(datalist, "Title 3", "Tab 3 comment")),
"Global title", result='XML'))

datalist = create_datalist_example()
datagroup = create_tabgroup_example()
print("result:", fedit((([(datagroup, "Category 1", "Category 1 comment"),
(datalist, "Category 2", "Category 2 comment"),
(datalist, "Category 3", "Category 3 comment")],
"Three", "Three levels"),
(datagroup, "Two", "Two levels"),
(datalist, "One", "One level")),
"Global title", result='XML'))
15 changes: 11 additions & 4 deletions formlayout.py
Original file line number Diff line number Diff line change
Expand Up @@ -779,7 +779,12 @@ def __init__(self, datalist, comment="", parent=None):
self.widgetlist = []
for data, title, comment in datalist:
self.combobox.addItem(title)
widget = FormWidget(data, comment=comment, parent=self)
if isinstance(data, tuple) and len(data[0]) == 3:
widget = FormTabWidget(data, comment=comment, parent=self)
elif isinstance(data, list) and len(data[0]) == 3:
widget = FormComboWidget(data, comment=comment, parent=self)
else:
widget = FormWidget(data, comment=comment, parent=self)
self.stackwidget.addWidget(widget)
self.widgetlist.append((title, widget))

Expand Down Expand Up @@ -832,7 +837,9 @@ def __init__(self, datalist, comment="", parent=None):
self.type = parent.type
self.widgetlist = []
for data, title, comment in datalist:
if len(data[0])==3:
if isinstance(data, tuple) and len(data[0]) == 3:
widget = FormTabWidget(data, comment=comment, parent=self)
elif isinstance(data, list) and len(data[0]) == 3:
widget = FormComboWidget(data, comment=comment, parent=self)
else:
widget = FormWidget(data, comment=comment, parent=self)
Expand Down Expand Up @@ -917,10 +924,10 @@ def __init__(self, data, title="", comment="", icon=None, parent=None,
import xml.etree.ElementTree as ET

# Form
if isinstance(data[0][0], (list, tuple)):
if isinstance(data, tuple) and len(data[0]) == 3:
self.formwidget = FormTabWidget(data, comment=comment,
parent=self)
elif len(data[0])==3:
elif isinstance(data, list) and len(data[0]) == 3:
self.formwidget = FormComboWidget(data, comment=comment,
parent=self)
else:
Expand Down