Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'x': node.x - anchor[0],
'y': node.y - anchor[1],
'size': node.editor_size,
'color': node.color,
'code': node.code.split('\n'),
'connects': node.get_con_id(),
'id': node.id}))
elif isinstance(node, Field):
buff.append(OrderedDict({'type': 'field',
'x': node.x - anchor[0],
'y': node.y - anchor[1],
'size': (node.w, node.h),
'code': node.document.text.split('\n'),
'connects': node.get_con_id(),
'id': node.id}))
elif isinstance(node, Sub):
buff.append(OrderedDict({'type': 'sub',
'x': node.x - anchor[0],
'y': node.y - anchor[1],
'size': node.editor_size,
'color': node.color,
'code': node.code,
'connects': node.get_con_id(),
'id': node.id}))
return json.dumps(buff, indent=4)
def on_close(self, force=False):
if (not self.caption == "Pyno") and (not force): # is this the root/main window?
return True
for node in self.nodes:
if isinstance(node, Sub) and node.pwindow:
node.pwindow.on_close(force=True)
self.autosave()
self.close()
tuple(node['color']),
'\n'.join(node['code']) if version >= 0.3 else node['code'],
node['connects'],
node['size'],
node['id' if version >= 0.4 else 'parent']))
elif node['type'] == 'field':
buff.append(Field(self.window,
node['x'] + anchor[0],
node['y'] + anchor[1],
self.window.batch,
'\n'.join(node['code']) if version >= 0.3 else node['code'],
node['connects'],
node['size'],
node['id' if version >= 0.4 else 'parent']))
elif node['type'] == 'sub':
buff.append(Sub(self.window,
node['x'] + anchor[0],
node['y'] + anchor[1],
self.window.batch,
tuple(node['color']),
node['code'],
node['connects'],
node['size'],
node['id' if version >= 0.4 else 'parent']))
except Exception as ex:
print('Wrong data:', ex)
return None
finally:
for node in buff:
node.reconnect(buff)
return buff
self.pan_scale[1] = 2
if not (self.code_editor or self.field):
if symbol == key.N:
self.nodes.append(Node(self, self.pointer[0], self.pointer[1], self.batch,
random_node_color(), code=initialCode.node))
elif symbol == key.O:
self.nodes.append(Node(self, self.pointer[0], self.pointer[1], self.batch,
random_node_color(), code=initialCode.open_node))
elif symbol == key.F:
self.nodes.append(Field(self, self.pointer[0], self.pointer[1], self.batch))
elif symbol == key.S:
self.nodes.append(Sub(self, self.pointer[0], self.pointer[1], self.batch,
random_node_color()))
elif symbol == key.R:
for node in self.nodes:
if isinstance(node, Node):
node.reload()
if modifiers & key.MOD_CTRL:
if symbol == key.C:
self.copy_nodes()
elif symbol == key.V:
self.paste_nodes()
if symbol == key.DELETE:
for node in self.selected_nodes:
self.pointer = (x, y)
self.connection = True
if si:
self.disconnect_node(node)
elif so:
self.connecting_node = \
{'node': node,
'put': node.selectedOutput,
'mode': 'output'}
return
if isinstance(node, Node):
self.code_editor = CodeEditor(node)
elif isinstance(node, Field) and not self.field:
self.push_handlers(node)
self.field = node
elif isinstance(node, Sub):
self.code_editor = CodeEditor(node, highlighting=2)
if node.pwindow:
node.pwindow.set_visible(not node.pwindow.visible)
self.selected_nodes = [node]
self.node_drag = True
return
self.select = True
self.selectPoint = (x, y)