How to use the pyno.utils.font 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 / element.py View on Github external
self.x, self.y = x, y
        self.w, self.h = 70, 30
        self.cw, self.ch = self.w // 2, self.h // 2
        self.offset = 20
        self.put_size = 5
        self.pin_color = color_select(color)
        self.color = color
        self.draw_color = color
        self.er_color = (230, 20, 20)

        self.active = True
        self.batch = batch
        self.graphics = dict(inputs=dict(), outputs=dict(), connections=list(),
                             error=None, base=Quad(self.batch))

        self.er_label = pyglet.text.Label('error', font_name=font,
                                          bold=True, font_size=12,
                                          color=self.er_color + (255,),
                                          anchor_x='right', anchor_y='center')
        self.inputs = ()
        self.outputs = ()
        self.in_labels = []
        self.connected_to = []
        self.out_labels = []
        self.child = []
        self.selected = False  # 714848
        self.selectedInput = {'name': 'none', 'pos': 0}
        self.selectedOutput = {'name': 'none', 'pos': 0}
        self.hover = False

        self.problem = False
github honix / Pyno / pyno / element.py View on Github external
self.in_labels = []
        gr['inputs'] = dict()
        for input in self.inputs:
            gr['inputs'][input] = Quad(self.batch)
            self.in_labels.append(pyglet.text.Label(input, x=0, y=0,
                                                    font_name=font,
                                                    bold=True,
                                                    color=(255,255,255,200),
                                                    font_size=12))
        self.out_labels = []
        gr['outputs'] = dict()
        for output in self.outputs:
            gr['outputs'][output] = Quad(self.batch)
            self.out_labels.append(pyglet.text.Label(output, x=0, y=0,
                                                     font_name=font,
                                                     bold=True,
                                                     color=(255,255,255,200),
                                                     font_size=12,
                                                     anchor_x='right'))
github honix / Pyno / pyno / field.py View on Github external
def __init__(self, window, x, y, batch, code='0', connects=None, size=None, id=None):
        Element.__init__(self, x, y, (230, 230, 230), batch, id)

        if size:
            self.w, self.h = size

        if connects:
            self.connected_to = connects

        self.window = window
        self.code = code

        self.document = pyglet.text.document.FormattedDocument(self.code)
        self.document.set_style(0, len(self.document.text),
                                dict(font_name=font,
                                     font_size=11,
                                     color=(0, 0, 0, 230)))
        self.layout = pyglet.text.layout.IncrementalTextLayout(
                self.document,
                self.w - 30, self.h - 3,
                multiline=True, batch=batch,
                group=labelsGroup)
        self.caret = pyglet.text.caret.Caret(self.layout)
        self.caret.color = (0, 0, 0)
        self.caret.visible = False

        self.incr = False
        self.resize = False

        self.inputs = ('input',)
        self.outputs = ('output',)
github honix / Pyno / pyno / node.py View on Github external
def __init__(self, window, x, y, batch, color=(200, 200, 200), code="",
                 connects=None, size=(300, 150), id=None):
        Element.__init__(self, x, y, color, batch, id)
        Processor.init_processor(self, window.global_scope)  # node has a processor for calculation

        self.window = window
        self.editor_size = size
        self.code = code

        if connects:
            self.connected_to = connects

        self.env = {}

        self.name = ''
        self.label = pyglet.text.Label(self.name, font_name=font,
                                       bold=True, font_size=11,
                                       anchor_x='center', anchor_y='center',
                                       batch=batch, group=labelsGroup,
                                       color=(255, 255, 255, 230))
        self.reload()
github honix / Pyno / pyno / codeEditor.py View on Github external
self.update_label = pyglet.text.Label('CTRL+ENTER to save and execute',
                                              font_name=font,
                                              anchor_y='top',
                                              font_size=9)

        self.line_numbering = pyglet.text.Label('',
                                                font_name=font,
                                                font_size=11,
                                                color=(255, 255, 255, 127),
                                                align='right',
                                                anchor_y='top',
                                                width=nline_width,
                                                multiline=True)

        self.autocomplete = pyglet.text.Label('',
                                              font_name=font,
                                              font_size=9,
                                              color=(125, 255, 125, 127))

        self.caret = pyglet.text.caret.Caret(self.layout)
        self.caret.color = (255, 255, 255)
        self.caret.visible = False
        self.hover = False
        self.hovered = True
        self.resize = False

        self.change = False

        self.pan_scale = [[0.0, 0.0], 1]
        self.screen_size = (800, 600)
github honix / Pyno / pyno / codeEditor.py View on Github external
def __init__(self, node, highlighting=1):
        self.node = node  # node-owner of this codeEditor
        self.document = pyglet.text.document.FormattedDocument(node.code)

        self.highlighting = highlighting  # 0: off, 1: python (node), 2: file (sub)

        @self.document.event
        def on_insert_text(start, end):
            self.update_highlighting()

        @self.document.event
        def on_delete_text(start, end):
            self.update_highlighting()

        self.document.set_style(0, len(node.code),
                                dict(font_name=font,
                                font_size=11, color=(255, 255, 255, 230)))

        self.layout = pyglet.text.layout.IncrementalTextLayout(
                                self.document,
                                *node.editor_size,
                                multiline=True, wrap_lines=False)

        self.update_label = pyglet.text.Label('CTRL+ENTER to save and execute',
                                              font_name=font,
                                              anchor_y='top',
                                              font_size=9)

        self.line_numbering = pyglet.text.Label('',
                                                font_name=font,
                                                font_size=11,
                                                color=(255, 255, 255, 127),
github honix / Pyno / pyno / sub.py View on Github external
connects=None, size=(300, 150), id=None):
        Element.__init__(self, x, y, color, batch, id)
        Processor.init_processor(self, window.global_scope)  # node has a processor for calculation

        self.editor_size = size

        if connects:
            self.connected_to = connects

        self.code = None
        if not code:
            sub_pass = pkg_resources.resource_filename('pyno', 'examples/sub_pass.pn')
            code = sub_pass  # identical to '''examples/blank.pn'''

        self.name = ''
        self.label = pyglet.text.Label(self.name, font_name=font,
                                       bold=True, font_size=11,
                                       anchor_x='center', anchor_y='center',
                                       batch=batch, group=labelsGroup,
                                       color=(255, 255, 255, 230))
        self.pwindow = None
        self.input_nodes = {}
        self.output_nodes = {}
        self.new_code(code)
github honix / Pyno / pyno / window.py View on Github external
def new_batch(self):
        self.batch = pyglet.graphics.Batch()
        self.info_label = pyglet.text.Label('BOOM!!', font_name=font,
                                            font_size=9, batch=self.batch,
                                            color=(200, 200, 255, 100),
                                            x=160, y=10, group=draw.uiGroup)
        # load pyno-logo in left bottom
        corner = pkg_resources.resource_stream('pyno', 'imgs/corner.png')
        pyno_logo_img = pyglet.image.load('dummyname', file=corner)
        self.pyno_logo = pyglet.sprite.Sprite(pyno_logo_img,
                                              batch=self.batch,
                                              group=draw.uiGroup)
        self.menu = menu.Menu(self)
        # line place-holder
        self.line = (draw.Line(self.batch), draw.Line(self.batch))