justinpenner / TalkingLeaves

A GlyphsApp plugin to help you explore the world’s languages and writing systems
MIT License
26 stars 2 forks source link

crash #19

Closed justanotherfoundry closed 3 months ago

justanotherfoundry commented 3 months ago

The Plugin TalkingLeaves.glyphsPlugin has caused a crash. Please update it by opening the Plugin Manager or re-downloading it from the original source.

Details: Traceback (most recent call last):

File "plugin.py", line 48, in openWindow_ self.tl = TalkingLeaves() ^^^^^^^^^^^^^^^

File "TalkingLeaves.py", line 79, in init if Glyphs.devMode: ^^^^^^^^^^^^^^

AttributeError: 'NSKVONotifying_GSApplication' object has no attribute 'devMode'

App:3.3-3309 Plugin:0.1-2 System:14.5.0

justinpenner commented 3 months ago

Thanks, I just fixed this in 79f1ee1. Silly mistake, as the Glyphs.devMode property obviously doesn't exist outside of dev mode, so I fixed it by using getattr().

Also, @justanotherfoundry as a plugin developer you might find some useful ideas in the dev folder. I've been looking for ways to test Glyphs plugins without restarting Glyphs after each change, and have found two useful ways to do it:

  1. Put only the code related to loading the plugin class and adding it to the menu bar in plugin.py, and everything else into TalkingLeaves.py which is set up to be loaded as a module or run as a script from the Script menu. So instead of restarting Glyphs after each change, you just close the TalkingLeaves window and then Cmd-Opt-R to run the updated script.
  2. Use executeVanillaTest to wrap TalkingLeaves into a mini application that can run from Terminal. I used glyphsLib to load a .glyphs file into a GSFont object, and then I wrote a "fake" GlyphsApp module that minimally replicates the parts of the API that TalkingLeaves uses.
justanotherfoundry commented 3 months ago

Thanks for the fix!

justanotherfoundry commented 3 months ago

Regarding the testing-without-restarting: Why isn’t TalkingLeaves simply implemented as a plain script?

justinpenner commented 3 months ago

It definitely could be just a script, but I think users have different expectations for a script versus a plugin. So I guess it's about branding, mainly. Plugin implies a larger and/or more useful project, more support from the developer, etc. A plugin is also neatly packaged and easier to install, with a more consistent presence somewhere in the app (in the Window menu in this case).

Also, from a development perspective, the majority of the code is in one file right now, but it's getting quite long and unwieldy to navigate the code. So I'll be dividing it into modules soon, which makes a lot more sense to do inside of a plugin bundle as opposed to a folder of scripts.