How to use the pyno.node.Node function in pyno

To help you get started, we’ve selected a few pyno examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github honix / Pyno / pyno / serializer.py View on Github external
def serialize(self, nodes, anchor=(0, 0)):
        buff = []
        buff.append({'version': Serializer.version})
        for node in nodes:
            if isinstance(node, Node):
                buff.append(OrderedDict({'type': 'node',
                            '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}))
github honix / Pyno / pyno / window.py View on Github external
return
                    else:
                        si = node.selectedInput['name'] != 'none'
                        so = node.selectedOutput['name'] != 'none'
                        if si or so:
                            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)
github honix / Pyno / pyno / window.py View on Github external
def on_key_press(self, symbol, modifiers):
        key = pyglet.window.key

        if modifiers == 2 and symbol == key.EQUAL:
            # double zoom
            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):
github honix / Pyno / pyno / serializer.py View on Github external
print("Attention: pyno-file still uses the old save format, please re-save soon!")
            paste = eval(data)

        try:
            version = paste[0]['version']
        except Exception as ex:
            print('Can\'t fetch format version. Probably format is < 0.3.')
            version = 0.0

        nodes = paste[1:] if version >= 0.3 else paste

        buff = []
        try:
            for node in nodes:
                if node['type'] == 'node':
                    buff.append(Node(self.window, 
                                    node['x'] + anchor[0],
                                    node['y'] + anchor[1],
                                    self.window.batch,
                                    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'],
github honix / Pyno / pyno / window.py View on Github external
def on_key_press(self, symbol, modifiers):
        key = pyglet.window.key

        if modifiers == 2 and symbol == key.EQUAL:
            # double zoom
            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: