Skip to content

Commit b61f2f4

Browse files
committed
Merge branch 'master' of https://github.com/dddomodossola/remi
2 parents 62a67ca + 98c9d08 commit b61f2f4

5 files changed

Lines changed: 506 additions & 3 deletions

File tree

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,8 +362,8 @@ Create a *res* folder and pass it to your App class constructor:
362362
```python
363363
class MyApp(App):
364364
def __init__(self, *args):
365-
res_path = os.path.join(os.path.dirname(__file__), 'res')
366-
super(MyApp, self).__init__(*args, static_file_path=res_path)
365+
res_path = os.path.join(os.getcwd(), 'res')
366+
super(MyApp, self).__init__(*args, static_file_path={'res':res_path})
367367
```
368368

369369
Make a copy the standard style.css from the remi folder and paste it inside your *res* folder. Edit it in order to customize.
@@ -449,6 +449,8 @@ Projects using Remi
449449

450450
[The Python Banyan Framework](https://github.com/MrYsLab/python_banyan)
451451

452+
[LightShowPi show manager](https://bitbucket.org/chrispizzi75/lightshowpishowmanager)
453+
452454

453455
Other Implementations
454456
===

editor/editor.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,10 +314,11 @@ def load(self, ifile, configuration):
314314

315315
members_list = app_init_fnc.__dict__.values()
316316
for m in members_list:
317-
if inspect.isfunction(m) and m.__name__ not in ['__init__', 'main', 'idle']:
317+
if inspect.isfunction(m) and m.__name__ not in ['__init__', 'main', 'idle', 'construct_ui']:
318318
#setattr(self, m.__name__, self.fakeListenerFunc)
319319
import types
320320
setattr(self, m.__name__, types.MethodType( m, self ))
321+
print(m.__name__)
321322
root_widget = app_init_fnc.construct_ui(self)
322323
self.create_callback_copy(root_widget)
323324
return root_widget
@@ -474,6 +475,7 @@ def save(self, save_path_filename, configuration):
474475
self.prepare_path_to_this_widget(self.children['root'])
475476
ret = self.repr_widget_for_editor( self.children['root'] )
476477
code_nested = ret + self.check_pending_listeners(self,'self',True)# + self.code_listener_registration[str(id(self))]
478+
477479
main_code_class = prototypes.proto_code_main_class%{'classname':configuration.configDict[configuration.KEY_PRJ_NAME],
478480
'config_resourcepath':configuration.configDict[configuration.KEY_RESOURCEPATH],
479481
'code_nested':code_nested,
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
import remi.gui as gui
2+
from remi import start, App
3+
from remi_ext import TreeTable, SingleRowSelectionTable
4+
5+
class MyApp(App):
6+
def __init__(self, *args):
7+
super(MyApp, self).__init__(*args)
8+
9+
def main(self):
10+
self.wid = gui.VBox(style={'margin':'5px auto', 'padding': '10px'})
11+
table = [('', '#ff9', 'cable', '1', '2', '3'),
12+
('cable', '#ff9', '1-core cable', '1', '2', '3'),
13+
('cable', '#ff9', 'multi core cable', '1', '2', '3'),
14+
('multi core cable', '#ff9', '2-core cable', '1', '2', '3'),
15+
('multi core cable', '#ff9', '3-core cable', '1', '2', '3'),
16+
('3-core cable', '#ff9', '3-core armoured cable', '1', '2', '3'),
17+
('cable', '#ff9', 'armoured cable', '1', '2', '3'),
18+
('armoured cable', '#ff9', '3-core armoured cable', '1', '2', '3')]
19+
heads_color = '#dfd'
20+
uoms_color = '#ffd'
21+
heads = ['heads', heads_color, 'object', 'one', 'two', 'three']
22+
uoms = ['uom', uoms_color, '', 'mm', 'cm', 'dm']
23+
self.My_TreeTable(table, heads, heads2=uoms)
24+
return self.wid
25+
26+
def My_TreeTable(self, table, heads, heads2=None):
27+
''' Define and display a table
28+
in which the values in first column form one or more trees.
29+
'''
30+
self.Define_TreeTable(heads, heads2)
31+
self.Display_TreeTable(table)
32+
33+
def Define_TreeTable(self, heads, heads2=None):
34+
''' Define a TreeTable with a heading row
35+
and optionally a second heading row.
36+
'''
37+
display_heads = []
38+
display_heads.append(tuple(heads[2:]))
39+
self.tree_table = TreeTable()
40+
self.tree_table.append_from_list(display_heads, fill_title=True)
41+
if heads2 is not None:
42+
heads2_color = heads2[1]
43+
row_widget = gui.TableRow()
44+
for index, field in enumerate(heads2[2:]):
45+
row_item = gui.TableItem(text=field,
46+
style={'background-color': heads2_color})
47+
row_widget.append(row_item, field)
48+
self.tree_table.append(row_widget, heads2[0])
49+
self.wid.append(self.tree_table)
50+
51+
def Display_TreeTable(self, table):
52+
''' Display a table in which the values in first column form one or more trees.
53+
The table has row with fields that are strings of identifiers/names.
54+
First convert each row into a row_widget and item_widgets
55+
that are displayed in a TableTree.
56+
Each input row shall start with a parent field (field[0])
57+
that determines the tree hierarchy but that is not displayed on that row.
58+
The parent widget becomes an attribute of the first child widget.
59+
Field[1] is the row color, field[2:] contains the row values.
60+
Top child(s) shall have a parent field value that is blank ('').
61+
The input table rows shall be in the correct sequence.
62+
'''
63+
parent_names = []
64+
hierarchy = {}
65+
indent_level = 0
66+
widget_dict = {} # key, value = name, widget
67+
for row in table:
68+
parent_name = row[0]
69+
row_color = row[1]
70+
child_name = row[2]
71+
row_widget = gui.TableRow(style={'background-color': row_color})
72+
# Determine whether hierarchy of sub_sub concepts shall be open or not
73+
openness = 'true'
74+
row_widget.attributes['treeopen'] = openness
75+
# widget_dict[child_name] = row_widget
76+
for index, field in enumerate(row[2:]):
77+
# Determine field color
78+
field_color = '#ffff99'
79+
row_item = gui.TableItem(text=field,
80+
style={'text-align': 'left',
81+
'background-color': field_color})
82+
row_widget.append(row_item, field)
83+
if index == 0:
84+
row_item.parent = parent_name
85+
child_id = row_item
86+
87+
# The root of each tree has a parent that is blank ('').
88+
# Each row with childs has as attribute openness, which by default is 'true'.
89+
# The fields can be given other attributes, such as color.
90+
91+
# Verify whether the parent_name (child.parent)
92+
# is present or is in the list of parent_names.
93+
print('parent-child:', parent_name, child_name)
94+
if parent_name == '':
95+
hierarchy[child_name] = 0
96+
parent_names.append(child_name)
97+
target_level = 0
98+
elif parent_name in parent_names:
99+
hierarchy[child_name] = hierarchy[parent_name] + 1
100+
target_level = hierarchy[child_name]
101+
else:
102+
# Parent not in parent_names
103+
print('Error: Parent name "{}" does not appear in network'
104+
.format(parent_name))
105+
return
106+
print('indent, target-pre:', indent_level, target_level,
107+
parent_name, child_name)
108+
# Indentation
109+
if target_level > indent_level:
110+
self.tree_table.begin_fold()
111+
indent_level += 1
112+
if target_level < indent_level:
113+
while target_level < indent_level:
114+
indent_level += -1
115+
self.tree_table.end_fold()
116+
print('indent, target-post:', indent_level, target_level,
117+
parent_name, child_name)
118+
if child_name not in parent_names:
119+
parent_names.append(child_name)
120+
self.tree_table.append(row_widget, child_name)
121+
122+
123+
if __name__ == "__main__":
124+
# starts the webserver
125+
# optional parameters
126+
start(MyApp,address='127.0.0.1', port=8081, multiple_instance=False,
127+
enable_file_cache=True, update_interval=0.1, start_browser=True)
128+
# start(MyApp, debug=True, address='0.0.0.0', port=0 )

0 commit comments

Comments
 (0)