from mojo.UI import *
Classes
- AccordionView(posSize, descriptions, backgroundColor)
A vanilla object hosting different kinds of other vanilla objects (like vanilla.List, vanilla.TextEditor, ....) in an accordion view.
Initiate a AccordionView
posSize: a tuple of four, setting the size
descriptions: list of options for each item in the accordionView (see example)
backgroundColor: a NSColor object used as background color
from mojo.UI import AccordionView from vanilla import * class MyInspector: def __init__(self): self.w = FloatingWindow((200, 600)) self.firstItem = TextEditor((10, 10, -10, -10)) self.secondItem = List((0, 0, -0, -0), ["a", "b", "c"]) self.thirdItem = Tabs((10, 10, -10, -10), ["1", "2", "3"]) self.fourthItem = Group((0, 0, -0, -0)) self.fourthItem.checkBox = CheckBox((10, 10, 100, 22), "CheckBox") self.fourthItem.editText = EditText((10, 40, -10, 22)) descriptions = [ dict(label="first item", view=self.firstItem, size=200, collapsed=False, canResize=False), dict(label="second item", view=self.secondItem, minSize=100, size=140, collapsed=True, canResize=True), dict(label="third item", view=self.thirdItem, minSize=100, size=140, collapsed=True, canResize=False), dict(label="fourth item", view=self.fourthItem, size=140, collapsed=False, canResize=False) ] self.w.accordionView = AccordionView((0, 0, -0, -0), descriptions) self.w.open() MyInspector()
- HTMLView(posSize)
Initiate a HTMLView
posSize: a tuple of four, setting the size
setHTMLPath(url)
Set the url in the HTMLView
goBack()
Go forward in the history of the HTMLView
goForward()
Go forward in the history of the HTMLView
clearHistory()
Clear the history of the HTMLView - HelpWindow(htmlPath, title="help", developer=None, developerURL=None)
Initiate a HelpWindow
htmlPath: html help path
title: title of the help window
developer: a string with the name of the developer, optionally
developerURL: a URL link to the developer, optionally
set(htmlPath)
set a html path in the HTMLView of the HelpWindow
from mojo.UI import HelpWindow HelpWindow("http://robofont.com")
- SmartSet(smartSet=dict())
Initiate a smart set object
smartSet: a dictionary containing smart set data
name
Set or get the smart set name.
glyphNames
Set or get the a list of glyph names used by the smart set.
query
Set or get a search query. - MultiLineView(posSize, pointSize=150, lineHeight=50, doubleClickCallbak=None, applyKerning=None, bordered=False, hasHorizontalScroller=False, hasVerticalScroller=True, displayOptions=None, selectionCallback=None, menuForEventCallback=None)
A multi glyph line view vanilla object, this is the same objects that is used to build a Space Center.
Initiate a multi line view object:
posSize: a tuple of four, setting the size
pointSize: the initial point size, optionally
lineHeight: the initial lineHeight, , optionally
doubleClickCallback: callback for a double click event
applyKerning: enable kerning the view, optionally
bordered: set a border around the view
hasHorizontalScroller: set the horizontal scroller
hasVerticalScroller: set the vertical scroller
displayOptions: a dict with multi line view display options
selectionCallback: callback when a glyph get selected
menuForEventCallback: callback when a contextual menu will we used, required to return a NSMenu object
get()
Returns all glyphs in the line view
set(glyphs)
Sets a list of glyphs in the line view
setFont(font)
The glyph line view needs a font as fallback and for font metrics
createNewLineGlyph()
Returns a special glyph object that acts like a new line
createEmptyGlyph(name)
Returns a special glyph object that acts like an empty glyph (use this as fallback when a glyph is not in the font)
setPointSize(pointSize)
Sets the point size
setLineHeight(lineHeight)
Sets the line height
setApplyKerning(value)
Sets if kerning is applied in the line view
getDisplayStates()
Returns a dict with all display options
setDisplayStates(options)
Sets a dict of line view display options
setLeftToRight(value)
Sets the reading direction of the glyph line view
from mojo.UI import MultiLineView from vanilla import * class MyOwnSpaceCenter: def __init__(self, font): self.w = Window((600, 400), minSize=(300, 300)) self.w.lineView = MultiLineView((0, 0, -0, -0), pointSize=30, selectionCallback=self.lineViewSelectionCallback) self.w.lineView.setFont(font) glyphs = [] for glyphName in font.glyphOrder: glyphs.append(font[glyphName]) self.w.lineView.set(glyphs) self.w.open() def lineViewSelectionCallback(self, sender): print sender.getSelectedGlyph() MyOwnSpaceCenter(CurrentFont())
Methods
- GlyphViewDisplaySettings(settings)
Set display options for the current glyphview. Input as dict. These settings will be default for the glyphview. All options are: Fill, Stroke, Metrics, On Curve Points, Off Curve Points, Point Coordinates, Anchors, Curve Length, Blues, Family Blues, Rulers - AllSpaceCenters()
Get all open space centers - CurrentSpaceCenter()
methods:
get()
returns a list of glyph names in the space center
getRaw()
returns a string from the input of the space center
set(glyphNames)
sets the list of glyphNames in the space center
setRaw(text)
set a string in to the main input of the space center
getTracking()
returns the tracking used
setTracking(value)
set a tracking value between the glyphs
getLeftToRight()
returns the reading direction
setLeftToRight(value)
sets the reading direction
getPointSize()
returns the point size
setPointSize(value)
sets the points size - SpaceCenterToPDF(path, spaceCenter=None)
Saves the Space Center to a pdf with vector data, if a spaceCenter is not provided the CurrentSpaceCenter() will be used. - AllGlyphWindows()
Returns all open glyph windows. - CurrentGlyphWindow()
Returns the current glyph window. - GlyphWindowToPDF(path, glyphWindow=None)
Saves the Glyph Window to a pdf with vector data, if a Glyph Window is not provided the CurrentGlyphWindow() will be used. - AllFontWindows()
Returns all open font windows. - CurrentFontWindow()
Returns the current font window. - OpenGlyphWindow(glyph=None, newWindow=False)
Opens a new glyph window
glyph: a given glyph object
newWindow: open a new window, even if there is already a glyph window open - OpenSpaceCenter(font, newWindow=False)
Opens a new Space Center
font: a given font object
newWindow: open a new window, even if there is already a Space Center winow open - OutputWindow()
Returns the output window
write(text)
Write a string in the output window
clear()
Clears the output window - SetCurrentGlyphByName(glyphName)
Sets a glyph name in the current glyph editor - SetCurrentLayerByName(layerName)
Sets the current layer by a layerName in the current glyph editor - UpdateCurrentGlyphView()
Updates the current glyph editor - SetCurrentLayerByName(layerName)
Sets the current layer by layer name - addSmartSet(smartSet, index=-1)
Add a smart set object.
Optionally set an index to insert the smart set object. - removeSmartSet(smartSetName)
Remove a smart set. - getSmartSets()
Get all current smart sets. - setSmartSets(smartSets)
Set a list of smart sets. - setDefaultCharacterSet(characterSetName)
Set the default character set by name as defined in the preferences. - getDefaultCharacterSet()
Get the current default character set name. - addCharacterSet(characterSetName, glyphNames, useAsDefault=False)
Add a character set with a name and a list of glyph names. - removeCharacterSet(characterSetName)
Remove a character set by name. - getCharacterSets()
Get all characeter sets as a dictionairy. - setCharacterSets(characterSets)
Set a dictionary of character sets. - setMaxAmountOfVisibleTools(value)
Set the maximum amount of visible tools in the toolbar.
Must be in integer. - getMaxAmountOfVisibleTools()
Get the maximum amount of visible tools in the toolbar. - setScriptingMenuNamingShortKey()
Get the scripting menu names and shortkey dictionary. - getScriptingMenuNamingShortKey(data)
Set a scripting menu names and shortkey dictionary. - setScriptingMenuNamingShortKeyForPath(path, preferredName, shortkey=None)
Set the scripting menu names and shortkey dictionary. - exportPreferences(path)
Export all user preferences to a path. - importPreferences(path)
Import user preferences from a path.