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): 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 _build_ui(self): columnDescriptions = [ { "title": "Delete", "cell": vanilla.CheckBoxListCell(), "width": 40 }, { "title": "Description", "typingSensitive": True, "editable": False, "width": 210 }, { "title": "Size", "typingSensitive": True, "editable": False, "width": 60 }, { "title": "Key", "typingSensitive": True, "editable": True, "width": 220 }, { "title": "Location", "typingSensitive": True, "editable": False, "width": 40 }, ] self._width = 640 self._height = 300 self.w = vanilla.Window((self._width, self._height), "UFO Cleaner", (self._width, self._height)) self.w.key_list = vanilla.List( (10, 9, -10, -40), self._libkeys, columnDescriptions=columnDescriptions, drawFocusRing=True, #editCallback=self._setDecompose, doubleClickCallback=self._open_sheet, ) #self.w.xml = CodeEditor((10, -130, -10, -40), "", lexer="xml") self.w.total_size = vanilla.TextBox((10, -30, 240, 20), "") self._update_total_size_display() self.w.action_button = vanilla.Button( (-200, -30, -10, 20), "Delete checked items from UFO", callback=self._clean_ufo, sizeStyle="small", ) self._sheet = False self.setUpBaseWindowBehavior() self.w.open()
def __init__(self): f = CurrentFont() if f is None: return if f.path is None: print("Save this font first!") return self.designSpaceModel = f.lib.get(self.designSpaceModelLibKey, "twobytwo") #print "self.designSpaceModel", self.designSpaceModel if self.designSpaceModel == "twobytwo": self.masterNames = [ 'narrow-thin', 'wide-thin', 'narrow-bold', 'wide-bold' ] elif self.designSpaceModel == "twobyone": self.masterNames = ['narrow-thin', 'wide-thin'] rgbBlack = NSColor.colorWithDeviceRed_green_blue_alpha_(0, 0, 0, 1) rgbWhite = NSColor.colorWithDeviceRed_green_blue_alpha_( 255, 255, 255, 1) self.shapeColor = rgbWhite self.backgroundColor = rgbBlack self.extrapolateMinValue = 0 self.extrapolateMaxValue = 1 self.w = vanilla.Window((500, 600), "Responsive Lettering", minSize=(300, 200)) self.w.preview = HTMLView((0, 0, -0, -140)) self.w.exportButton = vanilla.Button((-150, -30, -10, 20), "Export SVG", callback=self.cbExport) columnDescriptions = [ dict(title="Glyphname", key="name", width=125), dict(title="Width", key="width", width=50), dict(title="Height", key="height", width=50), dict(title="Bounds?", key="bounds", width=75), dict(title="Contours", key="contours", width=50), dict(title="Points", key="points", width=50), ] self.w.l = vanilla.List((0, -140, -0, -40), self.wrapGlyphs(), columnDescriptions=columnDescriptions, doubleClickCallback=self.callbackListClick) self.w.t = vanilla.TextBox((70, -27, -160, 20), "FontName", sizeStyle="small") self.w.backgroundColorWell = vanilla.ColorWell( (10, -30, 20, 20), callback=self.backgroundColorWellCallback, color=rgbBlack) self.w.shapeColorWell = vanilla.ColorWell( (35, -30, 20, 20), callback=self.shapeColorWellCallback, color=rgbWhite) self.w.bind("became main", self.windowBecameMainCallback) self.setColorsFromLib() self.update() self.w.open() self.cbMakePreview(None)
def __init__(self, fonts): self.fonts = fonts self.w = vanilla.Window((1200, 600), minSize=(100, 100)) _, _, w_width, w_height = self.w.getPosSize() prev_height = w_height / 3 self.w.allFontsGroup = vanilla.Group((0, 0, -0, prev_height)) self.steps = len(self.fonts) step = w_width / self.steps for f_index, f in enumerate(self.fonts): x = step * f_index control = DrawPair((x, 0, step, -0)) self.kern_list = list(f.kerning.keys()) initial_pair = self.kern_list[0] kern_value = f.kerning.get(initial_pair, 0) repr_pair = get_repr_pair(f, initial_pair) repr_glyphs = [f[g_name] for g_name in repr_pair] control.setGlyphData_kerning(repr_glyphs, kern_value) setattr(self.w.allFontsGroup, 'pair_{}'.format(f_index), control) display_list = [', '.join(pair) for pair in self.kern_list] list_height = w_height - prev_height self.w.myList = vanilla.List( (0, -list_height, -0, -0), display_list, allowsMultipleSelection=False, selectionCallback=self.list_callback, ) self.w.bind('resize', self.resize_callback) self.w.open()
def __init__(self): self.w = vanilla.Window((200, 400)) buttons = [ "message", "messageSheet", "askYesNo", "askYesNoCallback", "askYesNoSheet", "askYesNoCancel", "askYesNoCancelCallback", "askYesNoCancelSheet", "getFile", "getFileSheet", "getFolder", "getFolderSheet", "getFileOrFolder", "getFileOrFolderSheet", ] y = 10 for b in buttons: obj = vanilla.Button((10, y, -10, 16), b, callback=getattr(self, b), sizeStyle="mini") setattr(self.w, "button_%s" % b, obj) y += 20 self.w.open()
def __init__(self): # Window 'self.w': windowWidth = 250 windowHeight = 190 windowWidthResize = 300 # user can resize width by this value windowHeightResize = 0 # user can resize height by this value self.w = vanilla.Window( (windowWidth, windowHeight), # default window size "Randomly Move Points", # window title minSize=(windowWidth, windowHeight), # minimum size (for resizing) maxSize=(windowWidth + windowWidthResize, windowHeight + windowHeightResize), # maximum size (for resizing) autosaveName= "com.kylewaynebenson.RandomlyMove.mainwindow" # stores last window position and size ) # UI elements: YOffset = 10 self.w.text_1 = vanilla.TextBox((15, YOffset, -15, 30), "Randomly move all points by:", sizeStyle='small') LineHeight = 25 YOffset += LineHeight self.w.text_2 = vanilla.TextBox((15, YOffset, 80, 20), "Range", sizeStyle='regular') self.w.moveRange = vanilla.EditText((65, YOffset, 40, 21), "3", sizeStyle='regular') LineHeight = 30 YOffset += LineHeight self.w.text_3 = vanilla.TextBox((15, YOffset, 80, 20), "Grid", sizeStyle='regular') self.w.moveGrid = vanilla.EditText((65, YOffset, 40, 21), "2", sizeStyle='regular') LineHeight = 30 YOffset += LineHeight self.w.checkBox = CheckBox((15, YOffset, 0, 20), "Only move OCPs", value=False) # Run Button: self.w.runButton = vanilla.Button((-130, -20 - 15, -15, -15), "Shake", sizeStyle='regular', callback=self.RamdonlyMovePoints) self.w.setDefaultButton(self.w.runButton) # Open window and focus on it: self.w.open() self.w.makeKey()
def __init__(self, parentWindow=None): self.needsUpdate = False self.__version__ = __version__ if not getDefault("DrawBotCheckForUpdatesAtStartup", True): return self.currentVersion = getCurrentVersion() self.needsUpdate = StrictVersion(__version__) < StrictVersion(self.currentVersion) if not self.needsUpdate: return if parentWindow: self.w = vanilla.Sheet((450, 130), parentWindow=parentWindow) else: self.w = vanilla.Window((450, 130)) self.w.appIcon = vanilla.ImageView((25, 15, 65, 65)) self.w.appIcon.setImage(imageObject=AppKit.NSApp().applicationIconImage()) title = "There is a new version of DrawBot!" txt = AppKit.NSAttributedString.alloc().initWithString_attributes_(title, {AppKit.NSFontAttributeName: AppKit.NSFont.boldSystemFontOfSize_(0)}) self.w.introBold = vanilla.TextBox((100, 15, -15, 20), txt) self.w.intro = vanilla.TextBox((100, 45, -15, 200), "DrawBot %s is out now (you have %s).\nWould you like to download it now?" % (self.currentVersion, __version__), sizeStyle="small") self.w.cancelButton = vanilla.Button((-270, -30, 60, 20), "Cancel", callback=self.cancelCallback, sizeStyle="small") self.w.cancelButton.bind(".", ["command"]) self.w.cancelButton.bind(unichr(27), []) self.w.openInBrowser = vanilla.Button((-200, -30, 120, 20), "Show In Browser", callback=self.openInBrowserCallback, sizeStyle="small") self.w.okButton = vanilla.Button((-70, -30, 55, 20), "OK", callback=self.okCallback, sizeStyle="small") self.w.setDefaultButton(self.w.okButton) self.w.open()
def __init__(self): self.w = vanilla.Window((400, 400), minSize=(100, 100)) self.w.glyphLineView = GlyphLineView((0, 0, 0, 0), pointSize=None, autohideScrollers=False, showPointSizePlacard=True) events.addObserver(self, "glyphChanged", "currentGlyphChanged") self.glyphChanged(dict(glyph=CurrentGlyph())) self.setUpBaseWindowBehavior() self.w.open()
def __init__(self): self.fontList = AllFonts() self.fontNames = [str(f) for f in self.fontList] self.w = vanilla.Window((300, 220), "Copy Anchors") self.w.fontChoiceTitle0 = vanilla.TextBox((10, 14, -10, 25), "⬇️") self.w.fontChoice0 = vanilla.PopUpButton((40, 10, -10, 25), self.fontNames) self.w.fontChoiceTitle1 = vanilla.TextBox((10, 44, -10, 25), "➡️") self.w.fontChoice1 = vanilla.PopUpButton((40, 40, -10, 25), self.fontNames) if len(self.fontNames) > 1: self.w.fontChoice1.set(1) self.w.glyphTitle = vanilla.TextBox((10, 84, -10, 25), "🔠") self.w.glyphChoice = vanilla.PopUpButton( (40, 80, -10, 25), ["Selected glyphs", "All glyphs"]) self.w.measureTitle = vanilla.TextBox((10, 114, -10, 25), "↔️") self.w.measureChoice = vanilla.PopUpButton( (40, 110, -10, 25), ["Relative to glyph bounds", "Exact copy"]) self.w.clearFist = vanilla.CheckBox((40, 145, -10, 25), "Clear destination anchors first", value=True) self.w.copyButton = vanilla.SquareButton((10, 185, -10, 25), "Copy!", callback=self.copyAnchors) self.w.open()
def __init__( self ): # Window 'self.w': windowWidth = 250 windowHeight = 130 windowWidthResize = 300 # user can resize width by this value windowHeightResize = 0 # user can resize height by this value self.w = vanilla.Window( ( windowWidth, windowHeight ), # default window size "Change Width Centered", # window title minSize = ( windowWidth, windowHeight ), # minimum size (for resizing) maxSize = ( windowWidth + windowWidthResize, windowHeight + windowHeightResize ), # maximum size (for resizing) autosaveName = "com.kylewaynebenson.ChangeWidthCentered.mainwindow" # stores last window position and size ) # UI elements: self.w.text_1 = vanilla.TextBox( (15, 10, -15, 30), "Change new width to:", sizeStyle='small' ) self.w.newWidth = vanilla.EditText( ( 15, 40-1, 50, 21), "750", sizeStyle='regular' ) self.w.checkBox = vanilla.CheckBox((-120, 40, 0, 20), "All layers", value=False) # Run Button: self.w.runButton = vanilla.Button((-130, -20-15, -15, -15), "Change Width", sizeStyle='regular', callback=self.changeWidth ) self.w.setDefaultButton( self.w.runButton ) self.w.open() self.w.makeKey()
def __init__(self): windowWidth = 280 windowHeight = 115 self.w = vanilla.Window( (windowWidth, windowHeight), "Rename glyphs and update features", autosaveName="com.harbortype.RenameGlyphs.mainwindow") self.w.text_1 = vanilla.TextBox((15, 18 + 2, 120, 17), "Find") self.w.findString = vanilla.EditText((120, 18 - 1, -15, 22)) self.w.text_2 = vanilla.TextBox((15, 48 + 2, 120, 17), "Replace with") self.w.replaceString = vanilla.EditText((120, 48 - 1, -15, 22)) self.w.renameButton = vanilla.Button((-130, -35, -15, -15), "Rename", callback=self.Rename) self.w.undoButton = vanilla.Button((15, -35, 115, -15), "Undo", callback=self.Undo) self.w.setDefaultButton(self.w.renameButton) # Load settings if not self.LoadPreferences(): print( "Note: 'Rename Glyphs and Update Features' could not load preferences. Will resort to defaults." ) self.w.open() self.w.makeKey()
def __init__(self): self.color = "#FF0000" self.w = vanilla.Window((500, 600), "MathShape Exporter", minSize=(300, 200)) self.w.preview = HTMLView((0, 0, -0, -200)) self.w.exportButton = vanilla.Button((-150, -30, -10, 20), "Export", callback=self.cbExport) self.w.previewButton = vanilla.Button((10, -30, -160, 20), "Preview", callback=self.cbMakePreview) valueWidth = 50 columnDescriptions = [ dict(title="Glyphname", key="name", width=100), dict(title="Width", key="width"), dict(title="Bounds", key="bounds", width=100), ] self.w.l = vanilla.List((0, -200, -0, -60), self.wrapGlyphs(), columnDescriptions=columnDescriptions) self.w.t = vanilla.TextBox((40, -53, -5, 20), "FontName", sizeStyle="small") self.w.clr = vanilla.ColorWell((10, -55, 20, 20), callback=self.cbColor, color=NSColor.redColor()) self.update() self.w.open()
def _build_ui(self): self.height = 20 + 26 * len(self.settings) self.w = vanilla.Window((self.width, self.height), self._name) i = 0 for key in self.settings_list: setting = self.settings[key] ui_objects = [] if type(setting.default_value) == bool: checkbox = vanilla.CheckBox( (self.column + 10, 10 + 26 * i, -10, 22), setting.name, value = setting.value, callback = self._edit_value, ) setting.ui_object = checkbox ui_objects.append(checkbox) elif type(setting.default_value) == float: slider = vanilla.Slider( (self.column + 10, 10 + 26 * i, -10, 22), value = setting.value, callback = self._edit_value, continuous = False, ) setting.ui_object = slider ui_objects.append(slider) ui_objects.append( vanilla.TextBox( (10, 10 + 26 * i, self.column, 22), setting.name, ) ) for j in range(len(ui_objects)): setattr(self.w, "%s_%i" % (setting.key, j), ui_objects[j]) i += 1
def __init__( self ): # Window 'self.w': windowWidth = 300 windowHeight = 160 windowWidthResize = 500 # user can resize width by this value windowHeightResize = 500 # user can resize height by this value self.w = vanilla.Window( ( windowWidth, windowHeight ), # default window size "Pangram Helper", # window title minSize = ( windowWidth, windowHeight ), # minimum size (for resizing) maxSize = ( windowWidth + windowWidthResize, windowHeight + windowHeightResize ), # maximum size (for resizing) autosaveName = "com.mekkablue.PangramHelper.mainwindow" # stores last window position and size ) # UI elements: self.w.missingLetters = vanilla.TextBox( (15, 12+2, -15, 14), "Missing: %s" % fullAlphabet.upper(), sizeStyle='small' ) self.w.pangram = vanilla.TextEditor( (1, 40, -1, -45), "The quick brown fox jumps over the lazy dog.", checksSpelling=True, callback = self.updateMissingLetters) # Run Button: self.w.copyButton = vanilla.Button((-170, -20-15, -110, -15), "Copy", sizeStyle='regular', callback=self.PangramHelperMain ) self.w.tabButton = vanilla.Button((-100, -20-15, -15, -15), "Open Tab", sizeStyle='regular', callback=self.PangramHelperMain ) self.w.setDefaultButton( self.w.tabButton ) # Load Settings: if not self.LoadPreferences(): print "Note: 'Pangram Helper' could not load preferences. Will resort to defaults" # Open window and focus on it: self.updateMissingLetters() self.w.open() self.w.pangram.selectAll() self.w.makeKey()
def __init__(self): # Window 'self.w': windowWidth = 250 windowHeight = 180 windowWidthResize = 300 # user can resize width by this value windowHeightResize = 0 # user can resize height by this value self.w = vanilla.Window( (windowWidth, windowHeight), # default window size "Create Cast Shadow", # window title minSize=(windowWidth, windowHeight), # minimum size (for resizing) maxSize=(windowWidth + windowWidthResize, windowHeight + windowHeightResize), # maximum size (for resizing) autosaveName= "com.kylewaynebenson.CastShadow.mainwindow" # stores last window position and size ) # UI elements: self.w.text_1 = vanilla.TextBox( (15, 10, -15, 30), "Create Cast shadow that is this many units removed from original drawing:", sizeStyle='small') self.w.text_2 = vanilla.TextBox((15, 60, 20, 20), "X:", sizeStyle='regular') self.w.xAxis = vanilla.EditText((40, 60 - 1, 50, 21), "-20", sizeStyle='regular') self.w.text_3 = vanilla.TextBox((-95, 60, 20, 20), "Y:", sizeStyle='regular') self.w.yAxis = vanilla.EditText((-20 - 50, 60 - 1, -20, 21), "-20", sizeStyle='regular') self.w.text_4 = vanilla.TextBox((15, 90, 52, 20), "Stroke:", sizeStyle='regular') self.w.offset = vanilla.EditText((68, 90 - 1, 50, 21), "4", sizeStyle='regular') self.w.text_5 = vanilla.TextBox((-110, 90, 52, 20), "Gap:", sizeStyle='regular') self.w.gap = vanilla.EditText((-70, 90 - 1, 50, 21), "0", sizeStyle='regular') # Run Button: self.w.runButton = vanilla.Button((-130, -20 - 15, -15, -15), "Create Shadows", sizeStyle='regular', callback=self.CastShadowMain) self.w.setDefaultButton(self.w.runButton) # Open window and focus on it: self.w.open() self.w.makeKey()
def __init__(self): """Window for entering characters you want to find kerning pairs for.""" self.w = vanilla.Window( (400,200), "Extract kern string", minSize=(370,150) ) self.w.textdescription = vanilla.TextBox((15, 12+2, -15, 14), "Search for kern pairs where these characters are on the left:", sizeStyle='small') self.w.kernChars = vanilla.EditText((15, 40, -15, -40), u"Ľľďť", sizeStyle='small') self.w.goButton = vanilla.Button((-80, -30, -15, 17), "Search", sizeStyle='small', callback=self.buttonCallback) self.w.center() self.w.open()
def __init__(self): # Window 'self.w': windowWidth = 600 windowHeight = 200 windowWidthResize = 1200 # user can resize width by this value windowHeightResize = 1200 # user can resize height by this value self.w = vanilla.Window( (windowWidth, windowHeight), # default window size "Font Info Overview", # window title minSize=(windowWidth, windowHeight), # minimum size (for resizing) maxSize=(windowWidth + windowWidthResize, windowHeight + windowHeightResize), # maximum size (for resizing) autosaveName= "com.mekkablue.FontInfoOverview.mainwindow", # stores last window position and size ) # List: self.w.List = vanilla.List( (0, 0, -0, -45), self.listContent(), columnDescriptions=[{ "title": kl[0], "key": kl[1], "editable": True, "width": kl[2] } for kl in keyList], drawVerticalLines=True, enableDelete=True, drawFocusRing=True, # selectionCallback = self.selectedAction, # doubleClickCallback = self.doubleclickedAction, editCallback=self.editAction) # Buttons: self.w.reloadButton = vanilla.Button( (-130 - 90 - 15, -35, -130 - 15 * 2, -15), "Reload", sizeStyle='regular', callback=self.Reload) self.w.applyButton = vanilla.Button((-130 - 15, -35, -15, -15), "Apply Changes", sizeStyle='regular', callback=self.Apply) # self.w.setDefaultButton( self.w.reloadButton ) # Counter: self.w.changeCounter = vanilla.TextBox((15, -31, -250, 16), "Changes: -", sizeStyle='small') self.updateCounter() # open the window self.w.open() self.w.makeKey()
def __init__(self): self.preferences = Preferences() self.w = vanilla.Window((150, 50), 'Equalize Sidebearings') self.w.activation_key_label = vanilla.TextBox((10, 15, -10, 22), 'Short Key:') self.w.activation_key = vanilla.EditText( posSize=(82, 12, -10, 25), text=self.preferences.activation_key, callback=self.edit_text_callback) self.w.open()
def __init__(self): self.debug = False # Glyph and font data self.glyph = None self.LIBKEY = "com.andyclymer.zPosition" self.pointData = {} # dict of x,y,z for each pointID self.tempPath = tempfile.mkstemp()[1] self.tempHTMLPath = self.tempPath + ".html" self.w = vanilla.Window((620, 740), "3D Projection Preview", autosaveName="ProjectionPreview") self.w.bind("resize", self.windowResizedCallback) topHeight = 65 self.w.refreshButton = vanilla.SquareButton( (10, 10, 130, 25), "Reload glyph data", callback=self.refreshPreviewCallback, sizeStyle="small") x = 150 self.w.zoomScaleChoice = vanilla.PopUpButton( (x, 10, 70, 25), ["50%", "75%", "100%", "150%"], sizeStyle="small", callback=self.refreshPreviewCallback) self.w.zoomScaleChoice.set(2) self.w.strokeWidth = vanilla.EditText((x + 90, 10, 40, 25), "90") self.w.strokeWidth.enable(False) self.w.doStrokeBox = vanilla.CheckBox( (x + 140, 10, 100, 25), "Stroke", sizeStyle="small", value=False, callback=self.refreshPreviewCallback) self.w.note = vanilla.TextBox( (10, 43, -10, 25), "Note: Requires an internet connection for the Zdog library to load, http://www.zzz.dog/", sizeStyle="small") # Web view self.w.webView = WebView.alloc().initWithFrame_(((0, 0), (500, 500))) self.w.scroll = vanilla.ScrollView((10, topHeight, -10, -10), self.w.webView, hasHorizontalScroller=False, hasVerticalScroller=False) self.w.open() self.refreshPreviewCallback(None)
def __init__(self): self.w = vanilla.Window((250, 120), "Simple App Window", closable=False) self.w.text = vanilla.TextBox(( 10, 10, -10, 70 ), "This is a simple window. It doesn't do much. You see that button? Press it and some text will be printed in Console.app." ) self.w.button = vanilla.Button((10, 90, -10, 20), "Press me", callback=self.buttonCallback) self.w.open()
def __init__(self): # Window 'self.w': windowWidth = 250 windowHeight = 145 windowWidthResize = 100 # user can resize width by this value windowHeightResize = 0 # user can resize height by this value self.w = vanilla.Window( (windowWidth, windowHeight), # default window size "Replace in Family Name", # window title minSize=(windowWidth, windowHeight), # minimum size (for resizing) maxSize=(windowWidth + windowWidthResize, windowHeight + windowHeightResize), # maximum size (for resizing) autosaveName= "com.harbortype.ReplaceInFamilyName.mainwindow" # stores last window position and size ) # UI elements: linePos, inset, lineHeight = 22, 25, 25 self.w.text_1 = vanilla.TextBox((inset - 1, linePos + 2, 75, 14), "Find:", sizeStyle='small') self.w.find = vanilla.EditText((inset + 80, linePos, -inset, 19), "", sizeStyle='small', callback=self.SavePreferences) linePos += lineHeight self.w.text_2 = vanilla.TextBox((inset - 1, linePos + 2, 75, 14), "Replace with:", sizeStyle='small') self.w.replace = vanilla.EditText((inset + 80, linePos, -inset, 19), "", sizeStyle='small', callback=self.SavePreferences) linePos += lineHeight # Run Button: self.w.runButton = vanilla.Button( (-80 - inset, -20 - inset, -inset, -inset), "Run", sizeStyle='regular', callback=self.ReplaceInFamilyNameMain) self.w.setDefaultButton(self.w.runButton) # Load Settings: if not self.LoadPreferences(): print( "Note: 'Replace in Family Name' could not load preferences. Will resort to defaults" ) # Open window and focus on it: self.w.open() self.w.makeKey()
def __init__(self): width = 300 # Main Window self.w = vanilla.Window((width, 400), "Glyph Proofer", minSize=(width, 300), maxSize=(width, 1000)) # Add a drop-able font list columnDescriptions = [dict(title="path", formatter=UFOPathFormatter.alloc().init())] self.w.fontList = vanilla.List((15, 15, -15, -50), [], columnDescriptions=columnDescriptions, showColumnTitles=False, enableDelete=True, drawFocusRing=False, otherApplicationDropSettings=dict(type=NSFilenamesPboardType, operation=NSDragOperationCopy, callback=self.dropFontCallback)) self.w.makePDFButton = vanilla.Button((-120, -37, -16, 20), "Generate PDF", callback=self.makePDFButtonCallback) self.setUpBaseWindowBehavior() self.w.open()
def __init__(self): global can_display_ui if not can_display_ui: return try: import vanilla except ImportError: Message(message=("Please install vanilla to enable UI dialogs for " "Master Grid. You can install vanilla through " "Glyphs > Preferences > Addons > Modules."), title="Missing Module") can_display_ui = False return self.w = vanilla.Window( (220, 160), "Master Grid", ) y = 8 self.w.master_name = vanilla.TextBox( (8, y, -8, 35), "Set local grid for master:\nNone") y += 46 x = 8 self.w.label_x = vanilla.TextBox((x, y, 30, 17), "X:") self.w.x = vanilla.EditText((x + 22, y - 3, 40, 24)) x = 88 self.w.label_y = vanilla.TextBox((x, y, 30, 17), "Y:") self.w.y = vanilla.EditText((x + 22, y - 3, 40, 24)) y += 28 self.w.grid_type_label = vanilla.TextBox((8, y, 66, 17), "Grid is in:") self.w.grid_type = vanilla.RadioGroup( (74, y, -8, 40), ["Absolute font units", "UPM subdivision"], isVertical=True, ) self.w.button_delete = vanilla.Button( (10, -30, 102, -10), "Remove Grid", callback=self.callback_delete, ) self.w.button_set = vanilla.Button( (118, -30, 74, -10), "Set Grid", callback=self.callback_set, ) self.update() self.w.open() self.w.makeKey()
def __init__(self): self.pdf = None self.w = vanilla.Window((600, 900), "My Interface") self.w.drawButton = vanilla.Button((10, 10, 100, 25), "Draw!", callback=self.draw) self.w.saveButton = vanilla.Button((120, 10, 100, 25), "Save!", callback=self.save) self.w.drawView = db.ui.drawView.DrawView((10, 50, -10, -10)) self.w.open()
def __init__(self): self.w = vanilla.Window((400, 400), "Merz Playground", minSize=(200, 200)) self.w.getNSWindow().setFrameUsingName_(self.windowAutoSaveName) # Code # ---- self.codeGroup = vanilla.Group((0, 0, 0, 0)) self.codeEditor = self.codeGroup.codeEditor = CodeEditor( (0, 0, -0, -45)) self.runButton = self.codeGroup.runButton = vanilla.Button( (15, -35, -15, 20), "Run", callback=self.runCode) self.runButton.bind("r", ["command"]) self.outputEditor = OutPutEditor((0, 0, -0, -0), readOnly=True) paneDescriptions = [ dict(view=self.codeGroup, identifier="codeGroup", minSize=50, canCollapse=False), dict(view=self.outputEditor, identifier="outputEditor", size=100, minSize=50, canCollapse=False), ] self.codeSplitView = vanilla.SplitView((0, 0, 0, 0), paneDescriptions, isVertical=False) # Merz # ---- self.merzView = merz.MerzView((0, 0, 0, 0), backgroundColor=(1, 1, 1, 1)) # Splits # ------ paneDescriptions = [ dict(view=self.codeSplitView, identifier="codeSplitView", minSize=50, canCollapse=False), dict(view=self.merzView, identifier="merzView", minSize=50) ] self.w.splitView = vanilla.SplitView((0, 0, 0, 0), paneDescriptions) self.setUpBaseWindowBehavior() self.w.open()
def __init__(self): self.currentGlyph = None self.w = vanilla.Window((500, 500), "Plist Viewer", minSize=(100, 100)) self.w.xml = CodeEditor((0, 0, -0, -30), "", lexer="xml") self.w.applyButton = vanilla.Button((-70, -25, -20, 22), "Apply", callback=self.applyCallback, sizeStyle="small") addObserver(self, "currentGlyphChanged", "currentGlyphChanged") self.setUpBaseWindowBehavior() self.currentGlyphChanged({}) self.w.open()
def __init__(self): self.currentGlyph = None self.previousGlyph = None self.didSwitch = False # When a glyph change happened because of this extension self.w = vanilla.Window((200, 200)) self.w.bind("close", self.close) #self.w.open() if getExtensionDefault(scriptStateKey, fallback=False): addObserver(self, "draw", "draw") addObserver(self, "drawPreview", "drawPreview") addObserver(self, "drawInactive", "drawInactive") addObserver(self, "mouseDown", "mouseDown") addObserver(self, "viewDidChangeGlyph", "viewDidChangeGlyph")
def __init__( self ): # Window 'self.w': windowWidth = 280 windowHeight = 190 windowWidthResize = 200 # user can resize width by this value windowHeightResize = 200 # user can resize height by this value self.w = vanilla.Window( (windowWidth, windowHeight), # default window size "Sort Instances", # window title minSize = ( windowWidth, windowHeight ), # minimum size (for resizing) maxSize = ( windowWidth + windowWidthResize, windowHeight + windowHeightResize ), # maximum size (for resizing) autosaveName = "com.harbortype.SortInstances.mainwindow" # stores last window position and size ) # UI elements: linePos, inset, lineHeight = 12, 15, 22 # self.w.text_1 = vanilla.TextBox( (inset-1, linePos+2, 75, 14), "inset", sizeStyle='small' ) # linePos += lineHeight listValues = [] for i, (tag, name) in enumerate(self.axes.items()): listValues.append({"Index": i, "Name": name, "Tag": tag}) self.w.list_1 = vanilla.List((inset, linePos, -inset, -inset-20-inset), listValues, columnDescriptions=[ {"title": "Index", "width": 40}, {"title": "Tag", "width": 60}, {"title": "Name"}], allowsMultipleSelection = False, allowsEmptySelection = True, dragSettings=dict(type=genericListPboardType, operation = NSDragOperationMove, # allowDropBetweenRows = True, # allowDropOnRow = False, callback = self.dragCallback), selfDropSettings=dict(type=genericListPboardType, operation = NSDragOperationMove, allowDropBetweenRows = True, # allowDropOnRow = False, callback = self.selfDropCallback)) linePos += lineHeight # Run Button: self.w.runButton = vanilla.Button( (-80-inset, -20-inset, -inset, -inset), "Sort", sizeStyle='regular', callback=self.Process ) self.w.setDefaultButton( self.w.runButton ) # Open window and focus on it: self.w.open() self.w.makeKey()
def __init__(self, text="", tickCount=None, parentWindow=None): if parentWindow is None: self.w = vanilla.Window((250, 60), closable=False, miniaturizable=False, textured=False) else: self.w = vanilla.Sheet((250, 60), parentWindow) if tickCount is None: isIndeterminate = True tickCount = 0 else: isIndeterminate = False self.w.progress = vanilla.ProgressBar((15, 15, -15, 12), maxValue=tickCount, isIndeterminate=isIndeterminate, sizeStyle="small") self.w.text = vanilla.TextBox((15, 32, -15, 14), text, sizeStyle="small") self.w.progress.start() self.w.center() self.setUpBaseWindowBehavior() self.w.open()