def __init__(self): self.pageScale = 0.1 # Scale the SVG so that glyphs aren't 1000 ps points in size self.bufferFactor = 3 # The scale of the buffer within the grid (1 = glyphs touch) self.fontList = [] self.fontNameList = [] if not HASDRAWBOT: self.w = vanilla.Window((300, 200), "Import/Export Art") self.w.title = vanilla.TextBox((10, 10, -10, 25), titleText) self.w.warningBox = vanilla.Box((10, 40, -10, 150)) self.w.warningBox.nodrawbot = vanilla.TextBox((10, 10, -10, -10), nodrawbotText) self.w.open() else: self.w = vanilla.Window((300, 780), "Import/Export Art") self.w.title = vanilla.TextBox((10, 10, -10, 25), titleText) self.w.titleFont = vanilla.TextBox((10, 40, -10, 25), "Source/Destination UFO") self.w.fontChoice = vanilla.PopUpButton((10, 60, -10, 25), self.fontNameList) # Export self.w.exportBox = vanilla.Box((10, 105, -10, 185)) self.w.exportBox.title = vanilla.TextBox((10, 10, -10, 100), descriptionExport) self.w.exportBox.glyphChoice = vanilla.PopUpButton( (10, 110, -10, 25), ["Selected glyphs", "All glyphs"]) self.w.exportBox.exportButton = vanilla.SquareButton( (10, 140, -10, 25), "Export SVG", callback=self.exportCallback) # Edit self.w.editBox = vanilla.Box((10, 305, -10, 165)) self.w.editBox.title = vanilla.TextBox((10, 10, -10, 200), descriptionEdit) # Import self.w.importBox = vanilla.Box((10, 485, -10, 285)) self.w.importBox.title = vanilla.TextBox((10, 10, -10, 190), descriptionImport) self.w.importBox.layerChoice = vanilla.PopUpButton( (10, 210, -10, 25), [ "Into the default foreground layer", "Into a new layer called “import“" ]) self.w.importBox.importButton = vanilla.SquareButton( (10, 240, -10, 25), "Import SVG", callback=self.importCallback) self.w.bind("close", self.closeCallback) self.w.open() self.buildFontList(None) addObserver(self, "buildFontList", "fontDidOpen") addObserver(self, "buildFontList", "newFontDidOpen") addObserver(self, "buildFontList", "fontDidClose")
def __init__( self ): # Window 'self.w': windowWidth = 180 windowHeight = 200 windowWidthResize = 300 # user can resize width by this value windowHeightResize = 1100 # user can resize height by this value self.w = vanilla.FloatingWindow( ( windowWidth, windowHeight ), # default window size "Find in Features", # window title minSize = ( windowWidth, windowHeight ), # minimum size (for resizing) maxSize = ( windowWidth + windowWidthResize, windowHeight + windowHeightResize ), # maximum size (for resizing) autosaveName = "com.mekkablue.FindInFeatures.mainwindow" # stores last window position and size ) # UI elements: linePos, inset, lineHeight = 1, 5, 28 self.w.searchFor = vanilla.EditText( (1, linePos, -1, 22), "", callback=self.FindInFeaturesMain, sizeStyle='regular' ) self.w.searchFor.getNSTextField().setToolTip_("Type the exact name of a glyph or (prefixed with @) a class.") linePos += lineHeight self.w.result = vanilla.Box( (inset, linePos, -inset, -inset) ) self.w.result.previewText = vanilla.TextBox( (1, 1, -1, -1), "", sizeStyle='small', selectable=True ) linePos += lineHeight # Open window and focus on it: self.w.open() self.w.makeKey()
def __init__(self): self.fullMetadata = getExtensionDefault("%s.scriptMetadata" % KEYPREFIX, fallback={}) if not len(self.fullMetadata.keys()): # "Restart" window self.w = vanilla.Window((500, 160), "Andy’s RoboFont Hacks") self.w.hr = vanilla.HorizontalLine((10, -50, -10, 1)) self.w.restartText = vanilla.TextBox( (20, 20, -20, -45), text_Bold( "Installed and updated.\nRestart RoboFont to refresh the list of my RoboFont hacks.\n\n — Andy Clymer" )) self.w.okButton = vanilla.Button((-120, -35, 100, 20), "OK", callback=self.cancelCallback) self.w.open() else: # Full window self.w = vanilla.Window((750, 300), "Andy’s RoboFont Hacks") columnDescriptions = [{ "title": "state", "width": 20, "cell": vanilla.CheckBoxListCell() }, { "title": "longName" }] self.w.scriptList = vanilla.List( (10, 10, 300, -60), [], allowsMultipleSelection=False, showColumnTitles=False, selectionCallback=self.listSelectionChanged, columnDescriptions=columnDescriptions) self.defaultTitle = "Andy’s RoboFont Hacks" self.defaultText = "A selection of extras that make RoboFont work the way I like it. \n\nEverything is optional, click on one of the names on the left for a description of what the add-on does. Select as many as you like by checking the box to the left of the name, and restart RoboFont to activate.\n\n — Andy Clymer" self.w.descriptionBox = vanilla.Box((320, 10, -10, -60)) self.w.descriptionBox.title = vanilla.TextBox((5, 5, -10, 25), self.defaultTitle) self.w.descriptionBox.text = vanilla.TextBox((5, 38, -10, -10), self.defaultText) #self.w.webView = WebView.alloc().initWithFrame_(((0, 0), (320, 1000))) #self.w.scroll = vanilla.ScrollView((320, 10, -10, -60), self.w.webView, hasHorizontalScroller=False, hasVerticalScroller=False) #self.w.webView.setMainFrameURL_(self.htmlPath) self.w.hr = vanilla.HorizontalLine((10, -50, -10, 1)) self.w.changeNote = vanilla.TextBox( (20, -32, -230, 25), text_SmallGray("Any change will require restarting RoboFont."), sizeStyle="small") self.w.cancelButton = vanilla.Button((-230, -35, 100, 20), "Cancel", callback=self.cancelCallback) self.w.applyButton = vanilla.Button((-120, -35, 100, 20), "Apply", callback=self.applyCallback) self.populateList() self.w.open()
def __init__(self, parentWindow): self.parentWindow = parentWindow self.debug = False # Glyph and font data self.glyph = None self.LIBKEY = "com.andyclymer.zPosition" self.LIBKEYVIEW = "com.andyclymer.projectionViewOrientation" self.pointData = {} # dict of x,y,z for each pointID # Helper attributes self.holdChanges = False self.currentView = "front" self.enableProjection = False # Enable the buttons and save point data to the lib? # Window controls self.view = vanilla.Group((30, 30, 100, 100)) self.view.controlGroup = vanilla.Box((0, 0, 93, 94)) self.view.controlGroup.buttonFront = vanilla.SquareButton( (40, 5, 40, 40), "●", callback=self.rotateFront) self.view.controlGroup.buttonFront.enable(False) self.view.controlGroup.buttonSide = vanilla.SquareButton( (5, 5, 30, 40), "◑", callback=self.rotateSide) self.view.controlGroup.buttonSide.enable(False) self.view.controlGroup.buttonTop = vanilla.SquareButton( (40, 50, 40, 30), "◓", callback=self.rotateTop) self.view.controlGroup.buttonTop.enable(False) self.view.controlGroup.enableBox = vanilla.CheckBox( (13, -38, 25, 25), "", callback=self.enableDisableCallback) addObserver(self, "viewWillChangeGlyph", "viewWillChangeGlyph") addObserver(self, "viewDidChangeGlyph", "viewDidChangeGlyph") addObserver(self, "fontWillSave", "fontWillSave") addObserver(self, "fontDidSave", "fontDidSave") addObserver(self, "mouseUp", "mouseUp")
def __init__(self): self.w = vanilla.FloatingWindow( (360, 350), "Insert weight instances", minSize=(360, 350), maxSize=(360, 500), autosaveName="com.mekkablue.InstanceMaker.mainwindow") self.w.text_1 = vanilla.TextBox((15 - 1, 12 + 2, 75, 14), "Insert", sizeStyle='small') self.w.numberOfInstances = vanilla.PopUpButton( (15 + 40, 12, 50, 17), [str(x) for x in range(3, 12)], callback=self.UpdateSample, sizeStyle='small') self.w.text_2 = vanilla.TextBox((15 + 40 + 55, 12 + 2, 120, 14), "instances with prefix", sizeStyle='small') self.w.prefix = vanilla.EditText((15 + 40 + 55 + 120, 12 - 1, -15, 19), "A-", callback=self.UpdateSample, sizeStyle='small') self.w.text_3 = vanilla.TextBox((15 - 1, 40 + 2, 60, 14), "from:", sizeStyle='small') self.w.master1 = vanilla.ComboBox((15 + 40, 40 - 1, 50, 19), self.MasterList(1), callback=self.UpdateSample, sizeStyle='small') self.w.text_4 = vanilla.TextBox((15 + 40 + 55, 40 + 2, 55, 14), "through:", sizeStyle='small') self.w.master2 = vanilla.ComboBox((15 + 40 + 55 + 55, 40 - 1, 50, 19), self.MasterList(-1), callback=self.UpdateSample, sizeStyle='small') self.w.text_5 = vanilla.TextBox( (15 + 40 + 55 + 55 + 55, 40 + 2, 55, 14), "at width:", sizeStyle='small') self.w.width = vanilla.EditText( (15 + 40 + 45 + 55 + 55 + 65, 40 - 1, -15, 19), "100", callback=self.SavePreferences, sizeStyle='small') self.w.text_6 = vanilla.TextBox((15 - 1, 68 + 2, 60, 14), "using", sizeStyle='small') self.w.algorithm = vanilla.PopUpButton((15 + 40, 68, 80, 17), ["Pablo", "Luc(as)", "linear"], callback=self.UpdateSample, sizeStyle='small') self.w.text_7 = vanilla.TextBox((15 + 40 + 85, 68 + 2, 110, 14), "distribution:", sizeStyle='small') self.w.help_instances = vanilla.HelpButton((-15 - 21, 68 + 2, -15, 20), callback=self.openURL) self.w.existingInstances = vanilla.RadioGroup( (15 + 30, 100, -10, 60), [ "Leave existing instances as they are", "Deactivate existing instances", "Delete existing instances" ], callback=self.SavePreferences, sizeStyle='small') self.w.existingInstances.set(0) self.w.maciej = vanilla.CheckBox((15, 170, 160, 19), "Maciej y distribution from:", value=False, callback=self.UpdateSample, sizeStyle='small') self.w.maciej_light = vanilla.ComboBox((15 + 165, 170 - 2, 50, 19), self.MasterList(1), callback=self.UpdateSample, sizeStyle='small') self.w.text_maciej_1 = vanilla.TextBox( (15 + 165 + 55, 170 + 2, 55, 19), "through:", sizeStyle='small') self.w.maciej_bold = vanilla.ComboBox( (15 + 165 + 55 + 55, 170 - 2, -15, 19), self.MasterList(-1), callback=self.UpdateSample, sizeStyle='small') self.w.text_maciej_2 = vanilla.TextBox( (15 + 15, 170 + 2 + 20, -40, 40), "Provide horizontal stem widths in extreme masters to interpolate contrast rather than stems.", sizeStyle='small', selectable=True) self.w.help_maciej = vanilla.HelpButton( (-15 - 21, 170 + 6 + 20, -15, 20), callback=self.openURL) self.w.sample = vanilla.Box((15, 170 + 30 + 40, -15, -30 - 15)) self.w.sample.text = vanilla.TextBox((5, 5, -5, -5), "", sizeStyle='small') self.w.createButton = vanilla.Button((-80 - 15, -20 - 15, -15, -15), "Create", sizeStyle='regular', callback=self.CreateInstances) self.w.setDefaultButton(self.w.createButton) if not self.LoadPreferences(): print "Error: Could not load preferences. Will resort to defaults." self.w.open() self.UpdateSample(self) self.w.makeKey()
def __init__(self, value, font1, font2, available_fonts): self.activateModule() # sets initial value # self.redBlink = False global redIsOn redIsOn = False x = 10 y = 10 lineHeight = 23 self.value = value self.font1 = font1 self.font2 = font2 self.available_fonts = available_fonts # gname1 if CurrentGlyph() != None: g = CurrentGlyph() else: g = gInit self.gname = g # use minSize to make window re-sizable self.w = vanilla.Window((400, 400), 'Delorean: Interpolation Preview', minSize=(200, 200)) # Figuring out what to display in the dropdown list styleNames_set = False familyNames_set = False familyNames_differ = False if all([f.info.styleName for f in self.available_fonts]): styleNames_set = True if all([f.info.familyName for f in self.available_fonts]): familyNames_set = True if len(set([f.info.familyName for f in self.available_fonts])) > 1: familyNames_differ = True if styleNames_set: # If style names are all set and family name is all the same # (or not set), display only the style name. # If family names are different, display family name & style name. if familyNames_set: if familyNames_differ: fontList = [ '%s %s' % (f.info.familyName, f.info.styleName) for f in self.available_fonts ] else: fontList = [f.info.styleName for f in self.available_fonts] else: fontList = [f.info.styleName for f in self.available_fonts] elif familyNames_set and familyNames_differ: # If for some reason only the family name is set, check if it is # different across UFOs. If it is, use it. fontList = [f.info.familyName for f in self.available_fonts] else: # Last resort (neither family nor style name are set), or the # family name is the same across UFOs (and no style name set): # Only display the UFO path. fontList = [os.path.basename(f.path) for f in self.available_fonts] # Dropdown menus w_width = self.w.getPosSize()[2] menu_width = w_width / 2 - 15 # It would be nice to make the dropdown respond to a width change, # of the window, but that is for next time. self.w.leftList = vanilla.PopUpButton( (x, y, menu_width, lineHeight), fontList, callback=self.font1ChangeCallback) self.w.leftList.set(self.available_fonts.index(font1)) self.w.rightList = vanilla.PopUpButton( (-menu_width - x, y, menu_width, lineHeight), fontList, callback=self.font2ChangeCallback) self.w.rightList.set(self.available_fonts.index(font2)) # Line Return y += lineHeight # vanilla.TextBox (not interactive field) self.w.gnameTextBox = vanilla.TextBox((x, y, 200, lineHeight), 'Glyph name') self.w.valueTextBox = vanilla.TextBox((x + 105, y, 200, lineHeight), 'Interpolation %') # Line Return y += lineHeight # "Glyph name" self.w.gnameTextInput = vanilla.EditText( (x, y, 80, lineHeight), self.gname.name, callback=self.setterButtonCallback) # "Percentage" Slider # Value self.w.valueTextInput = SliderEditIntStepper( (x + 105, y, -10, 22), minValue=-200, maxValue=400, value=50, increment=10, callback=self.setterButtonCallback) y += lineHeight y += 15 # -5 from bottom self.w.preview = GlyphPreview((0, y, -0, -5)) # Report self.w.reportText = vanilla.TextBox((x, -27, 400, lineHeight), '') # generate instance self.w.generate = vanilla.Button((-35, -27, 27, lineHeight), u"⬇", callback=self.generateCallback) if CurrentGlyph() != None: g = CurrentGlyph() else: g = gInit gname = g.name self.interpSetGlyph(gname) self.w.box = vanilla.Box((0, (y - 9), -0, -30)) self.setUpBaseWindowBehavior() self.w.open()
def __init__(self): # Window 'self.w': windowWidth = 285 windowHeight = 190 windowWidthResize = 100 # user can resize width by this value windowHeightResize = 300 # user can resize height by this value self.w = vanilla.FloatingWindow( (windowWidth, windowHeight), # default window size "Style Renamer", # window title minSize=(windowWidth, windowHeight), # minimum size (for resizing) maxSize=(windowWidth + windowWidthResize, windowHeight + windowHeightResize), # maximum size (for resizing) autosaveName= "com.mekkablue.StyleRenamer.mainwindow" # stores last window position and size ) # UI elements: linePos, inset, lineHeight = 12, 15, 24 column = 55 self.w.subtractOrAdd = vanilla.PopUpButton( (inset, linePos, 145, 17), ("Subtract particle from", "Add particle to"), sizeStyle='small', callback=self.SavePreferences) self.w.subtractOrAddText = vanilla.TextBox( (inset + 150, linePos + 2, -inset, 14), "all instance names:", sizeStyle='small', selectable=True) tooltipText = "Choose here if you want to add the chosen particle name to all styles, or remove it from them." self.w.subtractOrAdd.getNSPopUpButton().setToolTip_(tooltipText) self.w.subtractOrAddText.getNSTextField().setToolTip_(tooltipText) linePos += lineHeight self.w.particleText = vanilla.TextBox((inset, linePos + 3, column, 14), "Particle:", sizeStyle='small', selectable=True) self.w.particle = vanilla.EditText( (inset + column, linePos, -inset - 25, 19), particleDefault, callback=self.SavePreferences, sizeStyle='small') tooltipText = "This is the name part you want to add to the name, or erase from it. Typically something like ‘%s’." % particleDefault self.w.particleText.getNSTextField().setToolTip_(tooltipText) self.w.particle.getNSTextField().setToolTip_(tooltipText) self.w.particleUpdate = vanilla.SquareButton( (-inset - 20, linePos, -inset, 18), "↺", sizeStyle='small', callback=self.update) self.w.particleUpdate.getNSButton().setToolTip_( "Will reset the name particle to ‘%s’." % particleDefault) linePos += lineHeight self.w.elidablePartText = vanilla.TextBox( (inset, linePos + 3, column, 14), "Elidable:", sizeStyle='small', selectable=True) self.w.elidablePart = vanilla.EditText( (inset + column, linePos, -inset - 25, 19), elidablePartDefault, callback=self.SavePreferences, sizeStyle='small') tooltipText = "Typically something like ‘%s’. This is the stub name part that will be the name of the style if it would be otherwise empty, e.g., remove the word ‘%s’ from the style ‘%s’, and the style name would be empty, so the elidable name kicks in, and the style is ‘%s’.\nOr, the other way around, the part of the name that gets deleted from the name, as soon as you add any particle to it. E.g., you add ‘%s’ to ‘%s’, and instead of calling it ‘%s %s’, it will be simply ‘%s’." % ( elidablePartDefault, particleDefault, particleDefault, elidablePartDefault, particleDefault, elidablePartDefault, elidablePartDefault, particleDefault, particleDefault) self.w.elidablePartText.getNSTextField().setToolTip_(tooltipText) self.w.elidablePart.getNSTextField().setToolTip_(tooltipText) self.w.elidablePartUpdate = vanilla.SquareButton( (-inset - 20, linePos, -inset, 18), "↺", sizeStyle='small', callback=self.update) self.w.elidablePartUpdate.getNSButton().setToolTip_( "Will reset the elidable part of style name to ‘%s’." % elidablePartDefault) linePos += lineHeight self.w.includeInactiveInstances = vanilla.CheckBox( (inset, linePos - 1, -inset, 20), "Include inactive instances", value=False, callback=self.SavePreferences, sizeStyle='small') self.w.includeInactiveInstances.getNSButton().setToolTip_( "If turned, will add/remove the particle to/from all instances, rather than just the active ones." ) linePos += lineHeight self.w.preview = vanilla.Box((inset, linePos, -inset, -30 - inset)) self.w.preview.previewText = vanilla.TextBox((5, 1, -5, -1), "", sizeStyle='small', selectable=True) linePos += lineHeight # Run Button: self.w.runButton = vanilla.Button( (-90 - inset, -20 - inset, -inset, -inset), "Rename", sizeStyle='regular', callback=self.StyleRenamerMain) self.w.setDefaultButton(self.w.runButton) # Load Settings: if not self.LoadPreferences(): print( "Note: 'Style Renamer' could not load preferences. Will resort to defaults" ) self.fileManager = NSFileManager.alloc().init() self.updatePreviewText() # Open window and focus on it: self.w.open() self.w.makeKey()
def __init__(self): # Window 'self.w': windowWidth = 360 windowHeight = 390 windowWidthResize = 0 # user can resize width by this value windowHeightResize = 300 # user can resize height by this value self.w = vanilla.FloatingWindow( (windowWidth, windowHeight), # default window size "Insert weight instances", # window title minSize=(windowWidth, windowHeight), # minimum size (for resizing) maxSize=(windowWidth + windowWidthResize, windowHeight + windowHeightResize), # maximum size (for resizing) autosaveName= "com.mekkablue.InstanceMaker.mainwindow" # stores last window position and size ) inset, lineheight = 15, 12 self.w.text_1 = vanilla.TextBox((inset - 1, lineheight + 2, 75, 14), "Insert", sizeStyle='small') self.w.numberOfInstances = vanilla.PopUpButton( (inset + 40, lineheight, 50, 17), [str(x) for x in range(3, 12)], callback=self.UpdateSample, sizeStyle='small') self.w.numberOfInstances.getNSPopUpButton().setToolTip_( "Choose how many instances you want to add. A full weight spectrum has 9 weights." ) self.w.text_2 = vanilla.TextBox( (inset + 40 + 55, lineheight + 2, 120, 14), "instances with prefix", sizeStyle='small') self.w.prefix = vanilla.EditText( (inset + 40 + 55 + 120, lineheight - 1, -inset, 19), "A-", callback=self.UpdateSample, sizeStyle='small') self.w.prefix.getNSTextField().setToolTip_( u"Choose text that is added at the beginning of each instance, e.g., ‘Condensed’." ) lineheight += 28 self.w.text_3 = vanilla.TextBox((inset - 1, lineheight + 2, 60, 14), "from:", sizeStyle='small') self.w.master1 = vanilla.ComboBox((inset + 35, lineheight - 1, 62, 19), self.MasterList(1), callback=self.UpdateSample, sizeStyle='small') self.w.master1.getNSComboBox().setToolTip_( "Weight value for the first instance being added, typically the stem width of your lightest weight." ) self.w.text_4 = vanilla.TextBox( (inset + 50 + 55 * 1, lineheight + 2, 55, 14), "through:", sizeStyle='small') self.w.master2 = vanilla.ComboBox( (inset + 50 + 55 * 2, lineheight - 1, 62, 19), self.MasterList(-1), callback=self.UpdateSample, sizeStyle='small') self.w.master2.getNSComboBox().setToolTip_( "Weight value for the last instance being added, typically the stem width of your boldest weight." ) self.w.text_5 = vanilla.TextBox( (inset + 65 + 55 * 3, lineheight + 2, 55, 14), "at width:", sizeStyle='small') self.w.width = vanilla.EditText( (inset + 65 + 55 * 4, lineheight - 1, -inset, 19), "100", callback=self.UpdateSample, sizeStyle='small') self.w.width.getNSTextField().setToolTip_( "The Width value for the instances being added. Default is 100. Adapt accordingly if you are adding condensed or extended instances." ) lineheight += 28 self.w.text_6 = vanilla.TextBox((inset - 1, lineheight + 2, 60, 14), "using", sizeStyle='small') self.w.algorithm = vanilla.PopUpButton( (inset + 35, lineheight, 90, 17), ("linear", "Pablo", "Schneider", "Abraham", "Luc(as)"), callback=self.UpdateSample, sizeStyle='small') self.w.algorithm.getNSPopUpButton().setToolTip_( "The way the Weight values are distributed between the first and last master values you entered above. Linear means equal steps between instances. Luc(as) (after Lucas de Groot) means the same growth percentage between instances. Pablo (after Pablo Impallari) is like Luc(as) at first, then becomes increasingly linear, i.e., flat in the periphery and steep in the middle. Schneider (after Lukas Schneider) is half way between Pablo and Luc(as) algorithms. Abraham (after Abraham Lee) is linear at first, then becomes incresingly like Luc(as), i.e. steep in the periphery, flat in the middle.\nFor a wide spectrum, try Pablo or Schneider. For spectrums that do not grow too bold, try Abraham or Luc(as). The latter tend to have large jumps at the end, which are usually found in the center of the weight spectrum (between Regular and Semibold). Smaller jumps are preferable in the periphery, i.e., for very light and very dark weights." ) self.w.text_7 = vanilla.TextBox( (inset + 40 + 85 + 5, lineheight + 2, 110, 14), "distribution.", sizeStyle='small') self.w.help_instances = vanilla.HelpButton( (-15 - 21, lineheight + 2, -inset, 20), callback=self.openURL) lineheight += 32 self.w.existingInstances = vanilla.RadioGroup( (inset + 20, lineheight, -10, 60), ("Leave existing instances as they are", "Deactivate existing instances", "Delete existing instances"), callback=self.SavePreferences, sizeStyle='small') self.w.existingInstances.set(0) lineheight += 70 self.w.naturalNames = vanilla.CheckBox( (inset, lineheight, inset + 225, 19), u"Use ‘natural’ weight names, starting at:", value=False, callback=self.UpdateSample, sizeStyle='small') self.w.naturalNames.getNSButton().setToolTip_( "Prefill with standard names and style linking. If turned off, will use the Weight number as instance name." ) self.w.firstName = vanilla.PopUpButton( (inset + 225, lineheight, -inset, 17), naturalNames, callback=self.UpdateSample, sizeStyle='small') self.w.firstName.getNSPopUpButton().setToolTip_( "If you use natural weight names, choose here the name of your lightest weight." ) try: # workaround for macOS 10.9 self.w.firstName.enable( self.w.naturalNames.getNSButton().isEnabled()) except: pass lineheight += 20 self.w.italicStyle = vanilla.CheckBox( (inset + 20, lineheight, -inset, 20), u"Italic suffixes and style linking", value=False, callback=self.UpdateSample, sizeStyle='small') self.w.italicStyle.getNSButton().setToolTip_( u"If enabled, will add the word ‘Italic’ to all instances, and also add italic style linking." ) lineheight += 24 self.w.maciej = vanilla.CheckBox((inset, lineheight - 1, 160, 19), "Maciej y distribution from:", value=False, callback=self.UpdateSample, sizeStyle='small') self.w.maciej.getNSButton().setToolTip_( "An algorithm proposed by Maciej Ratajski, which introduces slightly different interpolation for y coordinates. Will add interpolationWeightY parameters to the instances. If these value differ greatly from the weight interpolation values, interpolation of your diagonals may suffer." ) self.w.text_maciej_1 = vanilla.TextBox( (inset + 165 + 55, lineheight + 2, 55, 19), "through:", sizeStyle='small') self.w.text_maciej_2 = vanilla.TextBox( (inset + 15, lineheight + 2 + 20, -40, 40), "Provide horizontal stem widths in extreme masters to interpolate contrast rather than stems.", sizeStyle='small', selectable=True) self.w.maciej_light = vanilla.ComboBox( (inset + 160, lineheight - 1, 55, 19), self.MasterList(1), callback=self.UpdateSample, sizeStyle='small') self.w.maciej_bold = vanilla.ComboBox( (inset + 160 + 55 + 55, lineheight - 1, -inset, 19), self.MasterList(-1), callback=self.UpdateSample, sizeStyle='small') self.w.help_maciej = vanilla.HelpButton( (-inset - 21, lineheight + 6 + 20, -inset, 20), callback=self.openURL) self.w.help_maciej.getNSButton().setToolTip_( "Will open a website with a detailed description of the Maciej algorithm. Requires an internet connection." ) lineheight += 60 self.w.shouldRound = vanilla.CheckBox((inset, lineheight, -inset, 19), "Round all interpolation values", value=True, callback=self.UpdateSample, sizeStyle='small') self.w.shouldRound.getNSButton().setToolTip_( "If enabled, will round all calculated weight values to integers. Usually a good idea." ) lineheight += 30 self.w.sample = vanilla.Box((inset, lineheight, -inset, -30 - inset)) self.w.sample.text = vanilla.TextBox((5, 5, -5, -5), "", sizeStyle='small') self.w.createButton = vanilla.Button( (-90 - inset, -20 - inset, -inset, -inset), "Insert", sizeStyle='regular', callback=self.CreateInstances) self.w.setDefaultButton(self.w.createButton) if not self.LoadPreferences(): print( "Error: Could not load preferences. Will resort to defaults.") self.w.open() self.UpdateSample(self) self.w.makeKey()
def __init__(self): # Window 'self.w': windowWidth = 360 windowHeight = 390 windowWidthResize = 0 # user can resize width by this value windowHeightResize = 300 # user can resize height by this value self.w = vanilla.FloatingWindow( (windowWidth, windowHeight), # default window size "Insert weight instances", # window title minSize=(windowWidth, windowHeight), # minimum size (for resizing) maxSize=(windowWidth + windowWidthResize, windowHeight + windowHeightResize), # maximum size (for resizing) autosaveName= "com.mekkablue.InstanceMaker.mainwindow" # stores last window position and size ) inset, lineheight = 15, 12 self.w.text_1 = vanilla.TextBox((inset - 1, lineheight + 2, 75, 14), "Insert", sizeStyle='small') self.w.numberOfInstances = vanilla.PopUpButton( (inset + 40, lineheight, 50, 17), [str(x) for x in range(3, 12)], callback=self.UpdateSample, sizeStyle='small') self.w.text_2 = vanilla.TextBox( (inset + 40 + 55, lineheight + 2, 120, 14), "instances with prefix", sizeStyle='small') self.w.prefix = vanilla.EditText( (inset + 40 + 55 + 120, lineheight - 1, -inset, 19), "A-", callback=self.UpdateSample, sizeStyle='small') lineheight += 28 self.w.text_3 = vanilla.TextBox((inset - 1, lineheight + 2, 60, 14), "from:", sizeStyle='small') self.w.master1 = vanilla.ComboBox((inset + 35, lineheight - 1, 62, 19), self.MasterList(1), callback=self.UpdateSample, sizeStyle='small') self.w.text_4 = vanilla.TextBox( (inset + 50 + 55 * 1, lineheight + 2, 55, 14), "through:", sizeStyle='small') self.w.master2 = vanilla.ComboBox( (inset + 50 + 55 * 2, lineheight - 1, 62, 19), self.MasterList(-1), callback=self.UpdateSample, sizeStyle='small') self.w.text_5 = vanilla.TextBox( (inset + 65 + 55 * 3, lineheight + 2, 55, 14), "at width:", sizeStyle='small') self.w.width = vanilla.EditText( (inset + 65 + 55 * 4, lineheight - 1, -inset, 19), "100", callback=self.UpdateSample, sizeStyle='small') lineheight += 28 self.w.text_6 = vanilla.TextBox((inset - 1, lineheight + 2, 60, 14), "using", sizeStyle='small') self.w.algorithm = vanilla.PopUpButton( (inset + 35, lineheight, 90, 17), ( "linear", "Pablo", "Schneider", "Luc(as)", ), callback=self.UpdateSample, sizeStyle='small') self.w.text_7 = vanilla.TextBox( (inset + 40 + 85 + 5, lineheight + 2, 110, 14), "distribution.", sizeStyle='small') self.w.help_instances = vanilla.HelpButton( (-15 - 21, lineheight + 2, -inset, 20), callback=self.openURL) lineheight += 32 self.w.existingInstances = vanilla.RadioGroup( (inset + 20, lineheight, -10, 60), ("Leave existing instances as they are", "Deactivate existing instances", "Delete existing instances"), callback=self.SavePreferences, sizeStyle='small') self.w.existingInstances.set(0) lineheight += 70 self.w.naturalNames = vanilla.CheckBox( (inset, lineheight, inset + 225, 19), u"Use ‘natural’ weight names, starting at:", value=False, callback=self.UpdateSample, sizeStyle='small') self.w.firstName = vanilla.PopUpButton( (inset + 225, lineheight, -inset, 17), naturalNames, callback=self.UpdateSample, sizeStyle='small') try: # workaround for macOS 10.9 self.w.firstName.enable( self.w.naturalNames.getNSButton().isEnabled()) except: pass lineheight += 20 self.w.italicStyle = vanilla.CheckBox( (inset + 20, lineheight, -inset, 20), u"Italic suffixes and style linking", value=False, callback=self.UpdateSample, sizeStyle='small') lineheight += 24 self.w.maciej = vanilla.CheckBox((inset, lineheight - 1, 160, 19), "Maciej y distribution from:", value=False, callback=self.UpdateSample, sizeStyle='small') self.w.text_maciej_1 = vanilla.TextBox( (inset + 165 + 55, lineheight + 2, 55, 19), "through:", sizeStyle='small') self.w.text_maciej_2 = vanilla.TextBox( (inset + 15, lineheight + 2 + 20, -40, 40), "Provide horizontal stem widths in extreme masters to interpolate contrast rather than stems.", sizeStyle='small', selectable=True) self.w.maciej_light = vanilla.ComboBox( (inset + 160, lineheight - 1, 55, 19), self.MasterList(1), callback=self.UpdateSample, sizeStyle='small') self.w.maciej_bold = vanilla.ComboBox( (inset + 160 + 55 + 55, lineheight - 1, -inset, 19), self.MasterList(-1), callback=self.UpdateSample, sizeStyle='small') self.w.help_maciej = vanilla.HelpButton( (-inset - 21, lineheight + 6 + 20, -inset, 20), callback=self.openURL) lineheight += 60 self.w.shouldRound = vanilla.CheckBox((inset, lineheight, -inset, 19), "Round all interpolation values", value=True, callback=self.UpdateSample, sizeStyle='small') lineheight += 30 self.w.sample = vanilla.Box((inset, lineheight, -inset, -30 - inset)) self.w.sample.text = vanilla.TextBox((5, 5, -5, -5), "", sizeStyle='small') self.w.createButton = vanilla.Button( (-80 - inset, -20 - inset, -inset, -inset), "Create", sizeStyle='regular', callback=self.CreateInstances) self.w.setDefaultButton(self.w.createButton) if not self.LoadPreferences(): print "Error: Could not load preferences. Will resort to defaults." self.w.open() self.UpdateSample(self) self.w.makeKey()
def __init__(self): self.w = vanilla.Window((500, 500), minSize=(200, 200)) # Stack 1 blue = AppKit.NSColor.colorWithCalibratedRed_green_blue_alpha_( 0, 0, 1, 0.75) stack1Views = [ vanilla.Box("auto", fillColor=blue), vanilla.Box("auto", fillColor=blue), vanilla.Box("auto", fillColor=blue) ] stack1 = vanilla.VerticalStackView("auto", views=stack1Views, spacing=10, edgeInsets=(0, 0, 0, 0)) # Stack 2 green = AppKit.NSColor.colorWithCalibratedRed_green_blue_alpha_( 0, 1, 0, 0.75) greenBox = vanilla.Box("auto", fillColor=green) stack2Views = [dict(view=greenBox, width=150), dict(view=stack1)] stack2 = vanilla.HorizontalStackView("auto", views=stack2Views, spacing=10, edgeInsets=(0, 0, 0, 0), distribution="fill") # Stack 3 red = AppKit.NSColor.colorWithCalibratedRed_green_blue_alpha_( 1, 0, 0, 0.75) stack3Views = [ dict(view=vanilla.Box("auto", fillColor=red), width=75), dict(view=vanilla.Box("auto", fillColor=red), width=75), dict(view=vanilla.Box("auto", fillColor=red), width=75) ] stack3 = vanilla.HorizontalStackView("auto", views=stack3Views, spacing=10, edgeInsets=(0, 0, 0, 0)) # Stack 4 yellow = AppKit.NSColor.colorWithCalibratedRed_green_blue_alpha_( 1, 1, 0, 0.75) stack4Views = [ dict(view=stack2, width=">=100"), dict(view=vanilla.Box("auto", fillColor=yellow), height=">=50, <=100"), dict(view=stack3, height=30) ] stack4 = vanilla.VerticalStackView("auto", views=stack4Views, spacing=10, edgeInsets=(0, 0, 0, 0)) self.w.stack = stack4 metrics = dict(margin=15) rules = [ "H:|-margin-[stack]-margin-|", "V:|-margin-[stack]-margin-|", ] self.w.addAutoPosSizeRules(rules, metrics) self.w.open()
def __init__( self ): # Window 'self.w': windowWidth = 320 windowHeight = 490 windowWidthResize = 300 # user can resize width by this value windowHeightResize = 0 # user can resize height by this value self.w = vanilla.FloatingWindow( ( windowWidth, windowHeight ), # default window size "Find Near Vertical Misses", # window title minSize = ( windowWidth, windowHeight ), # minimum size (for resizing) maxSize = ( windowWidth + windowWidthResize, windowHeight + windowHeightResize ), # maximum size (for resizing) autosaveName = "com.mekkablue.FindNearVerticalMisses.mainwindow" # stores last window position and size ) # UI elements: linePos, inset, lineHeight = 12, 15, 22 self.w.descriptionText = vanilla.TextBox( (inset, linePos+2, -inset, 14), u"Find glyphs with nodes not exactly on vertical metrics:", sizeStyle='small', selectable=True ) linePos += lineHeight self.w.devianceText = vanilla.TextBox( (inset, linePos+3, inset+135, 14), u"Find nodes off by up to:", sizeStyle='small', selectable=True ) self.w.deviance = vanilla.EditText( (inset+135, linePos, -inset, 19), "1", callback=self.SavePreferences, sizeStyle='small' ) self.w.deviance.getNSTextField().setToolTip_(u"Finds nodes that are not equal to the metric, but off up to this value in units. Minimum: 1 unit.") linePos += lineHeight # BOX linePos += lineHeight//2 self.w.whereToCheck = vanilla.Box( (inset, linePos, -inset, lineHeight*7.6) ) insetLinePos = inset*0.2 self.w.whereToCheck.ascender = vanilla.CheckBox( (0.5*inset, insetLinePos-1, -inset, 20), u"Ascender (caps ignored)", value=True, callback=self.SavePreferences, sizeStyle='small' ) self.w.whereToCheck.ascender.getNSButton().setToolTip_(u"Checks if points are not exactly on, but just off the ascender of the corresponding master.") linePos += lineHeight insetLinePos += lineHeight self.w.whereToCheck.capHeight = vanilla.CheckBox( (0.5*inset, insetLinePos-1, -inset, 20), u"Cap Height (lowercase ignored)", value=True, callback=self.SavePreferences, sizeStyle='small' ) self.w.whereToCheck.capHeight.getNSButton().setToolTip_(u"Checks if points are not exactly on, but just off the capHeight of the corresponding master.") linePos += lineHeight insetLinePos += lineHeight self.w.whereToCheck.shoulderHeight = vanilla.CheckBox( (0.5*inset, insetLinePos-1, -inset, 20), u"shoulderHeight (UC, LC, SC ignored)", value=False, callback=self.SavePreferences, sizeStyle='small' ) self.w.whereToCheck.shoulderHeight.getNSButton().setToolTip_(u"Checks if points are not exactly on, but just off the shoulderHeight of the corresponding master.") linePos += lineHeight insetLinePos += lineHeight self.w.whereToCheck.smallCapHeight = vanilla.CheckBox( (0.5*inset, insetLinePos-1, -inset, 20), u"smallCapHeight (only considers smallcaps)", value=False, callback=self.SavePreferences, sizeStyle='small' ) self.w.whereToCheck.smallCapHeight.getNSButton().setToolTip_(u"Checks if points are not exactly on, but just off the smallCapHeight of the corresponding master.") linePos += lineHeight insetLinePos += lineHeight self.w.whereToCheck.xHeight = vanilla.CheckBox( (0.5*inset, insetLinePos-1, -inset, 20), u"x-height (caps ignored)", value=True, callback=self.SavePreferences, sizeStyle='small' ) self.w.whereToCheck.xHeight.getNSButton().setToolTip_(u"Checks if points are not exactly on, but just off the xHeight of the corresponding master.") linePos += lineHeight insetLinePos += lineHeight self.w.whereToCheck.baseline = vanilla.CheckBox( (0.5*inset, insetLinePos-1, -inset, 20), u"Baseline", value=True, callback=self.SavePreferences, sizeStyle='small' ) self.w.whereToCheck.baseline.getNSButton().setToolTip_(u"Checks if points are not exactly on, but just off the baseline of the corresponding master.") linePos += lineHeight insetLinePos += lineHeight self.w.whereToCheck.descender = vanilla.CheckBox( (0.5*inset, insetLinePos-1, -inset, 20), u"Descender", value=False, callback=self.SavePreferences, sizeStyle='small' ) self.w.whereToCheck.descender.getNSButton().setToolTip_(u"Checks if points are not exactly on, but just off the descender of the corresponding master.") linePos += lineHeight insetLinePos += lineHeight linePos += lineHeight # BOX END self.w.tolerateIfNextNodeIsOn = vanilla.CheckBox( (inset, linePos-1, -inset, 20), u"Tolerate near miss if next node is on", value=True, callback=self.SavePreferences, sizeStyle='small' ) self.w.tolerateIfNextNodeIsOn.getNSButton().setToolTip_("Will skip the just-off node if the next or previous on-curve node is EXACTLY on the metric line. Useful if you have very thin serifs or short segments near the metric lines.") linePos += lineHeight self.w.tolerateIfExtremum = vanilla.CheckBox( (inset, linePos-1, -inset, 20), u"Tolerate near miss for left/right curve extremum", value=True, callback=self.SavePreferences, sizeStyle='small' ) self.w.tolerateIfExtremum.getNSButton().setToolTip_("Will skip the just-off node if the next and previous nodes are VERTICAL OFF-CURVES. Recommended for avoiding false positives.") linePos += lineHeight self.w.includeHandles = vanilla.CheckBox( (inset, linePos-1, -inset, 20), u"Include off-curve points", value=False, callback=self.SavePreferences, sizeStyle='small' ) self.w.includeHandles.getNSButton().setToolTip_(u"Also checks BCPs (Bézier control points), vulgo ‘handles’. Otherwise only considers on-curve nodes") linePos += lineHeight self.w.includeNonExporting = vanilla.CheckBox( (inset, linePos-1, -inset, 20), u"Include non-exporting glyphs", value=False, callback=self.SavePreferences, sizeStyle='small' ) self.w.includeNonExporting.getNSButton().setToolTip_(u"Also check for near misses in glyphs that are set to not export. Useful if you are using non-exporting parts as components in other glyphs.") linePos += lineHeight self.w.removeOverlap = vanilla.CheckBox( (inset, linePos-1, -inset, 20), u"Check outlines after Remove Overlap (slower)", value=False, callback=self.SavePreferences, sizeStyle='small' ) self.w.removeOverlap.getNSButton().setToolTip_(u"Only checks outlines after overlap removal. That way, ignores triangular overlaps (‘opened corners’). Use this option if you have too many false positives.") linePos += lineHeight self.w.markNodes = vanilla.CheckBox( (inset, linePos-1, -inset, 20), u"Mark affected nodes with %s"%self.marker, value=False, callback=self.SavePreferences, sizeStyle='small' ) self.w.markNodes.getNSButton().setToolTip_(u"Sets the name of affected nodes to this emoji, so you can easily find it. ATTENTION: If Remove Overlap option is on, will use the emoji as an annotation instead.") linePos += lineHeight self.w.excludeText = vanilla.TextBox( (inset, linePos+3, 150, 14), u"Exclude glyphs containing:", sizeStyle='small', selectable=True ) self.w.exclude = vanilla.EditText( (inset+150, linePos, -inset, 19), ".ornm, .notdef", callback=self.SavePreferences, sizeStyle='small' ) linePos += lineHeight self.w.openTab = vanilla.CheckBox( (inset, linePos-1, -inset, 20), u"Open tab with affected layers", value=True, callback=self.SavePreferences, sizeStyle='small' ) self.w.openTab.getNSButton().setToolTip_(u"If it finds nodes just off the indicated metrics, will open a new tab with the layers if found the deviating nodes on. Otherwise please check the detailed report in Macro Window.") linePos += lineHeight self.w.progress = vanilla.ProgressBar((inset, linePos, -inset, 16)) self.w.progress.set(0) # set progress indicator to zero linePos+=lineHeight # Run Button: self.w.runButton = vanilla.Button( (-80-inset, -20-inset, -inset, -inset), "Find", sizeStyle='regular', callback=self.FindNearVerticalMissesMain ) self.w.setDefaultButton( self.w.runButton ) # Load Settings: if not self.LoadPreferences(): print "Note: 'Find Near Vertical Misses' could not load preferences. Will resort to defaults" # Open window and focus on it: self.w.open() self.w.makeKey()
def messageAccessoryView(self, sender): import vanilla view = vanilla.Box((0, 0, 200, 75)) view.checkBox = vanilla.CheckBox((10, 10, 100, 22), "checked") dialogs.message("Hello world", "foo bar", accessoryView=view)
def getFileAccessoryView(self, sender): import vanilla view = vanilla.Box((0, 0, 200, 75)) view.checkBox = vanilla.CheckBox((10, 10, 100, 22), "checked") print("result", dialogs.getFile(accessoryView=view))
def __init__(self): self.w = vanilla.Window((0, 0)) columnDescriptions = [ dict(columnPlacement="trailing"), dict(width=300, columnPlacement="fill") ] self.editText = vanilla.EditText("auto", "Type to test callback.", callback=self.editTextCallback) rows = [ (vanilla.TextBox("auto", "TextBox:"), vanilla.TextBox("auto", "Hello")), (vanilla.TextBox("auto", "EditText:"), self.editText), (vanilla.TextBox("auto", "Button:"), vanilla.Button("auto", "Button")), (vanilla.TextBox("auto", "PopUpButton:"), vanilla.PopUpButton("auto", ["PopUpButton"])), (vanilla.TextBox("auto", "ComboBox:"), vanilla.ComboBox("auto", ["ComboBox"])), (vanilla.TextBox("auto", "CheckBox:"), vanilla.CheckBox("auto", "CheckBox 1")), dict(rowPadding=(0, 0), cells=(None, vanilla.CheckBox("auto", "CheckBox 2"))), dict(rowPadding=(0, 0), cells=(None, vanilla.CheckBox("auto", "CheckBox 3"))), (vanilla.TextBox("auto", "SegmentedButton:"), vanilla.SegmentedButton( "auto", [dict(title="One"), dict(title="Two"), dict(title="Three")], sizeStyle="regular")), (vanilla.TextBox("auto", "Slider:"), vanilla.Slider("auto", minValue=0, maxValue=100, value=50)), dict(height=100, cells=(vanilla.TextBox("auto", "RadioGroup:"), dict(rowAlignment="none", view=vanilla.RadioGroup( "auto", ["One", "Two", "Three"])))), dict(height=100, cells=(vanilla.TextBox("auto", "ColorWell:"), dict(width=50, height=75, view=vanilla.ColorWell( "auto", color=AppKit.NSColor.redColor())))), dict(height=100, cells=(vanilla.TextBox("auto", "List:"), dict(columnPlacement="fill", rowPlacement="fill", view=vanilla.List("auto", ["One", "Two", "Three"])))), dict(height=100, cells=(vanilla.TextBox("auto", "TextEditor:"), vanilla.TextEditor("auto", "TextEditor"))), dict(height=100, cells=(vanilla.TextBox("auto", "Box:"), vanilla.Box("auto", fillColor=AppKit.NSColor.blueColor(), cornerRadius=20))), ] self.w.gridView = vanilla.GridView( "auto", rows, columnDescriptions=columnDescriptions, columnWidth=150, columnSpacing=10, rowHeight=25, rowPadding=(15, 0)) self.columnCount = len(columnDescriptions) self.rowCount = len(rows) # append, insert, etc. buttons self.appendColumnButton = vanilla.Button( "auto", "Append", callback=self.appendColumnButtonCallback) self.insertColumnButton = vanilla.Button( "auto", "Insert", callback=self.insertColumnButtonCallback) self.removeColumnButton = vanilla.Button( "auto", "Remove", callback=self.removeColumnButtonCallback) self.moveColumnButton = vanilla.Button( "auto", "Move", callback=self.moveColumnButtonCallback) self.showColumnButton = vanilla.Button( "auto", "Show/Hide", callback=self.showColumnButtonCallback) self.appendRowButton = vanilla.Button( "auto", "Append", callback=self.appendRowButtonCallback) self.insertRowButton = vanilla.Button( "auto", "Insert", callback=self.insertRowButtonCallback) self.removeRowButton = vanilla.Button( "auto", "Remove", callback=self.removeRowButtonCallback) self.moveRowButton = vanilla.Button( "auto", "Move", callback=self.moveRowButtonCallback) self.showRowButton = vanilla.Button( "auto", "Show/Hide", callback=self.showRowButtonCallback) rows = [[ vanilla.TextBox("auto", "Column:"), self.appendColumnButton, self.insertColumnButton, self.removeColumnButton, self.moveColumnButton, self.showColumnButton ], [ vanilla.TextBox("auto", "Row:"), self.appendRowButton, self.insertRowButton, self.removeRowButton, self.moveRowButton, self.showRowButton ]] columnDescriptions = [dict(width=60, columnPlacement="trailing")] for i in range(len(rows[0]) - 1): columnDescriptions.append({}) self.w.line = vanilla.HorizontalLine("auto") self.w.testButtonGrid = vanilla.GridView( "auto", rows, columnDescriptions=columnDescriptions, columnWidth=100, columnSpacing=5, columnPlacement="fill", rowHeight=25) rules = [ "H:|-margin-[gridView]-margin-|", "H:|[line]|", "H:|-margin-[testButtonGrid]-margin-|", "V:|" "-margin-" "[gridView]" "-margin-" "[line]" "-margin-" "[testButtonGrid]" "-margin-" "|" ] metrics = dict(margin=15) self.w.addAutoPosSizeRules(rules, metrics) self.w.open()
def __init__(self): # window self.fullWidth = self.ui.w(11.4) self.winWidth = self.ui.w() + self.fullWidth + self.ui.w() # window ui self.w = vanilla.Window((0, 0), "Layer Thief") # events self.w.bind("became key", self.windowBecameKey) self.w.bind("close", self.windowWillClose) mojo.events.addObserver(self, "fontWillClose", "fontWillClose") mojo.events.addObserver(self, "fontDidOpen", "fontDidOpen") # source ui self.w.sourceFontLabel = vanilla.TextBox( (self.ui.x(), self.ui.y() + 1, self.ui.w(2.4), self.ui.h("textBox")), self.sourceFontTitle, alignment="right") self.w.sourceFontPopUp = vanilla.PopUpButton( (self.ui.x(2.4), self.ui.y(), self.ui.w(9), self.ui.h("popUp")), [], callback=self.fontPopUpCallback) self.w.sourceLayerPopUp = vanilla.PopUpButton( (self.ui.x(2.4), self.ui.y(1), self.ui.w(9), self.ui.h("popUp")), [], callback=self.layerPopUpCallback) self.w.sourceFontPopUp.getNSPopUpButton().setKeyEquivalent_( self.sourceFontKey) self.w.sourceLayerPopUp.getNSPopUpButton().setKeyEquivalent_( self.sourceLayerKey) # target ui self.w.targetFontLabel = vanilla.TextBox( (self.ui.x(), self.ui.y(2) + 1, self.ui.w(2.4), self.ui.h("textBox")), self.targetFontTitle, alignment="right") self.w.targetFontPopUp = vanilla.PopUpButton( (self.ui.x(2.4), self.ui.y(), self.ui.w(9), self.ui.h("popUp")), [], callback=self.fontPopUpCallback) self.w.targetLayerPopUp = vanilla.PopUpButton( (self.ui.x(2.4), self.ui.y(1), self.ui.w(9), self.ui.h("popUp")), [], callback=self.layerPopUpCallback) self.w.targetFontPopUp.getNSPopUpButton().setKeyEquivalent_( self.targetFontKey) self.w.targetLayerPopUp.getNSPopUpButton().setKeyEquivalent_( self.targetLayerKey) # control ui # magic numbers for box fitment and checkbox placement ^ _ ^ bfa = vanilla.Box.allFrameAdjustments vanilla.Box.allFrameAdjustments = {"Box-None": (-13, -4, 24, 0)} self.w.actionBox = vanilla.Box( (self.ui.x(), self.ui.y(2), self.fullWidth, self.ui.h("row") * 2)) vanilla.Box.allFrameAdjustments = bfa # checks self.overwriteGlyphs = mojo.extensions.getExtensionDefault( self.overWriteGlyphsKey, fallback=self.overwriteGlyphs) self.w.glyphsCheckBox = vanilla.CheckBox( (self.ui.x(), self.ui.y() + 11, self.ui.w(7), self.ui.h("checkBox", 1)), self.glyphsCheckBoxTitle, callback=self.glyphsCheckBoxCallback, value=self.overwriteGlyphs, sizeStyle="small") self.overwriteMarks = mojo.extensions.getExtensionDefault( self.overWriteMarksKey, fallback=self.overwriteMarks) self.w.marksCheckBox = vanilla.CheckBox( (self.ui.x(), self.ui.y(1) + 3, self.ui.w(7), self.ui.h("checkBox", 1)), self.marksCheckBoxTitle, callback=self.marksCheckBoxCallback, value=self.overwriteMarks, sizeStyle="small") # copy self.w.copyButton = vanilla.Button((self.ui.x(-4) + 1, self.ui.y(), self.ui.w(4), self.ui.h("button")), self.copyButtonTitle, callback=self.copyButtonCallback) # self.w.copyButton.getNSButton().setKeyEquivalentModifierMask_(AppKit.NSCommandKeyMask) # self.w.copyButton.getNSButton().setKeyEquivalent_(self.copyButtonKey) # bottom margin self.w.resize(self.winWidth, self.ui.y(1.4)) # gobble up open fonts, if any if AllFonts(): self.openFonts = AllFonts() self._refresh() # # self.windowBecameKey() fires for the first time # self.w.open() self.w.center()