本文整理汇总了Python中mojo.extensions.getExtensionDefault函数的典型用法代码示例。如果您正苦于以下问题:Python getExtensionDefault函数的具体用法?Python getExtensionDefault怎么用?Python getExtensionDefault使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getExtensionDefault函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, constructions, font, parentWindow):
self.font = font
self.constructions = constructions
self.w = Sheet((300, 120), parentWindow=parentWindow)
getExtensionDefault, setExtensionDefault, getExtensionDefaultColor, setExtensionDefaultColor
y = 15
self.w.overWrite = CheckBox((15, y, 200, 22), "Overwrite Existing Glyphs", value=getExtensionDefault(self.overWriteKey, True))
y += 35
self.w.markGlyphs = CheckBox((15, y, 200, 22), "Mark Glyphs", value=getExtensionDefault(self.overWriteKey, True), callback=self.markGlyphsCallback)
self.w.markGlyphColor = ColorWell((130, y-5, 50, 30), color=getExtensionDefaultColor(self.markColorKey, NSColor.redColor()))
self.w.markGlyphColor.enable(getExtensionDefault(self.overWriteKey, True))
self.w.okButton = Button((-70, -30, -15, 20), "Build", callback=self.buildCallback, sizeStyle="small")
self.w.setDefaultButton(self.w.okButton)
self.w.closeButton = Button((-140, -30, -80, 20), "Cancel", callback=self.closeCallback, sizeStyle="small")
self.w.closeButton.bind(".", ["command"])
self.w.closeButton.bind(unichr(27), [])
self.w.open()
示例2: __init__
def __init__(self, parentWindow):
data = getExtensionDefault(self.identifier, dict())
self.w = Sheet((470, 580), parentWindow=parentWindow)
self.w.tabs = Tabs((10, 10, -10, -40), ["TTF AutoHint", "HTML Preview"])
self.w.tabs[0].settings = self.settings = TTFAutoHintGroup((0, 0, -0, -0))
self.settings.set(data)
y = 10
self.w.tabs[1].htmlText = TextBox((10, y, 100, 22), "HTML preview:")
y += 30
self.w.tabs[1].html = self.html = CodeEditor((10, y, -10, 250), getExtensionDefault("%s.htmlPreview" % settingsIdentifier, htmlPreviewDefault), lexer="html")
self.html.showLineNumbers(False)
y += 260
self.w.tabs[1].globalCssText = TextBox((10, y, 100, 22), "CSS Style:")
y += 30
self.w.tabs[1].globalCss = self.globalCss = CodeEditor((10, y, -10, -10), getExtensionDefault("%s.globalCSSPreview" % settingsIdentifier, ""), lexer="css")
self.globalCss.showLineNumbers(False)
self.w.saveButton = Button((-100, -30, -10, 20), "Save settings", callback=self.saveCallback, sizeStyle="small")
self.w.setDefaultButton(self.w.saveButton)
self.w.closeButton = Button((-190, -30, -110, 20), "Cancel", callback=self.closeCallback, sizeStyle="small")
self.w.closeButton.bind(".", ["command"])
self.w.closeButton.bind(unichr(27), [])
self.w.resetButton = Button((-280, -30, -200, 20), "Reset", callback=self.resetCallback, sizeStyle="small")
self.w.open()
示例3: __init__
def __init__(self):
self.w = FloatingWindow((220, 240), "2 Twitter")
left = 100
y = 10
userName = getExtensionDefault("%s.%s" %(defaultKey, "userName"), "")
password = getExtensionDefault("%s.%s" %(defaultKey, "password"), "")
self.w.userNameText = TextBox((10, y, left, 22), "User name:")
self.w.userName = EditText((left, y, -10, 22), userName)
y += 30
self.w.passwordText = TextBox((10, y, left, 22), "Password:")
self.w.password = SecureEditText((left, y, -10, 22), password)
y += 30
self.w.message = TextEditor((10, y, -10, 70), callback=self._textEditorCallback)
y += 80
self._viewNames = ["Glyph View", "Space Center"]
self.w.view = RadioGroup((10, y, -10, -40), self._viewNames)
self.w.view.set(0)
self.w.okButton = Button((-70, -30, -15, 20), "Post", callback=self.okCallback, sizeStyle="small")
self.w.setDefaultButton(self.w.okButton)
self.w.closeButton = Button((-140, -30, -80, 20), "Cancel", callback=self.closeCallback, sizeStyle="small")
self.w.closeButton.bind(".", ["command"])
self.w.closeButton.bind(unichr(27), [])
self.w.open()
示例4: load
def load(self):
self.onOff = getExtensionDefault(onOffKey, self._fallbackOnOff)
self.lineWidth = getExtensionDefault(lineWidthKey, self._fallbackStrokeWidth)
self.lineColor = getExtensionDefaultColor(lineColorKey, self._fallbackStrokeColor)
self.fillColor = getExtensionDefaultColor(fillColorKey, self._fallbackFillColor)
self.lineRGBA = getExtensionDefault(lineRGBA, self._fallbackStrokeRGBA)
self.fillRGBA = getExtensionDefault(fillRGBA, self._fallbackFillRGBA)
示例5: __init__
def __init__(self):
addObserver(self, "_curvePreview", "draw")
addObserver(self, "_curvePreview", "drawInactive")
addObserver(self, "_currentGlyphChanged", "currentGlyphChanged")
self.methods = {
0: "fl",
4: "free",
}
self.methodNames = [
"Tension:"
]
height = 80
self.w = vanilla.FloatingWindow((300, height), "Hobby's Spline")
y = -200
self.w.hobbyMethodSelector = vanilla.RadioGroup((10, y, -10, 108),
titles = "Circle",
callback=self._changeMethod,
sizeStyle="small"
)
y = 10
self.w.HobbySlider = Slider((15, y, -15, 25),
tickMarkCount=4,
callback=self._changetension,
minValue=0.5,
maxValue=1.0,
sizeStyle="small",
continuous=True
)
y = height - 32
self.w.hobbycurveButton = vanilla.Button((60, y , -60, 25), "transform selected curves",
callback=self._hobbycurve,
sizeStyle="small",
)
self.w.hobbyMethodSelector.set(getExtensionDefault("%s.%s" %(extensionID, "method"), 0))
self.method = self.methods[self.w.hobbyMethodSelector.get()]
self._checkSecondarySelectors()
self.w.HobbySlider.set(getExtensionDefault("%s.%s" %(extensionID, "tension"), 0.5))
self.tension = self.w.HobbySlider.get()
self.tmp_glyph = RGlyph()
UpdateCurrentGlyphView()
self.setUpBaseWindowBehavior()
self.w.open()
示例6: run
def run(self, destDir, progress):
progress.update("Converting...")
paths = self.controller.get()
report = Report()
report.css = CSSWriter()
report.html = HTMLWriter(cssFileName="font.css", style=getExtensionDefault("%s.globalCSSPreview" % settingsIdentifier, ""))
report.writeTitle("Web Fonts:")
report.newLine()
saveOTF = self.save_otf.get()
saveTTF = self.save_ttf.get()
saveWOFF = self.save_woff.get()
saveWOFFFormat = self.save_woff_format.get()
saveWOFF2 = self.save_woff2.get()
saveWOFF2Format = self.save_woff2_format.get()
saveEOT = self.save_eot.get()
saveSVG = self.save_svg.get()
suffix = self.webSuffix.get()
suffix = time.strftime(suffix)
preserveTTFhints = self.preserveTTFhints.get()
progress.setTickCount(len(paths))
for path in paths:
txt = os.path.basename(path)
progress.update(txt)
report.writeTitle(os.path.basename(path), "-")
report.write("source: %s" % path)
report.newLine()
try:
self._convertPath(path, destDir=destDir, saveOTF=saveOTF, saveTTF=saveTTF, saveWOFF=saveWOFF, saveWOFFFormat=saveWOFFFormat, saveWOFF2=saveWOFF2, saveWOFF2Format=saveWOFF2Format, saveEOT=saveEOT, saveSVG=saveSVG, suffix=suffix, report=report, preserveTTFhints=preserveTTFhints)
except:
import traceback
message = traceback.format_exc()
report.write("Failed:")
report.write(message)
report.indent(0)
report.newLine()
report.newLine()
report.writeTitle("TTFAutohint options:")
autohintOptions = getExtensionDefault(settingsIdentifier, defaultOptions)
report.writeDict(autohintOptions)
reportPath = os.path.join(destDir, "WebFonts Report.txt")
report.save(reportPath)
if self.generateHTML.get():
cssPath = os.path.join(destDir, "font.css")
report.css.save(cssPath)
htmlPath = os.path.join(destDir, "preview.html")
report.html.save(htmlPath)
示例7: __init__
def __init__(self):
self.filters = PenBallFiltersManager()
# self.filters.loadFiltersFromJSON('/'.join([LOCALPATH, JSONFILE]))
filtersList = getExtensionDefault('{0}.filtersList'.format(PENBALLWIZARD_EXTENSIONKEY), [])
self.filters.loadFiltersList(filtersList)
self.glyphNames = []
self.observedGlyphs = []
self.currentFont = CurrentFont()
self.initCachedFont()
filtersList = self.filters.keys()
if len(filtersList) > 0:
self.currentFilterName = filtersList[0]
else:
self.currentFilterName = None
self.fill = True
self.observers = [
('fontChanged', 'fontBecameCurrent'),
('fontChanged', 'fontDidOpen'),
('fontChanged', 'fontDidClose'),
]
self.displaySettingsRecord = {
1: (u'✓ Fill', True),
2: (u'Stroke', False),
3: (u'Inverse', False),
}
self.w = Window((100, 100, 800, 500), 'PenBall Wizard v{0}'.format(__version__), minSize=(500, 400))
self.w.filtersPanel = Group((0, 0, 300, -0))
self.w.filtersPanel.filtersList = List((0, 0, -0, -80), filtersList, selectionCallback=self.filterSelectionChanged, doubleClickCallback=self.filterEdit, allowsMultipleSelection=False, allowsEmptySelection=False, rowHeight=22)
self.w.filtersPanel.controls = Group((0, -80, -0, 0))
self.w.filtersPanel.addFilter = SquareButton((0, -80, 100, 40), 'Add filter', sizeStyle='small', callback=self.addFilter)
self.w.filtersPanel.addFilterChain = SquareButton((100, -80, 100, 40), 'Add operations', sizeStyle='small', callback=self.addFilterChain)
self.w.filtersPanel.removeFilter = SquareButton((-100, -80, 100, 40), 'Remove filter', sizeStyle='small', callback=self.removeFilter)
self.w.textInput = EditText((300, 0, -75, 22), '', callback=self.stringInput)
self.w.generate = SquareButton((0, -40, 300, -0), 'Generate', callback=self.buildGenerationSheet, sizeStyle='small')
self.w.displaySettings = PopUpButton(
(-70, 3, -10, 15),
self.makeDisplaySettingsMenuItems(),
sizeStyle='mini',
callback=self.changeDisplaySettings)
self.w.displaySettings.getNSPopUpButton().setPullsDown_(True)
self.w.displaySettings.getNSPopUpButton().setBordered_(False)
self.w.preview = MultiLineView((300, 22, -0, -0))
displayStates = self.w.preview.getDisplayStates()
for key in ['Show Metrics','Upside Down','Stroke','Beam','Inverse','Water Fall','Multi Line']:
displayStates[key] = False
for key in ['Fill','Single Line']:
displayStates[key] = True
self.w.preview.setDisplayStates(displayStates)
for callback, event in self.observers:
addObserver(self, callback, event)
self.updateControls()
self.w.bind('close', self.end)
self.launchWindow()
self.w.open()
示例8: generate
def generate(self, saveDir):
if not saveDir:
return
saveDir = saveDir[0]
f = self.font.naked()
glyphs = [g for g in f if not g.template]
progress = ProgressWindow("Generating .png's", tickCount=len(glyphs), parentWindow=self.window)
gridSize = int(getExtensionDefault(GRID_DEFAULTS_KEY, 50))
for g in glyphs:
if g.unicode is not None:
fileName = "%04X" %g.unicode
else:
fileName = glyphNameToFileName(g.name, f)
path = os.path.join(saveDir, "%s.png" %fileName)
image = g.getRepresentation("com.typemytype.pixelImageFactory", gridSize=gridSize)
data = image.TIFFRepresentation()
imageRep = NSBitmapImageRep.imageRepWithData_(data)
pngData = imageRep.representationUsingType_properties_(NSPNGFileType, None)
pngData.writeToFile_atomically_(path, False)
progress.update()
progress.close()
示例9: _getTempTTF
def _getTempTTF(self, path, report=None, preserveTTFhints=False):
if not hasattr(self, "_tempTTFPath"):
_, ext = os.path.splitext(path)
ext = ext.lower()
self._tempTTFPath = tempfile.mkstemp(suffix=".ttf")[1]
if ext == ".otf":
report.write("Source is binary a OTF file. Convert to TTF.")
report.indent()
convertToTTF(path, self._tempTTFPath, report)
report.dedent()
elif ext == ".ttf":
report.write("Source is binary a TTF file.")
shutil.copyfile(path, self._tempTTFPath)
if not preserveTTFhints:
report.write("Auto hint the existing TTF file.")
report.indent()
tempDest = tempfile.mkstemp(suffix=".ttf")[1]
autohintOptions = getExtensionDefault(settingsIdentifier, defaultOptions)
result = TTFAutohint(self._tempTTFPath, tempDest, autohintOptions)
report.writeItems(result)
os.remove(self._tempTTFPath)
self._tempTTFPath = tempDest
report.dedent()
else:
if ext == ".ufo":
report.write("Source is a UFO file. Generate TTF.")
else:
report.write("Source is a %s file. Import the file. Generate TTF." % (ext[1:]))
report.indent()
generateTTF(path, self._tempTTFPath, report)
report.dedent()
return self._tempTTFPath
示例10: __init__
def __init__(self, parentWindow):
data = getExtensionDefault(self.identifier, dict())
updateWithDefaultValues(data, defaultOptions)
width = 380
height = 1000
self.w = Sheet((width, height), parentWindow=parentWindow)
y = 10
self.w.threaded = CheckBox((10, y, -10, 22), "Threaded", value=data["threaded"])
y += 30
self.w.exportInFolders = CheckBox((10, y, -10, 22), "Export in Sub Folders", value=data["exportInFolders"])
y += 30
self.w.keepFileNames = CheckBox((10, y, -10, 22), "Keep file names (otherwise use familyName-styleName)", value=data["keepFileNames"])
y += 35
self.w.saveButton = Button((-100, y, -10, 20), "Save settings", callback=self.saveCallback, sizeStyle="small")
self.w.setDefaultButton(self.w.saveButton)
self.w.closeButton = Button((-190, y, -110, 20), "Cancel", callback=self.closeCallback, sizeStyle="small")
self.w.closeButton.bind(".", ["command"])
self.w.closeButton.bind(unichr(27), [])
self.w.resetButton = Button((-280, y, -200, 20), "Reset", callback=self.resetCallback, sizeStyle="small")
y += 30
self.w.resize(width, y, False)
self.w.open()
示例11: __init__
def __init__(self):
self.draw = False
self.swap = True
self.radius = getExtensionDefault(
"%s.%s" % (WurstSchreiberDefaultKey, "radius"), 60)
color = NSColor.colorWithCalibratedRed_green_blue_alpha_(1, 0, 0, .5)
colorValue = getExtensionDefaultColor(
"%s.%s" % (WurstSchreiberDefaultKey, "color"), color)
self.w = FloatingWindow((150, 170), "WurstSchreiber")
x = 15
y = 15
self.w.preview = CheckBox(
(x, y, -x, 20),
"Preview",
callback=self.previewChanged,
value=True)
y+=30
self.w.slider = SliderGroup(
(x, y, -x, 22), 0, 100, self.radius, callback=self.sliderChanged)
y+=35
self.w.color = ColorWell(
(x, y, -x, 40), callback=self.colorChanged, color=colorValue)
y+=55
self.w.button = Button(
(x, y, -x, 20), "Trace!", callback=self.traceButton)
addObserver(self, "drawWurst", "drawBackground")
self.w.bind("close", self.closing)
self.w.open()
示例12: openWindow
def openWindow(self, sender=None):
""" Initialize the input window. """
presets = [
"case", "dnom", "fina", "hist", "init", "isol", "locl", "lnum", "medi", "numr", "onum", "ordn", "tnum",
"pcap", "salt", "sinf", "smcp", "ss01", "ss02", "ss03", "ss04", "ss05", "ss06", "ss07", "ss08",
"ss09", "ss10", "ss11", "ss12", "ss13", "ss14", "ss15", "ss16", "ss17", "ss18", "ss19", "ss20",
"subs", "sups", "swsh", "titl", "zero" ]
presetList = " ".join(presets)
registerExtensionDefaults({"nl.typologic.suffixer.presetSuffixes" : presetList})
currentPresets = getExtensionDefault("nl.typologic.suffixer.presetSuffixes").split()
self.f = CurrentFont()
if self.f is None:
print "Suffixer: No font open"
return
existingSuffixes = []
for g in self.f:
suf = self._findSuffix(g.name)
if suf != None and suf not in existingSuffixes:
existingSuffixes.append(suf)
existingSuffixes.sort()
currentSuffix = ""
if CurrentGlyph() is not None:
currentSuffix = self._findSuffix(CurrentGlyph().name)
elif self.f.selection is not None:
for gn in self.f.selection:
currentSuffix = self._findSuffix(gn)
if currentSuffix != None:
break
self.w = FloatingWindow((300, 166), "Suffixer")
p = 10
h = 20
y1, y2, y3, y4 = 15, 49, 82, 135
w1, x2 = 160, 180
self.w.labelTwo = TextBox((p, y1, w1, h), "Add suffix to glyph names:")
self.w.dotTwo = TextBox((x2, y1, 15, h), ".")
self.w.newSuffix = ComboBox((x2+p, y1, -p, h), currentPresets)
self.w.replace = CheckBox((p+2, y2, w1, h), "Replace existing suffix:", callback=self.replaceCheckCallback)
self.w.dotOne = TextBox((x2, y2, 15, h), ".")
self.w.oldSuffix = PopUpButton((x2+p, y2, -p, h), existingSuffixes)
if currentSuffix != "" and currentSuffix != None:
self.w.oldSuffix.set(existingSuffixes.index(currentSuffix))
self.w.scope = RadioGroup((p, y3, -p, h*2), ["Target selected glyphs", "Replace all in current font"], isVertical=True)
self.w.scope.set(0)
currentState = 0 if currentSuffix == "" or currentSuffix == None else 1
self.w.replace.set(currentState)
self.w.scope.enable(currentState)
self.w.submit = Button((p, y4, -p, h), "Change suffixes", callback=self.replaceSuffixes)
self.w.setDefaultButton(self.w.submit)
self.w.open()
self.w.makeKey()
示例13: get_defaults
def get_defaults(self):
otf_1 = getExtensionDefault('%s.otf_1' % self.extension_key, None)
otf_2 = getExtensionDefault('%s.otf_2' % self.extension_key, None)
folder = getExtensionDefault('%s.folder' % self.extension_key, None)
if otf_1 is not None and os.path.exists(otf_1):
self.otf_1 = otf_1
self.w.otf_1_status.set('%s' % unichr(10003))
if otf_2 is not None and os.path.exists(otf_2):
self.otf_2 = otf_2
self.w.otf_2_status.set('%s' % unichr(10003))
if folder is not None and os.path.exists(folder):
self.folder = folder
self.w.folder_status.set('%s' % unichr(10003))
示例14: __init__
def __init__(self):
self.w = Window((250, 45), "DrawBot Settings")
self.w.openPythonFilesInDrawBot = CheckBox((10, 10, -10, 22), "Open .py files directly in DrawBot.",
value=getExtensionDefault("com.drawBot.openPyFileDirectly", False),
callback=self.openPythonFilesInDrawBotCallback)
self.w.open()
示例15: openFile
def openFile(self, notification):
if getExtensionDefault("com.drawBot.openPyFileDirectly", False):
fileHandler = notification["fileHandler"]
path = notification["path"]
_, ext = os.path.splitext(path)
if ext.lower() == ".py":
DrawBotController().open(path)
fileHandler["opened"] = True