Skip to content

Commit 38ef408

Browse files
authored
Merge pull request #31 from openalea/visualea
Visualea, Emit problem
2 parents 915b925 + bdc38b2 commit 38ef408

File tree

8 files changed

+223
-10
lines changed

8 files changed

+223
-10
lines changed

src/openalea/visualea/compositenode_widget.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ def set_autonomous(self):
160160
def run_node(self):
161161
self.node.eval_as_expression(self.sender().id)
162162

163+
163164
def open_widget(self):
164165
operator = GraphOperator(graph=self.node)
165166
operator.vertex_open(self.sender().id)

src/openalea/visualea/dataflowview/adapter.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
from openalea.core import node
2222
from openalea.core import compositenode
2323
import openalea.grapheditor.base as grapheditorbase
24+
from qtpy import QtWidgets
2425

2526
class GraphAdapter(grapheditorbase.GraphAdapterBase):
2627
"""An adapter to openalea.core.compositenode"""
@@ -81,7 +82,7 @@ def add_vertex(self, vertex, position=None):
8182
vertex.get_ad_hoc_dict().set_metadata("position", position)
8283
return vid
8384
except node.RecursionError:
84-
mess = QtGui.QMessageBox.warning(self, "Error",
85+
mess = QtWidgets.QMessageBox.warning(self, "Error",
8586
"A graph cannot be contained in itself.")
8687

8788
def remove_vertex(self, vertex):

src/openalea/visualea/graph_operator/port.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,15 @@ def port_send_to_console(self):
101101
QtWidgets.QMessageBox.Ok)
102102
if overwrite == QtWidgets.QMessageBox.Ok:
103103
interpreter.locals[result]=data
104+
data = str(data)
105+
data = data[:500]+"[...truncated]" if len(data)>500 else data
106+
print(result + ": " + data)
107+
104108
# print the instance name and content as if the user type its name in a shell
105109
# this is only to make obvious the availability of the instance in the
106-
try:
107-
interpreter.runsource(result, hidden=False, interactive=True)
108-
except:
109-
interpreter.runsource("%s\n" % result)
110+
# try:
111+
# interpreter.runsource(result, hidden=False, interactive=True)
112+
# except:
113+
# interpreter.runsource("%s\n" % result)
110114

111115
#setFocus()

src/openalea/visualea/node_widget.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,18 @@ def call_notify (self, sender, event=None):
5757
@param event : the data associated to the notification
5858
"""
5959

60+
# Don't see the point of self.qobj().emit because anyway we manage
61+
# ourselves the notification with self.notify
6062
try:
61-
self.qobj().emit(QtCore.Signal("notify"), sender, event)
62-
except Exception as e:
63-
# fix_print_with_import
64-
print(("Cannot emit Qt Signal : ", e))
6563
self.notify(sender, event)
64+
except:
65+
pass
66+
# try:
67+
# self.qobj().emit(QtCore.Signal("notify"), sender, event)
68+
# except Exception as e:
69+
# # fix_print_with_import
70+
# print(("Cannot emit Qt Signal : ", e))
71+
# self.notify(sender, event)
6672

6773

6874

test/dataflow/dataflow_test/__init__.py

Whitespace-only changes.
Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
2+
# This file has been generated at Wed Feb 22 14:27:28 2023
3+
4+
from openalea.core import *
5+
6+
7+
__name__ = 'dataflow_test'
8+
9+
__editable__ = True
10+
__version__ = '0.0.1'
11+
__license__ = 'Cecill-C'
12+
__authors__ = 'OpenAlea Consortium'
13+
__institutes__ = 'INRIA/CIRAD'
14+
__description__ = 'test simple data flow'
15+
__url__ = 'https://github.com/openalea'
16+
__icon__ = ''
17+
__alias__ = []
18+
19+
20+
__all__ = ['addition']
21+
22+
23+
24+
addition = CompositeNodeFactory(name='addition',
25+
description='simple addition',
26+
category='category test',
27+
doc='',
28+
inputs=[],
29+
outputs=[],
30+
elt_factory={ 2: ('pkg_test', 'float'),
31+
3: ('pkg_test', 'float'),
32+
4: ('pkg_test', '+'),
33+
5: ('openalea.flow control', 'annotation'),
34+
6: ('openalea.flow control', 'annotation'),
35+
7: ('pkg_test', 'float')},
36+
elt_connections={ 140604922288400: (3, 0, 4, 0),
37+
140604922288432: (2, 0, 4, 1),
38+
140604922288464: (4, 0, 7, 0)},
39+
elt_data={ 2: { 'block': False,
40+
'caption': '2.1',
41+
'delay': 0,
42+
'hide': True,
43+
'id': 2,
44+
'lazy': True,
45+
'port_hide_changed': set(),
46+
'posx': -245.9709450619092,
47+
'posy': -111.85872859148041,
48+
'priority': 0,
49+
'use_user_color': False,
50+
'user_application': None,
51+
'user_color': None},
52+
3: { 'block': False,
53+
'caption': '1.2',
54+
'delay': 0,
55+
'hide': True,
56+
'id': 3,
57+
'lazy': True,
58+
'port_hide_changed': set(),
59+
'posx': -320.3252070658707,
60+
'posy': -111.0109722906813,
61+
'priority': 0,
62+
'use_user_color': False,
63+
'user_application': None,
64+
'user_color': None},
65+
4: { 'block': False,
66+
'caption': '+',
67+
'delay': 0,
68+
'hide': True,
69+
'id': 4,
70+
'lazy': True,
71+
'port_hide_changed': set(),
72+
'posx': -314.20270829939903,
73+
'posy': -34.466726410245506,
74+
'priority': 0,
75+
'use_user_color': False,
76+
'user_application': False,
77+
'user_color': None},
78+
5: { 'id': 5,
79+
'posx': -364.22435123884213,
80+
'posy': -140.49860060790175,
81+
'txt': 'inputs'},
82+
6: { 'id': 6,
83+
'posx': -381.13154273993564,
84+
'posy': -60.87669916942594,
85+
'txt': 'addition'},
86+
7: { 'block': False,
87+
'caption': '3.3',
88+
'delay': 0,
89+
'hide': True,
90+
'id': 7,
91+
'lazy': True,
92+
'port_hide_changed': set(),
93+
'posx': -311.29505256125043,
94+
'posy': 14.841906066585054,
95+
'priority': 0,
96+
'use_user_color': False,
97+
'user_application': True,
98+
'user_color': None},
99+
'__in__': { 'block': False,
100+
'caption': 'In',
101+
'delay': 0,
102+
'hide': True,
103+
'id': 0,
104+
'lazy': True,
105+
'port_hide_changed': set(),
106+
'posx': 0,
107+
'posy': 0,
108+
'priority': 0,
109+
'use_user_color': True,
110+
'user_application': None,
111+
'user_color': None},
112+
'__out__': { 'block': False,
113+
'caption': 'Out',
114+
'delay': 0,
115+
'hide': True,
116+
'id': 1,
117+
'lazy': True,
118+
'port_hide_changed': set(),
119+
'posx': 0,
120+
'posy': 0,
121+
'priority': 0,
122+
'use_user_color': True,
123+
'user_application': None,
124+
'user_color': None}},
125+
elt_value={ 2: [(0, '2.1')],
126+
3: [(0, '1.2')],
127+
4: [],
128+
5: [],
129+
6: [],
130+
7: [],
131+
'__in__': [],
132+
'__out__': []},
133+
elt_ad_hoc={ 2: {'position': [-245.9709450619092, -111.85872859148041], 'userColor': None, 'useUserColor': False},
134+
3: {'position': [-320.3252070658707, -111.0109722906813], 'userColor': None, 'useUserColor': False},
135+
4: {'position': [-314.20270829939903, -34.466726410245506], 'userColor': None, 'useUserColor': False},
136+
5: {'position': [-364.22435123884213, -140.49860060790175], 'text': 'inputs', 'textColor': None, 'rectP2': (176.7140917324355, 69.32013223357238), 'color': None, 'visualStyle': 1},
137+
6: {'position': [-381.13154273993564, -60.87669916942594], 'text': 'addition', 'textColor': None, 'rectP2': (-1, -1), 'color': None, 'visualStyle': 1},
138+
7: {'position': [-311.29505256125043, 14.841906066585054], 'userColor': None, 'useUserColor': False},
139+
'__in__': {'position': [0, 0], 'userColor': None, 'useUserColor': True},
140+
'__out__': {'position': [0, 0], 'userColor': None, 'useUserColor': True}},
141+
lazy=True,
142+
eval_algo='LambdaEvaluation',
143+
)
144+
145+
146+
147+

test/test_helpwidget.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,6 @@ def test_helpwidget():
4444

4545

4646

47-
test_rst2alea()
47+
# test_rst2alea()
4848
#test_helpwidget()
4949

test/test_widget_composite_node.py

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
from openalea.core import logger, CompositeNodeFactory
2+
from openalea.visualea.mainwindow import MainWindow
3+
from openalea.core.pkgmanager import PackageManager
4+
from qtpy import QtWidgets, QtCore
5+
from openalea.core.alea import *
6+
7+
def open_window(factory):
8+
9+
dialog = QtWidgets.QDialog()
10+
widget = factory.instantiate_widget(autonomous=True)
11+
12+
dialog.setAttribute(QtCore.Qt.WA_DeleteOnClose)
13+
widget.setParent(dialog)
14+
15+
vboxlayout = QtWidgets.QVBoxLayout(dialog)
16+
vboxlayout.setContentsMargins(3,3,3,3)
17+
vboxlayout.setSpacing(5)
18+
vboxlayout.addWidget(widget)
19+
20+
dialog.setWindowTitle(factory.name)
21+
22+
return dialog
23+
24+
def test_addition_composite_node():
25+
# Allow to test DisplayGraphWidget from openalea.visualea.compositenode_widget
26+
app = QtWidgets.QApplication(sys.argv)
27+
28+
p = PackageManager()
29+
p.init(verbose=False)
30+
31+
factory, node = get_node(('dataflow_test', 'addition'), {}, pm=p)
32+
33+
win = open_window(factory)
34+
35+
# get the button 'Run', there is only one for the node 7 which is user marked
36+
for ch in win.findChildren(QtWidgets.QPushButton):
37+
if ch.text() == 'Run':
38+
ch.click()
39+
break
40+
# get the new caption of node 7, originally set to '0'
41+
output = win.children()[0].node.node(7).caption
42+
win.close()
43+
44+
res = run(('dataflow_test', 'addition'), {}, pm = p, vtx_id = 4)
45+
46+
47+
assert output == str(res[0])
48+
49+
def test_call_mainwindow():
50+
# test the basic call to openalea.visualea.mainwindow
51+
app = QtWidgets.QApplication(sys.argv)
52+
win = MainWindow(None)
53+
54+
# def test_remove_one_edge():

0 commit comments

Comments
 (0)