As I wrote some weeks ago, I’m on my way to do my first plugin (a palette one), the idea is to bring a script with UI that I made that changes currentText to uppercase, lowercase or title with three different buttons. I’ve been reading and using the SDK python templates to do so and I think I’m really close to make it work. The point is that the three buttons are not appearing in the palette and the traceback error that is printed in the macro panel show this:
Traceback (most recent call last):
File "main.py", line 16, in <module>
_run('plugin.py')
File "main.py", line 14, in _run
exec(compile(source, path, 'exec'), globals(), globals())
File "/Users/ricardgarcia/Library/Application Support/Glyphs/Plugins/CaseChanger.glyphsPalette/Contents/Resources/plugin.py", line 29
self.paletteView.group.UCButton = Button((10, -60, width, 20), "Uppercase", callback=self.upperCallback)
^
IndentationError: unexpected indent
I’m not sure how to get information about this and even less what should I fix. Aparently there’s something in the main.py file but I’m not sure what is going on.
Also, probably the IndentationError at the bottom line is from the next problem printed but I wanted to show it just in case.
I checked and corrected the indentation using just tabs and still prints the same problem… I know it is not the best idea to show a screenshot but might help:
You were right, I put tab but the rest of the code was indented with spaces. Now the problem moved to another place (sorry for taking you patience with this but as soon as I understand this I will be able to build some other ideas by my own):
Traceback (most recent call last):
File "GlyphsApp/GlyphsApp/plugins.py", line 909, in init
File "plugin.py", line 29, in settings
self.paletteView.group.UCButton = Button((10, -60, width, 20), "Uppercase", callback=self.upperCallback)
AttributeError: 'CaseChanger' object has no attribute 'upperCallback'
Well, that’s the point. I read and understood the problem but if you look at the screenshot that I posted above there’s a callback function called upperCallback, should it be written different?
I did and it worked, thanks! Now the problem is how to refer the current font. When I click one of the buttons there’s this pop-up window refering to f as not defined. As a rookie, I defined f = Glyphs.font but obviously that’s not the way to refer the font.
I might need more time reading SDK and knowing where to put every item. I’ve now placed this line of code in the plugin.py file with if statements as the example in SDK but is not showing the menu anymore and there’s nothing printed in the macro panel.
@GeorgSeifert, thank you so much for your help. I’ve been reading carefully other examples of other plugins and I discovered what I was doing wrong! Now the plugin is 100% working and I know how to face similar type of plugins by my own.
Even though the idea of having a palette menu with three buttons that change the case in currentText is not very complex and started as a personal plugin I was wondering which is the process to end up publishing a plugin in the plug in manager. Just for future ideas, actually.
The plugin manager is driven by this repository: https://github.com/schriftgestalt/glyphs-packages
So put your plugin in a git repo, for the glyphs-packages repo, add your plugin and send a pull request.