aboutsummaryrefslogtreecommitdiff
path: root/qolab/gui
diff options
context:
space:
mode:
authorEugeniy E. Mikhailov <evgmik@gmail.com>2021-12-19 22:08:53 -0500
committerEugeniy E. Mikhailov <evgmik@gmail.com>2021-12-19 22:08:53 -0500
commitc079b90b87a17821329f7cfc8e33cbacfc1cdb59 (patch)
treebee0be4b83b70669a58b42ea74dc7da716b513b2 /qolab/gui
parent6436cc27853c83e8b9c5ed4f7d483f2f236bb977 (diff)
downloadqolab-c079b90b87a17821329f7cfc8e33cbacfc1cdb59.tar.gz
qolab-c079b90b87a17821329f7cfc8e33cbacfc1cdb59.zip
dictionary can show subdictionary
Diffstat (limited to 'qolab/gui')
-rw-r--r--qolab/gui/web.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/qolab/gui/web.py b/qolab/gui/web.py
index 7f60ec1..a2c4720 100644
--- a/qolab/gui/web.py
+++ b/qolab/gui/web.py
@@ -12,6 +12,7 @@ labelnames_classes = 'font-bold'
panel_div_classes = 'space-x-4 border'
controls_div_classes = 'flex flex-wrap space-x-4 p-1 border'
controls_group_classes = 'flex flex-wrap space-x-4 p-1'
+dict_group_classes = 'bg-gray-100 flex flex-wrap space-x-0 p-0 border-2'
input_classes = "m-2 bg-gray-200 border-2 border-gray-200 rounded w-20 text-gray-700 focus:outline-none focus:bg-white focus:border-purple-500"
@@ -188,6 +189,28 @@ class QOLSaveControls(jp.Div):
if self.component_with_data is not None:
self.component_with_data.clear_last_saved_pos()
+class QOLDictionary(jp.Div):
+ def __init__(self, container=None, **kwargs):
+ super().__init__(**kwargs)
+ root = self
+ root.set_classes(dict_group_classes)
+ root.container=container
+ self.reflect_container()
+
+ def reflect_container(self):
+ root = self
+ s=jp.Span(text = self.name, a=root)
+ s.set_classes(labelnames_classes)
+ if self.container is None:
+ return
+ for k,v in self.container.items():
+ if not isinstance(v, dict):
+ QOLParamReadOnly(label=k, value=v, a=root)
+ else:
+ QOLDictionary(container=v, name=k, a=root)
+
+
+
def gui_test():
return wp
@@ -203,6 +226,14 @@ if __name__ == '__main__':
print(rw.getValue())
QOLPushButtonNoUndo(text='Danger', a=wp, onclick=test)
# sc = QOLSaveControls(a=wp)
+ d={}
+ d['a']='astring'
+ d['n']=7
+ d['d']={}
+ for i in range(20):
+ d['d'][i]=i
+ QOLDictionary(a=wp, name='d dictionary', container=d)
+
jp.justpy(gui_test)