Skip to content

Can't create a glyphLineView: getting "variable referenced before assigment" error #36

@RafalBuchner

Description

@RafalBuchner

Hi, I don't know what exactly I'm doing wrong.
In the code below I'm trying to create a glyphLineView

from defcon import Font
from defconAppKit.controls.glyphLineView import GlyphLineView
from defconAppKit.controls.glyphSequenceEditText import GlyphSequenceEditText
from vanilla import Window, Slider
class Demo:

    def __init__(self):
        self.font = Font("some/path/to/ufo")
        x,y,p,btnH,txtH = 10, 10, 10,22,17
        try:
            self.w = Window((200, 200), "Demo", minSize=(100, 100))
            self.w.lineViewSizeSlider = Slider((x, y, -p, btnH), minValue=10, maxValue=500, value=100,
            continuous=True, callback=self.lineViewResize)
            y += p + btnH
            self.w.textInput = GlyphSequenceEditText((x, y, -p, btnH), self.font, callback=self.lineViewTextInput)
            y += p + btnH
            self.w.testView = GlyphLineView((x, y, -p, -p))
            self.w.testView.setShowLayers(True)
            self.w.testView.setPointSize(200)
            self.w.open()
        except:
                # Error. Print exception.
                import traceback
                print(traceback.format_exc())

    def lineViewTextInput(self, sender):
        try:
            glyphs = sender.get()
            self.w.testView.set(glyphs)
        except:
                # Error. Print exception.
                import traceback
                print(traceback.format_exc())
    def lineViewResize(self, sender):
        self.w.testView.setPointSize(sender.get())


# Demo()
if __name__ == "__main__":
    from vanilla.test.testTools import executeVanillaTest
    executeVanillaTest(Demo)

This is the output that I'm getting whenever I'm trying to write something using GlyphSequenceEditText instance.

local variable 'strokeColor' referenced before assignment

Any idea what am I doing wrong?
Best
R

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions