AttributeError when using mac vanilla dialogs

38 views
Skip to first unread message

Cosimo Lupo

unread,
Sep 27, 2013, 7:00:24 AM9/27/13
to rob...@googlegroups.com
Whenever I call the Robofab dialogs module from a 'NoneLab' OSX environment, I get an AttributeError that traces back to "dialogs_mac_vanilla.py" and says that the (vanilla) module seemingly has no attribute 'dialogs'.

    >>> from robofab.interface.all.dialogs import GetFolder
    >>> print GetFolder()
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/Users/cosimolupo/Documents/robofab/trunk/Lib/robofab/interface/all/dialogs_mac_vanilla.py", line 168, in GetFolder
        result = vanilla.dialogs.getFolder(messageText=message, title=title, directory=directory, allowsMultipleSelection=allowsMultipleSelection)
    AttributeError: 'module' object has no attribute 'dialogs'

I am using Python 2.7.2 on a Mac with OSX 10.8.5, Robofab revision 599 from svn, and the latest vanilla package from typesupply's github repository.

The problem appears to be the fact that RoboFab (specifically,  dialogs_mac_vanilla.py) only does a global `import vanilla`, whereas vanilla's own __init__.py does not load the vanilla.dialogs module required by RoboFab to dispaly dialogs from within a Mac Python environment.

I could fix the error by appending `import vanilla.dialogs` to RF's dialogs_mac_vanilla.py.

Erik van Blokland

unread,
Sep 27, 2013, 10:10:54 AM9/27/13
to rob...@googlegroups.com
Hi Cosimo,

On 27 sep. 2013, at 13:00, Cosimo Lupo <cosim...@daltonmaag.com> wrote:

The problem appears to be the fact that RoboFab (specifically,  dialogs_mac_vanilla.py) only does a global `import vanilla`, whereas vanilla's own __init__.py does not load the vanilla.dialogs module required by RoboFab to dispaly dialogs from within a Mac Python environment.

I could fix the error by appending `import vanilla.dialogs` to RF's dialogs_mac_vanilla.py.

Cosimo Lupo

unread,
Sep 27, 2013, 10:23:43 AM9/27/13
to rob...@googlegroups.com
Well, that's good to know. I have no problem switching to git. 
I shall assume the github's RoboFab is by now "the current version".
Thanks for replying. 

Martin Wenzel

unread,
Oct 8, 2013, 7:12:18 AM10/8/13
to rob...@googlegroups.com
Hi there,

I've been trying to copy all anchors from one font to another but I always get stuck, getting a traceback:
AttributeError: can't set attribute

for g in srcFont:
srcG = g
trgtG = trgtFont[g.name]
if len(srcG.anchors) > 0 and srcG.name in trgtFont:
srcAnchors = srcG.anchors
trgtG.anchors = srcAnchors
print '# adding anchors to', g.name
trgtFont.update()

I guess I could figure it out if I would understand how to remove and add anchors. I tried to find information about that on http://www.robofab.org/objects/anchor.html but had no luck

Thanks,
Martin

Gustavo Ferreira

unread,
Oct 8, 2013, 7:34:22 AM10/8/13
to rob...@googlegroups.com
hi Martin,

have a look at the `transfer_anchors` function here:

https://github.com/gferreira/hTools2/blob/master/Lib/hTools2/modules/anchors.py

I think you're looking for `g.clearAnchors()` and `g.appendAnchor(name, (x, y))`.

hope that helps, Gustavo

Erik van Blokland

unread,
Oct 8, 2013, 7:48:43 AM10/8/13
to rob...@googlegroups.com

On 8 okt. 2013, at 13:12, Martin Wenzel <mar...@martinplus.com> wrote:

> Hi there,
>
> I've been trying to copy all anchors from one font to another but I always get stuck, getting a traceback:
> AttributeError: can't set attribute


srcFont = AllFonts().getFontsByFamilyName("Aaa")[0]
trgtFont = AllFonts().getFontsByFamilyName("Bbb")[0]
print srcFont
print trgtFont

for g in srcFont:
print g
if not g.name in trgtFont:
print "skip", g
continue
trgtG = trgtFont[g.name]
if len(g.anchors) > 0:
for a in g.anchors:
print a.position, a.name
trgtG.appendAnchor(a.name, a.position)

Martin Wenzel

unread,
Oct 8, 2013, 8:08:37 AM10/8/13
to rob...@googlegroups.com
Everyone,

Thanks for all your input, great help!
Erik, thanks for typing up a whole script.

These two are the ones I was looking for.
glyph.clearAnchors()
glyph.appendAnchor(name, (x,y))
> --
> --
> You received this message because you are subscribed to the Google Groups "RoboFab" group.
> To post to this group, send email to rob...@googlegroups.com
> To unsubscribe from this group, send email to robofab-u...@googlegroups.com
> For more options, visit this group at http://groups.google.com/group/robofab?hl=en
>
> Messages from newly joined members are subject to moderation.
> Download RoboFab and documentation at http://robofab.com
> ---
> You received this message because you are subscribed to the Google Groups "RoboFab" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to robofab+u...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.



- - - Communication and Type Design
- - - http://www.MartinPlus.com
phone +49 (0)30 88 72 79 70
mobile +49 (0)15 20 35 45 006

- - - Time for type but not for pizza?
http://www.MartinPlusFonts.com/pizza












Reply all
Reply to author
Forward
0 new messages