Palette plugin > Traceback


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 "", line 16, in <module>
  File "", line 14, in _run
    exec(compile(source, path, 'exec'), globals(), globals())
  File "/Users/ricardgarcia/Library/Application Support/Glyphs/Plugins/CaseChanger.glyphsPalette/Contents/Resources/", line 29 = 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 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.

Any idea what is happening?

Thank you so much for any provided help!

The last line in the error message has a wrong indentation. Maybe you have mixed spaces and tabs?

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:

The you need to show more of the code surrounding the error line.

1 Like

Ops! Just edited the previous reply with a screenshot.

can you post the line 27-30 as code?

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/", line 909, in init
  File "", line 29, in settings = Button((10, -60, width, 20), "Uppercase", callback=self.upperCallback)
AttributeError: 'CaseChanger' object has no attribute 'upperCallback'

The class doesn’t seem to have a upperCallback function. Try to read the error messages a few times. It tells you the problem quite clearly :wink:

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?

Have you converted the whole file to tabs?

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.

You should get to the font by font = self.windowController().document().font

1 Like

I might need more time reading SDK and knowing where to put every item. I’ve now placed this line of code in the 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.

Thanks again for all of your time, Georg.

@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.

Again thank you so so much for your patience.

The plugin manager is driven by this repository:
So put your plugin in a git repo, for the glyphs-packages repo, add your plugin and send a pull request.

See also the last parts of the Writing Plug-ins tutorial:

1 Like