Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
RafalBuchner opened this issue Nov 4, 2020 · 1 comment

Comments

@RafalBuchner
Copy link

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

@typemytype
Copy link
Member

mm I guess there have to first declared as None here

fillColor = self._glyphColor
strokeColor = self._strokeColor

could you make a PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants