'GSApplication' object has no attribute 'redraw'

The documentation promises

Redraws all Edit views and Preview views.


> Glyphs.redraw()
Traceback (most recent call last):
  File "<string>", line 1, in <module>
AttributeError: 'GSApplication' object has no attribute 'redraw'

I ended up doing this, but it’s a bit ugly:

NSNotificationCenter.defaultCenter().postNotificationName_object_("GSRedrawEditView", None)

What version do you have? This is only available in the latest cutting edge version.

Well, I want to write plugins that work for both cutting-edge and released versions… Right now I am doing:

if Glyphs.redraw:
  NSNotificationCenter.defaultCenter().postNotificationName_object_("GSRedrawEditView", None)

but it does not always seem to be redrawing correctly. (See @monokano’s bug 1 in Reloading a font from disk)

GSApplication & handleSize in Objective-C:

How can I access the handleSize?

I tried:

@interface GSApplication : NSApplication
- (NSInteger) handleSize; // also tried @property ...

GSApplication *Glyphs = [NSApplication sharedApplication];
NSInteger handleSizeIndex = [Glyphs handleSize]; 

But it logs:
-[GSApplication handleSize]: unrecognized selector sent to instance

Thought I know my ways through Objective-C, but some things still baffle me :slight_smile:

NSUserDefaults *Defaults = [NSUserDefaults standardUserDefaults];
[Defaults setInteger:0|1|2 forKey:@"GSHandleSize"]

Is a convenient method in the python wrapper. Have a look there what it is doing. Most stuff on Glyphs in python is like that.

Thank you!

I cannot get Glyphs.handleSize in Objective-C, because it doesn’t know what Glyphs is. :confused: That’s why I tried to declare the GSApplication and the handleSize property/method (?).

I don’t want to set the handleSize, but read it. So I guess I’ll just get it with [[NSUserDefaults standardUserDefaults] objectForKey:@"GSHandleSize"]

There is a special method [[NSUserDefaults standardUserDefaults] integerForKey:@""].

1 Like

Thank you!

and as I said, all the Glyphs. methods are mostly for convenience. Have a look at the wrapper (__init__.py) what they do internally.

I see, yes, I always look into the __init__, it just didn’t occur to me to make the connection from the python Glyphs.handleSize to the objective-c pendant. but now I got the curve. Thank you!