def __init__(self): # Window 'self.w': edY = 22 txX = 128 txY = 17 sp = 12 btnX = 80 btnY = 22 windowWidth = sp * 4 + txX + 224 + btnX windowHeight = sp * 6.5 + txY self.w = vanilla.FloatingWindow( (windowWidth, windowHeight), # default window size "adhesiontext Arabic, Layer Color", # window title autosaveName= "com.simonthi.adhesiontextArabic.mainwindow" # stores last window position and size ) arabicDic = open(dicFileLocation, 'r') # UI elements: self.w.text1 = vanilla.TextBox((sp, sp * 1 + txY * 0, txX, txY), "Words: 25", sizeStyle='regular') self.w.words = vanilla.Slider((sp + txX, sp * 1 + txY * 0, 195, txY), value=25, minValue=5, maxValue=200, callback=self.sliderCallback) #UI check color self.w.check = vanilla.CheckBox((sp, sp * 1 + txY * 1.5, txX, txY), "Include color", sizeStyle='regular') # UI color elements: self.w.text2 = vanilla.TextBox((sp, sp * 1 + txY * 3, txX, txY), "Color: red", sizeStyle='regular') self.w.color = vanilla.Slider((sp + txX, sp * 1 + txY * 3, 195, txY), value=0, minValue=0, maxValue=11, callback=self.sliderCallback1) # Run Button: self.w.runButton = vanilla.Button( (-sp - btnX, sp + txY * 3, -sp, btnY), "Get text", sizeStyle='regular', callback=self.typeset) self.w.setDefaultButton(self.w.runButton) # Load Settings: if not self.LoadPreferences(): print "Note: 'adhesiontext Arabic' could not load preferences. Will resort to defaults" # Open window and focus on it: self.w.open() self.w.makeKey()
def __init__(self): try: self.w = vanilla.FloatingWindow((windowWidth, windowHeight), "Cluster Kern Groups") instructions = "To prepare for kerning, we need to automatically set the kern groups. First we will group your glyphs by their left and right edges. Adjust the sliders to change the grouping tolerance. When the groups look reasonable, press 'Proceed'. Alternatively, you can load your existing kern groups." self.w.instr = vanilla.TextBox((10, 10, windowWidth - 10, 45), instructions, "left", sizeStyle='small') self.w.text_anchorL = vanilla.TextBox( (10, 50, windowWidth / 2 - 10, 15), "Left Tolerance", "center", sizeStyle='small') self.w.lSlider = vanilla.Slider( (10, 60, -(10 + windowWidth / 2), 15), 0.01, 500, callback=self.buttonPressed) self.w.text_anchorR = vanilla.TextBox( (windowWidth / 2, 50, windowWidth / 2 - 10, 15), "Right Tolerance", "center", sizeStyle='small') self.w.rSlider = vanilla.Slider( (10 + windowWidth / 2, 60, -10, 15), 0.01, 500, callback=self.buttonPressed) self.w.useMine = vanilla.Button( (windowWidth / 2 - 200, -50, 100, 20), "Just Use Mine", callback=self.useMine) self.w.calculate = vanilla.Button( (windowWidth / 2 - 50, -50, 100, 20), "Calculate", callback=self.buttonPressed) self.w.proceed = vanilla.Button((-120, -50, 100, 20), "Proceed", callback=self.checkModelAndApply) self.w.proceed.enable(False) self.w.progressBar = vanilla.ProgressBar( (10, windowHeight - 20, windowWidth - 20, 10)) self.w.progressBar.set(0) self.w.resultsL = vanilla.TextEditor( (10, 80, windowWidth / 2 - 10, -60)) self.w.resultsR = vanilla.TextEditor( (windowWidth / 2, 80, windowWidth / 2 - 10, -60)) self.w.open() self.lefts = [] self.rights = [] self.loadSidebearings() self.mineUsed = False except Exception, e: print(e)
def __init__(self, parent): self.parent = parent self.w = vanilla.FloatingWindow( (150, 130), "Speed Punk %s" % VERSION, closable=False, autosaveName='de.yanone.speedPunk.%s.prefWindow' % (environment), ) from AppKit import NSHUDWindowMask, NSUtilityWindowMask, NSTitledWindowMask, NSBorderlessWindowMask self.w.getNSWindow().setStyleMask_(0 << 1 | 0 << 2 | NSUtilityWindowMask | NSTitledWindowMask | NSBorderlessWindowMask) self.w.illustrationPositionRadioGroup = vanilla.RadioGroup( (10, 10, -10, 40), ["Outside of glyph", "Outer side of curve"], callback=self.radioGroupCallback, sizeStyle="small") self.w.curveGainTextBox = vanilla.TextBox((10, 60, -10, 17), "Gain", sizeStyle="mini") self.w.curveGainSlider = vanilla.Slider( (10, 70, -10, 25), tickMarkCount=5, callback=self.curveGainSliderCallback, sizeStyle="small", minValue=curveGain[0], maxValue=curveGain[1], value=self.parent.getPreference('curveGain')) if self.parent.getPreference( 'illustrationPosition') == "outsideOfGlyph": self.w.illustrationPositionRadioGroup.set(0) if self.parent.getPreference( 'illustrationPosition') == "outsideOfCurve": self.w.illustrationPositionRadioGroup.set(1) self.w.faderCheckBox = vanilla.CheckBox( (10, 100, -10, 17), "Fader", sizeStyle="small", callback=self.faderCheckBoxCallback) self.w.faderSlider = vanilla.Slider( (10, 125, -10, 25), sizeStyle="small", minValue=0, maxValue=1.0, value=1.0, callback=self.faderSliderCallback, ) self.w.gradientImage = vanilla.ImageView((10, 150, -10, 15)) self.w.histogramImage = vanilla.ImageView((10, 150, -10, 15))
def __init__( self ): # Window 'self.w': edX = 40 edY = 17 txX = 20 txY = 17 slX = 200 spX = 10 spY = 10 btnY = 17 btnX = 60 windowWidth = spX*3+txX+edX+slX windowHeight = spY*6+txY*2+btnY*4 windowWidthResize = 500 self.w = vanilla.FloatingWindow( ( windowWidth, windowHeight ), # default window size "Nudge-Move", # window title minSize = ( windowWidth, windowHeight ), # minimum size (for resizing) maxSize = ( windowWidth + windowWidthResize, windowHeight ), # maximum size (for resizing) autosaveName = "com.Tosche.Nudge-movebyNumericalValue(GUI).mainwindow" # stores last window position and size ) # UI elements: self.w.txX = vanilla.TextBox( (spX, spY, txX, txY), "X:", sizeStyle='small') self.w.txY = vanilla.TextBox( (spX, spY*2+txY, txX, txY), "Y:", sizeStyle='small') self.w.edX = ArrowEditText( (spX+txX, spY, edX, edY), "10", sizeStyle='small', callback=self.textChange) self.w.edY = ArrowEditText( (spX+txX, spY*2+txY, edX, edY), "10", sizeStyle='small', callback=self.textChange) self.w.slX = vanilla.Slider( (spX*2+txX+edX, spY, -spX, edY), sizeStyle='small', minValue=0, maxValue=50, value=10, callback=self.sliderChange) self.w.slY = vanilla.Slider( (spX*2+txX+edX, spY*2+txY, -spX, edY), sizeStyle='small', minValue=0, maxValue=50, value=10, callback=self.sliderChange) # Run Button: self.w.tl = vanilla.SquareButton((spX, spY*3+txY*2, btnX, btnY), u"↖", sizeStyle='small', callback=self.nudgeMove ) self.w.l = vanilla.SquareButton((spX, spY*4+txY*2+btnY, btnX, btnY), u"←", sizeStyle='small', callback=self.nudgeMove ) self.w.dl = vanilla.SquareButton((spX, spY*5+txY*2+btnY*2, btnX, btnY), u"↙", sizeStyle='small', callback=self.nudgeMove ) self.w.t = vanilla.SquareButton((spX*2+btnX, spY*3+txY*2, btnX, btnY), u"↑", sizeStyle='small', callback=self.nudgeMove ) self.w.d = vanilla.SquareButton((spX*2+btnX, spY*5+txY*2+btnY*2, btnX, btnY), u"↓", sizeStyle='small', callback=self.nudgeMove ) self.w.tr = vanilla.SquareButton((spX*3+btnX*2, spY*3+txY*2, btnX, btnY), u"↗", sizeStyle='small', callback=self.nudgeMove ) self.w.r = vanilla.SquareButton((spX*3+btnX*2, spY*4+txY*2+btnY, btnX, btnY), u"→", sizeStyle='small', callback=self.nudgeMove ) self.w.dr = vanilla.SquareButton((spX*3+btnX*2, spY*5+txY*2+btnY*2, btnX, btnY), u"↘", sizeStyle='small', callback=self.nudgeMove ) self.LoadPreferences() # Open window and focus on it: self.w.open() self.w.makeKey()
def __init__( self ): # Window 'self.w': windowWidth = 350 windowHeight = 60 windowWidthResize = 500 # 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 "Adjust Image Alpha for Selected Glyphs", # window title minSize = ( windowWidth, windowHeight ), # minimum size (for resizing) maxSize = ( windowWidth + windowWidthResize, windowHeight + windowHeightResize ), # maximum size (for resizing) autosaveName = "com.mekkablue.AdjustImageAlpha.mainwindow" # stores last window position and size ) # UI elements: self.w.text_1 = vanilla.TextBox( (15-1, 12+2, 75, 14), "Image Alpha:", sizeStyle='small' ) self.w.alphaSlider= vanilla.Slider((100, 12, -55, 19), value=100.0, minValue=10.0, maxValue=100.0, sizeStyle='small', callback=self.AdjustImageAlphaMain ) self.w.indicator = vanilla.TextBox( (-50, 12+2, -15, 14), "100.0", sizeStyle='small' ) # Load Settings: if not self.LoadPreferences(): print("Note: 'Adjust Image Alpha' could not load preferences. Will resort to defaults") # Open window and focus on it: self.w.open() self.w.makeKey()
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 ): windowHeight = 180 self.w = vanilla.FloatingWindow( (350, windowHeight), "Stitcher", minSize=(300, windowHeight), maxSize=(500, windowHeight), autosaveName="com.mekkablue.ComponentsOnNodes.mainwindow" ) inset = 15 linePos = 14 lineGap = 22 self.w.text_1 = vanilla.TextBox( (inset, linePos, 100, 14), "Place component:", sizeStyle='small' ) self.w.componentName = vanilla.EditText( (inset+100, linePos, -15, 20), "_circle", sizeStyle='small', callback=self.SavePreferences ) linePos += lineGap self.w.text_2 = vanilla.TextBox( (inset, linePos, 15+95, 14), "At intervals of:", sizeStyle='small' ) self.w.sliderMin = vanilla.EditText( ( inset+100, linePos, 50, 20), "30", sizeStyle='small', callback=self.SavePreferences ) self.w.sliderMax = vanilla.EditText( (-inset-50, linePos, -15, 20), "60", sizeStyle='small', callback=self.SavePreferences ) self.w.intervalSlider= vanilla.Slider((inset+100+50+10, linePos, -inset-50-10, 20), value=0, minValue=0.0, maxValue=1.0, sizeStyle='small', callback=self.ComponentOnLinesMain ) linePos += lineGap self.w.liveSlider = vanilla.CheckBox((inset, linePos, -inset, 20), "Live slider", value=False, sizeStyle='small' ) linePos += lineGap self.w.useBackground = vanilla.CheckBox((inset, linePos, -inset, 20), "Keep paths in background", value=True, sizeStyle='small', callback=self.SavePreferences ) linePos += lineGap self.w.balanceOverCompletePath = vanilla.CheckBox( (inset, linePos, -inset, 20), u"Balance components over complete path", value=False, callback=self.SavePreferences, sizeStyle='small' ) self.w.runButton = vanilla.Button((-80-inset, -20-inset, -inset, -inset), "Stitch", sizeStyle='regular', callback=self.ComponentOnLinesMain ) self.w.setDefaultButton( self.w.runButton ) try: self.LoadPreferences() except: pass self.w.open() self.w.makeKey()
def __init__( self ): windowHeight = 150 self.w = vanilla.FloatingWindow( (350, windowHeight), "Stitcher", minSize=(300, windowHeight), maxSize=(500, windowHeight), autosaveName="com.mekkablue.ComponentsOnNodes.mainwindow" ) self.w.text_1 = vanilla.TextBox( (15-1, 12+2, 15+95, 14), "Place component:", sizeStyle='small' ) self.w.text_2 = vanilla.TextBox( (15-1, 12+25+2, 15+95, 14), "At intervals of:", sizeStyle='small' ) self.w.componentName = vanilla.EditText( (15+100, 12-1, -15, 19), "circle", sizeStyle='small', callback=self.SavePreferences ) self.w.sliderMin = vanilla.EditText( ( 15+100, 12+25-1, 50, 19), "30", sizeStyle='small', callback=self.SavePreferences ) self.w.sliderMax = vanilla.EditText( (-15-50, 12+25-1, -15, 19), "60", sizeStyle='small', callback=self.SavePreferences ) self.w.intervalSlider= vanilla.Slider((15+100+50+10, 12+25, -15-50-10, 19), value=0, minValue=0.0, maxValue=1.0, sizeStyle='small', callback=self.ComponentOnLinesMain ) #self.w.replaceComponents = vanilla.CheckBox((15+3, 12+25+25, -15, 19), "Replace existing components", value=True, sizeStyle='small', callback=self.SavePreferences ) self.w.liveSlider = vanilla.CheckBox((15+3, 12+25+25, -15, 19), "Live slider", value=False, sizeStyle='small' ) self.w.useBackground = vanilla.CheckBox((15+3, 12+25+25+20, -15, 19), "Keep paths in background", value=True, sizeStyle='small', callback=self.SavePreferences ) self.w.runButton = vanilla.Button((-80-15, -20-15, -15, -15), "Stitch", sizeStyle='regular', callback=self.ComponentOnLinesMain ) self.w.setDefaultButton( self.w.runButton ) try: self.LoadPreferences() except: pass self.w.open()
def __init__( self ): # Window 'self.w': windowWidth = 250 windowHeight = 240 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 "New Tab with Small Paths", # window title minSize = ( windowWidth, windowHeight ), # minimum size (for resizing) maxSize = ( windowWidth + windowWidthResize, windowHeight + windowHeightResize ), # maximum size (for resizing) autosaveName = "com.mekkablue.FindSmallPaths.mainwindow" # stores last window position and size ) # UI elements: linePos, inset, lineHeight = 12, 15, 22 self.w.text_1 = vanilla.TextBox( (inset, linePos, -inset, 30), u"Open new tab with glyphs that contain paths with an area smaller than:", sizeStyle='small' ) linePos += lineHeight*1.7 self.w.minArea = vanilla.TextBox( (inset, linePos, -inset, 15+3), u"1000 square units", sizeStyle = 'small', alignment="center") linePos += lineHeight self.w.sliderMin = vanilla.EditText( ( inset, linePos, 50, 19), "10", sizeStyle='small', callback=self.SliderUpdate ) self.w.sliderMax = vanilla.EditText( (-inset-50, linePos, -inset, 19), "10000", sizeStyle='small', callback=self.SliderUpdate ) self.w.areaSlider= vanilla.Slider((inset+50+10, linePos, -inset-50-10, 19), value=0.1, minValue=0.0, maxValue=1.0, sizeStyle='small', callback=self.SliderUpdate ) linePos += lineHeight self.w.deleteThemRightAway = vanilla.CheckBox( (inset, linePos, -inset, 20), u"Delete Small Paths Right Away", value=False, callback=self.CheckBoxUpdate, sizeStyle='small' ) linePos += lineHeight self.w.afterOverlapRemoval = vanilla.CheckBox( (inset, linePos, -inset, 20), u"After Decomposition and Overlap Removal (slower)", value=True, callback=self.CheckBoxUpdate, sizeStyle='small' ) linePos += lineHeight self.w.allFonts = vanilla.CheckBox( (inset, linePos, -inset, 20), u"Apply to all open fonts", value=False, callback=self.SavePreferences, sizeStyle='small' ) 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((-120, -20-inset, -inset, -inset), u"Open Tab", sizeStyle='regular', callback=self.FindSmallPathsMain ) self.w.setDefaultButton( self.w.runButton ) # Load Settings: if not self.LoadPreferences(): print "Note: 'Find Small Paths' could not load preferences. Will resort to defaults" self.CheckBoxUpdate(None) self.SliderUpdate(None) # Open window and focus on it: self.w.open() self.w.makeKey()
def __init__(self): # Window 'self.w': windowWidth = 360 windowHeight = 60 windowWidthResize = 200 # 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 "Add Point Along Segment", # window title minSize=(windowWidth, windowHeight), # minimum size (for resizing) maxSize=(windowWidth + windowWidthResize, windowHeight + windowHeightResize), # maximum size (for resizing) autosaveName= "com.harbortype.AddPointAlongSegment.mainwindow" # stores last window position and size ) # UI elements: linePos, inset, lineHeight = 12, 15, 22 buttonWidth = 80 self.w.time = vanilla.Slider( (inset, linePos, -inset * 3 - buttonWidth - 40, 23), minValue=0.0, maxValue=1.0, tickMarkCount=3, callback=self.UpdateEditText, sizeStyle='regular') self.w.edit_1 = vanilla.EditText( (-inset * 2 - buttonWidth - 40, linePos, -inset * 2 - buttonWidth, 19), "insert text here", sizeStyle='small', callback=self.UpdateSlider) # linePos += lineHeight # Run Button: self.w.runButton = vanilla.Button( (-buttonWidth - inset, linePos + 1, -inset, 17), "Add point", sizeStyle='regular', callback=self.Main) self.w.setDefaultButton(self.w.runButton) # Load Settings: if not self.LoadPreferences(): print( "Note: 'Add Point Along Segment' could not load preferences. Will resort to defaults" ) # Open window and focus on it: self.w.open() self.w.makeKey()
def __init__(self): self.font = Font if self.font is None: Message("No font selected", "Select a font project!") return self.currentPair = "" self.update_current_pair() self.currentKerningValue = self.font.kerningForPair( self.font.selectedFontMaster.id, self.currentPair[0], self.currentPair[1]) if self.currentKerningValue is None: self.currentKerningValue = 0 self.oldKerningValue = int(self.currentKerningValue) Glyphs.addCallback(self.ui_update, UPDATEINTERFACE) if not self.font.currentTab: self.font.newTab("AV") self.font.currentTab.textCursor = 1 self.w = vanilla.FloatingWindow((0, 0), "Kerning slider") self.ypos = 10 self.w.pairTitle = vanilla.TextBox( (10, self.ypos, -10, 17), self.currentPair[0] + " – " + self.currentPair[1], alignment="center") self.ypos += 20 self.w.kernSlider = vanilla.Slider((10, self.ypos, -10, 23), minValue=-20, maxValue=20, tickMarkCount=41, value=self.currentKerningValue, stopOnTickMarks=True, callback=self.enter_kern_value) self.ypos += 30 self.update_slider_values(self.currentKerningValue, True) self.w.bind("close", self.window_close) self.w.resize(300, self.ypos) self.w.open()
def __init__( self ): # Window 'self.w': windowWidth = 350 windowHeight = 90 windowWidthResize = 700 # 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 "OTVar Player", # window title minSize = ( windowWidth, windowHeight ), # minimum size (for resizing) maxSize = ( windowWidth + windowWidthResize, windowHeight + windowHeightResize ), # maximum size (for resizing) autosaveName = "com.mekkablue.OTVarGlyphAnimator.mainwindow" # stores last window position and size ) # UI elements: self.w.slider = vanilla.Slider( (15,12,-15,15), tickMarkCount=None, callback=self.redrawPreview, continuous=True, sizeStyle="regular", minValue=0, maxValue=100 ) self.w.slower = vanilla.Button((15, -20-15, 47, -15), u"🚶", sizeStyle='regular', callback=self.slower ) self.w.slower.getNSButton().setToolTip_("Slower") self.w.faster = vanilla.Button((65, -20-15, 47, -15), u"🏃", sizeStyle='regular', callback=self.faster ) self.w.faster.getNSButton().setToolTip_("Faster") self.w.backAndForth = vanilla.CheckBox( (125, -20-15, 50, -15), u"⇋", value=False, callback=self.SavePreferences, sizeStyle='small' ) # web button: self.w.buildWeb = vanilla.Button((-140,-35, -100,-15), u"🌍", sizeStyle='regular', callback=self.buildWeb ) # Run Button: self.w.runButton = vanilla.Button((-95, -35, -15, -15), "Play", sizeStyle='regular', callback=self.togglePlay ) self.w.runButton.getNSButton().setToolTip_("Toggle Play/Pause") self.w.setDefaultButton( self.w.runButton ) # Load Settings: if not self.LoadPreferences(): print "Note: 'OTVar Glyph Animator' could not load preferences. Will resort to defaults" self.direction = 1 self.font = Glyphs.font self.originalWeightValue = None self.isPlaying = False if self.font.instances: self.originalWeightValue = self.font.instances[0].weightValue self.w.bind("close",self.restoreFont) # open and initialize the preview area at the bottom self.redrawPreview(None) # Open window and focus on it: self.w.open() self.w.makeKey()
def __init__(self): # Window 'self.w': edY = 22 txX = 85 txY = 17 sp = 12 btnX = 80 btnY = 22 windowWidth = sp * 4 + txX + 195 + btnX windowHeight = sp * 2.5 + txY self.w = vanilla.FloatingWindow( (windowWidth, windowHeight), # default window size "adhesiontext Arabic", # window title autosaveName= "com.Tosche.adhesiontextArabic.mainwindow" # stores last window position and size ) arabicDic = open(dicFileLocation, 'r') # UI elements: self.w.text1 = vanilla.TextBox((sp, sp * 1 + txY * 0, txX, txY), "Words: 25", sizeStyle='regular') self.w.words = vanilla.Slider((sp + txX, sp * 1 + txY * 0, 195, txY), value=25, minValue=5, maxValue=200, callback=self.sliderCallback) # Run Button: self.w.runButton = vanilla.Button((-sp - btnX, sp, -sp, btnY), "Get text", sizeStyle='regular', callback=self.typeset) self.w.setDefaultButton(self.w.runButton) # Load Settings: if not self.LoadPreferences(): print( "Note: 'adhesiontext Arabic' could not load preferences. Will resort to defaults" ) self.w.words.getNSSlider().setVertical_(False) # Open window and focus on it: self.w.open() self.w.makeKey()
def __init__(self): # Window 'self.w': edY = 22 txY = 17 sp = 8 btnX = 100 btnY = 22 windowWidth = 230 windowHeight = 100 windowWidthResize = 100 # 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 "Close Tabs with Few Glyphs", # window title autosaveName= "com.Tosche.CloseTabswithFewGlyphs.mainwindow" # stores last window position and size ) # UI elements: self.w.text = vanilla.TextBox((sp, sp, 230, txY), "Close tabs with 3 glyphs or fewer") self.w.glyphsCount = vanilla.Slider((sp, sp * 2 + edY, -sp, edY), tickMarkCount=10, stopOnTickMarks=True, minValue=1, maxValue=10, value=3, callback=self.updateText) # Run Button: self.w.runButton = vanilla.Button( (-sp - btnX, sp * 3 + edY * 2, -sp, btnY), "Close", sizeStyle='regular', callback=self.CloseTabs) self.w.setDefaultButton(self.w.runButton) # Load Settings: if not self.LoadPreferences(): print( "Note: 'Close Tabs with Few Glyphs' could not load preferences. Will resort to defaults" ) # Open window and focus on it: self.w.open() self.w.makeKey()
def __init__(self): self.currentGlyph = None self.window = None self.fonts = [] self.fontNames = [] self.glyph0 = RGlyph() #None self.glyph1 = RGlyph() #None self.compatibilityReport = None self.interpolatedGlyph = RGlyph() self.w = vanilla.FloatingWindow((250, 155), "Interpolation Slider") self.w.open() self.w.title = vanilla.TextBox((10, 10, -10, 25), "Masters:", sizeStyle="small") self.w.font0 = vanilla.PopUpButton((10, 25, -10, 25), [], callback=self.glyphChanged, sizeStyle="small") self.w.font1 = vanilla.PopUpButton((10, 50, -10, 25), [], callback=self.glyphChanged, sizeStyle="small") self.w.compatibilityText = vanilla.TextBox((-105, 83, 100, 35), u"Compatibility: ⚪️", sizeStyle="small") self.w.line = vanilla.HorizontalLine((5, 110, -5, 1)) self.w.interpValue = vanilla.Slider((10, 120, -10, 25), callback=self.optionsChanged, minValue=0, maxValue=1) self.w.interpValue.set(0.5) self.w.bind("close", self.closed) self.collectFonts() self.glyphChanged(None) addObserver(self, "glyphChanged", "currentGlyphChanged") addObserver(self, "fontsChanged", "newFontDidOpen") addObserver(self, "fontsChanged", "fontDidOpen") addObserver(self, "fontsChanged", "fontDidClose") addObserver(self, "drawBkgnd", "drawBackground") addObserver(self, "drawPreview", "drawPreview")
def createWindow(controls, fn): winWidth = 300 winHeight = 40 * (1 + len(controls)) + 20 myWindow = vanilla.FloatingWindow((winWidth, winHeight), "Sans-o-Matic") x = 10 y = 10 for k in controls: v = controls[k] label = vanilla.TextBox((x, y, 150, 30), k) x = x + 120 def controlCallback(s): for k2 in controls: v2 = controls[k2] controls[k2]["value"] = getattr(myWindow, k2).get() clearLayer() fn(controls) if v['type'] == "Slider": control = vanilla.Slider((x, y, -10, 30), minValue=v['min'], maxValue=v['max'], value=v['default'], callback=controlCallback) elif v['type'] == "CheckBox": control = vanilla.CheckBox((x, y, 10, 10), "", callback=controlCallback) setattr(myWindow, k, control) setattr(myWindow, k + "label", label) y = y + 40 x = 10 def dismiss(s): myWindow.close() myWindow = None myWindow.dismiss = vanilla.Button((-75, y, -15, -15), "OK", sizeStyle='regular', callback=dismiss) fn(controls) myWindow.open()
def __init__(self): self.widthValue = 55 # create a window self.w = vanilla.Window((300, 70), "Simple Observer") # add a button with a title and a callback self.w.startStopButton = vanilla.Button( (10, 10, -10, 22), "Start", callback=self.startStopButtonCallback) self.w.widthSlider = vanilla.Slider((10, 40, -10, 22), value=self.widthValue, minValue=10, maxValue=MAXWIDTH, callback=self.widthSliderCallback) # setup basic windwo behavoir (this is an method from the BaseWindowController) self.setUpBaseWindowBehavior() # open the window self.w.open()
def __init__(self, font): self.font = font self.glyphs = [ font[k] for k in font.unicodeData.sortGlyphNames( font.keys(), glyphSortDescriptors) ] self.w = vanilla.Window((700, 500), minSize=(400, 400)) self.w.tabs = vanilla.Tabs((10, 10, -10, -10), [ "Window", "GlyphCollectionView", "GlyphView", "GlyphLineView", "Misc. Controls" ]) self.windowTab = self.w.tabs[0] self.collectionViewTab = self.w.tabs[1] self.glyphViewTab = self.w.tabs[2] self.lineViewTab = self.w.tabs[3] self.controlsTab = self.w.tabs[4] # test various window methods self.windowTab.messageButton = vanilla.Button( (10, 10, 200, 20), "Show Message", callback=self.windowMessage) self.windowTab.progress1Button = vanilla.Button( (10, 40, 200, 20), "Show Progress 1", callback=self.windowProgress1) self.windowTab.progress2Button = vanilla.Button( (10, 70, 200, 20), "Show Progress 2", callback=self.windowProgress2) self.windowTab.askYesNoButton = vanilla.Button( (10, 100, 200, 20), "Show Ask Yes No", callback=self.windowAskYesNo) self.windowTab.putFileButton = vanilla.Button( (10, 130, 200, 20), "Show Put File", callback=self.windowPutFile) self.windowTab.getFileButton = vanilla.Button( (10, 160, 200, 20), "Show Get File", callback=self.windowGetFile) # test cell view selfDropSettings = dict(callback=self.collectionViewSelfDropCallback) dropSettings = dict(callback=self.collectionViewOtherDropCallback, allowDropBetweenRows=False) self.collectionViewTab.collectionViewModifyButton = vanilla.Button( (10, 10, 150, 20), "Modify Glyphs", callback=self.collectionViewModify) self.collectionViewTab.collectionViewSizeSlider = vanilla.Slider( (170, 10, 150, 20), minValue=10, maxValue=100, value=50, continuous=False, callback=self.collectionViewResize) self.collectionViewTab.collectionView = GlyphCollectionView( (10, 40, -10, -10), allowDrag=True, selectionCallback=self.collectionViewSelectionCallback, doubleClickCallback=self.collectionViewDoubleClickCallback, deleteCallback=self.collectionViewDeleteCallback, selfDropSettings=selfDropSettings, selfApplicationDropSettings=dropSettings) self.collectionViewTab.collectionView.set(self.glyphs) self.collectionViewResize( self.collectionViewTab.collectionViewSizeSlider) # test glyph view self.glyphViewTab.collectionView = GlyphCollectionView( (10, 10, 66, -10), allowDrag=False, selectionCallback=self.glyphViewCollectionSelectionCallback, showModePlacard=False) self.glyphViewTab.glyphView = GlyphView((76, 10, -10, -10)) self.glyphViewTab.collectionView.set(self.glyphs) self.glyphViewTab.collectionView.setSelection([0]) # test line view self.lineViewTab.lineViewSizeSlider = vanilla.Slider( (-160, 11, 150, 20), minValue=10, maxValue=500, value=100, continuous=True, callback=self.lineViewResize) self.lineViewTab.textInput = GlyphSequenceEditText( (10, 10, -170, 22), self.font, callback=self.lineViewTextInput) self.lineViewTab.lineView = GlyphLineView((10, 40, -10, -10)) # test controls self.controlsTab.glyphNameComboBox = GlyphNameComboBox( (10, 10, -10, 22), self.font) self.controlsTab.featureTextEditor = FeatureTextEditor( (10, 45, -10, -10), self.font.features.text) self.setUpBaseWindowBehavior() self.w.tabs.set(3) self.w.open()
def __init__(self): edX = 40 txX = 70 sliderY = 18 spX = 10 windowWidth = 350 windowHeight = 260 windowWidthResize = 3000 # user can resize width by this value windowHeightResize = 3000 # user can resize height by this value self.w = vanilla.FloatingWindow( (windowWidth, windowHeight), # default window size "Instance Slider", # window title minSize=(windowWidth, windowHeight), # minimum size (for resizing) maxSize=(windowWidth + windowWidthResize, windowHeight + windowHeightResize), # maximum size (for resizing) autosaveName= "com.Tosche.InstanceSlider.mainwindow" # stores last window position and size ) # UI elements: YOffset = 27 self.w.add = vanilla.Button((6, -YOffset, 24, 20), "+", callback=self.addDelButtons) self.w.delete = vanilla.Button((34, -YOffset, 24, 20), u"–", callback=self.addDelButtons) self.w.revert = vanilla.Button((62, -YOffset, 60, 20), "Revert", callback=self.revert) LineHeight = 26 YOffset += LineHeight if slider1Min != slider1Max: self.w.textY = vanilla.TextBox((spX, -YOffset, txX, 14), "WeightY", sizeStyle='small') self.w.checkY = vanilla.CheckBox( (txX - spX, -YOffset - 3, -10, 18), "", sizeStyle='small', callback=self.checkboxY, value=False) self.w.sliderY = vanilla.Slider( (spX + txX, -YOffset, -spX * 2 - edX, sliderY), minValue=slider1Min, maxValue=slider1Max, tickMarkCount=5, sizeStyle="small", callback=self.slide, continuous=True) self.w.editY = vanilla.EditText( (-spX - edX, -YOffset, edX, sliderY), "0", sizeStyle='small', callback=self.typeValue) YOffset += LineHeight if slider3Min != slider3Max: self.w.text3 = vanilla.TextBox((spX, -YOffset, txX, 14), "Custom", sizeStyle='small') self.w.slider3 = vanilla.Slider( (spX + txX, -YOffset, -spX * 2 - edX, sliderY), minValue=slider3Min, maxValue=slider3Max, tickMarkCount=5, sizeStyle="small", callback=self.slide, continuous=True) self.w.edit3 = vanilla.EditText( (-spX - edX, -YOffset, edX, sliderY), "0", sizeStyle='small', callback=self.typeValue) YOffset += LineHeight if slider2Min != slider2Max: self.w.text2 = vanilla.TextBox((spX, -YOffset, txX, 14), "Width", sizeStyle='small') self.w.slider2 = vanilla.Slider( (spX + txX, -YOffset, -spX * 2 - edX, sliderY), minValue=slider2Min, maxValue=slider2Max, tickMarkCount=5, sizeStyle="small", callback=self.slide, continuous=True) self.w.edit2 = vanilla.EditText( (-spX - edX, -YOffset, edX, sliderY), "0", sizeStyle='small', callback=self.typeValue) YOffset += LineHeight if slider1Min != slider1Max: self.w.text1 = vanilla.TextBox((spX, -YOffset, txX, 14), "Weight", sizeStyle='small') self.w.slider1 = vanilla.Slider( (spX + txX, -YOffset, -spX * 2 - edX, sliderY), minValue=slider1Min, maxValue=slider1Max, tickMarkCount=5, sizeStyle="small", callback=self.slide, continuous=True) self.w.edit1 = vanilla.EditText( (-spX - edX, -YOffset, edX, sliderY), "0", sizeStyle='small', callback=self.typeValue) YOffset += LineHeight self.w.list = vanilla.List((0, 0, -0, -(YOffset - 18)), insList, selectionCallback=self.listClick, allowsMultipleSelection=False, allowsEmptySelection=False, columnDescriptions=[{ "title": "Instance", "width": self.w.getPosSize()[2] - 215 }, { "title": "Weight", "width": 50 }, { "title": "Width", "width": 50 }, { "title": "Custom", "width": 50 }, { "title": "WeightY", "width": 50 }]) self.w.list._nsObject.setBorderType_(NSNoBorder) tableView = self.w.list._tableView tableView.setAllowsColumnReordering_(False) tableView.unbind_( "sortDescriptors") # Disables sorting by clicking the title bar tableView.tableColumns()[0].setResizingMask_(1) tableView.tableColumns()[1].setResizingMask_(0) tableView.tableColumns()[2].setResizingMask_(0) tableView.tableColumns()[3].setResizingMask_(0) # setResizingMask_() 0=Fixed, 1=Auto-Resizable (Not user-resizable). There may be more options? tableView.setColumnAutoresizingStyle_(5) # AutoresizingStyle: # 0 Disable table column autoresizing. # 1 Autoresize all columns by distributing space equally, simultaneously. # 2 Autoresize each table column sequentially, from the last auto-resizable column to the first auto-resizable column; proceed to the next column when the current column has reached its minimum or maximum size. # 3 Autoresize each table column sequentially, from the first auto-resizable column to the last auto-resizable column; proceed to the next column when the current column has reached its minimum or maximum size. # 4 Autoresize only the last table column. When that table column can no longer be resized, stop autoresizing. Normally you should use one of the sequential autoresizing modes instead. # 5 Autoresize only the first table column. When that table column can no longer be resized, stop autoresizing. Normally you should use one of the sequential autoresizing modes instead. self.w.line = vanilla.HorizontalLine((0, -(YOffset - 18), -0, 1)) # Open window and focus on it: self.w.open() self.w.makeKey() # initialisation: # set the first instance in preview if there is an instance # set the slider and text # set preview area if closed # redraw uiList = self.w.list if len(font.instances) > 0: if not font.tabs: font.newTab("HALOGEN halogen 0123") if font.currentTab.previewHeight <= 1.0: font.currentTab.previewHeight = 150 self.setupSliders(font.instances[0], uiList[0])
def __init__(self): edX = 40 txX = 70 sliderY = 18 spX = 10 axisX = 60 windowWidth = 350 windowHeight = 260 windowWidthResize = 3000 # user can resize width by this value windowHeightResize = 3000 # user can resize height by this value self.w = vanilla.FloatingWindow( (windowWidth, windowHeight), # default window size "Instance Slider", # window title minSize=(windowWidth, windowHeight), # minimum size (for resizing) maxSize=(windowWidth + windowWidthResize, windowHeight + windowHeightResize), # maximum size (for resizing) autosaveName= "com.Tosche.InstanceSlider.mainwindow" # stores last window position and size ) YOffset = 27 self.w.add = vanilla.Button((6, -YOffset, 24, 20), "+", callback=self.addDelButtons) self.w.delete = vanilla.Button((34, -YOffset, 24, 20), "–", callback=self.addDelButtons) self.w.revert = vanilla.Button((62, -YOffset, 60, 20), "Revert", callback=self.revert) global av LineHeight = 26 YOffset += LineHeight axisCount = len([v for v in av if v[0] != ""]) self.w.textY = vanilla.TextBox((spX, -YOffset, txX, 14), "WeightY", sizeStyle='small') self.w.checkY = vanilla.CheckBox((txX - spX, -YOffset - 3, -10, 18), "", sizeStyle='small', callback=self.checkboxY, value=False) self.w.sliderY = vanilla.Slider( (spX + txX, -YOffset, -spX * 2 - edX, sliderY), minValue=av[0][1], maxValue=av[0][2], tickMarkCount=5, sizeStyle="small", callback=self.slide, continuous=True) self.w.editY = vanilla.EditText((-spX - edX, -YOffset, edX, sliderY), "0", sizeStyle='small', callback=self.typeValue) YOffset += LineHeight move = -LineHeight * 2 move -= LineHeight if axisCount == 6 else 0 self.w.text5 = vanilla.TextBox((spX, move, txX, 14), av[5][0], sizeStyle='small') self.w.slider5 = vanilla.Slider( (spX + txX, move, -spX * 2 - edX, sliderY), minValue=av[5][1], maxValue=av[5][2], tickMarkCount=5, sizeStyle="small", callback=self.slide, continuous=True) self.w.edit5 = vanilla.EditText((-spX - edX, move, edX, sliderY), "0", sizeStyle='small', callback=self.typeValue) move -= LineHeight if axisCount >= 5 else 0 self.w.text4 = vanilla.TextBox((spX, move, txX, 14), av[4][0], sizeStyle='small') self.w.slider4 = vanilla.Slider( (spX + txX, move, -spX * 2 - edX, sliderY), minValue=av[4][1], maxValue=av[4][2], tickMarkCount=5, sizeStyle="small", callback=self.slide, continuous=True) self.w.edit4 = vanilla.EditText((-spX - edX, move, edX, sliderY), "0", sizeStyle='small', callback=self.typeValue) move -= LineHeight if axisCount >= 4 else 0 self.w.text3 = vanilla.TextBox((spX, move, txX, 14), av[3][0], sizeStyle='small') self.w.slider3 = vanilla.Slider( (spX + txX, move, -spX * 2 - edX, sliderY), minValue=av[3][1], maxValue=av[3][2], tickMarkCount=5, sizeStyle="small", callback=self.slide, continuous=True) self.w.edit3 = vanilla.EditText((-spX - edX, move, edX, sliderY), "0", sizeStyle='small', callback=self.typeValue) move -= LineHeight if axisCount >= 3 else 0 self.w.text2 = vanilla.TextBox((spX, move, txX, 14), av[2][0], sizeStyle='small') self.w.slider2 = vanilla.Slider( (spX + txX, move, -spX * 2 - edX, sliderY), minValue=av[2][1], maxValue=av[2][2], tickMarkCount=5, sizeStyle="small", callback=self.slide, continuous=True) self.w.edit2 = vanilla.EditText((-spX - edX, move, edX, sliderY), "0", sizeStyle='small', callback=self.typeValue) move -= LineHeight if axisCount >= 2 else 0 self.w.text1 = vanilla.TextBox((spX, move, txX, 14), av[1][0], sizeStyle='small') self.w.slider1 = vanilla.Slider( (spX + txX, move, -spX * 2 - edX, sliderY), minValue=av[1][1], maxValue=av[1][2], tickMarkCount=5, sizeStyle="small", callback=self.slide, continuous=True) self.w.edit1 = vanilla.EditText((-spX - edX, move, edX, sliderY), "0", sizeStyle='small', callback=self.typeValue) move -= LineHeight if axisCount >= 1 else 0 self.w.text0 = vanilla.TextBox((spX, move, txX, 14), av[0][0], sizeStyle='small') self.w.slider0 = vanilla.Slider( (spX + txX, move, -spX * 2 - edX, sliderY), minValue=av[0][1], maxValue=av[0][2], tickMarkCount=5, sizeStyle="small", callback=self.slide, continuous=True) self.w.edit0 = vanilla.EditText((-spX - edX, move, edX, sliderY), "0", sizeStyle='small', callback=self.typeValue) YOffset += LineHeight * axisCount av = [v for v in av if v[0] != ""] axisElements = [ [self.w.text0, self.w.slider0, self.w.edit0], [self.w.text1, self.w.slider1, self.w.edit1], [self.w.text2, self.w.slider2, self.w.edit2], [self.w.text3, self.w.slider3, self.w.edit3], [self.w.text4, self.w.slider4, self.w.edit4], [self.w.text5, self.w.slider5, self.w.edit5], ] for els in axisElements[len(av):]: els[0].show(False) els[1].show(False) els[2].show(False) self.usedAxisElements = axisElements[:len(av)] # TODO: disable WeightY if Weight doesn't exist if "Weight" not in [a[0] for a in av]: self.w.checkY.enable(False) columnTitles = [{ "title": "Instance", "width": self.w.getPosSize()[2] - axisX * (len(av) + 1) }] for i in range(len(av)): columnTitles += [{"title": av[i][0], "width": axisX}] self.w.list = vanilla.List((0, 0, -0, -(YOffset - 18)), insList, selectionCallback=self.listClick, allowsMultipleSelection=False, allowsEmptySelection=False, columnDescriptions=columnTitles) self.w.list._nsObject.setBorderType_(NSNoBorder) tableView = self.w.list._tableView tableView.setAllowsColumnReordering_(False) tableView.unbind_( "sortDescriptors") # Disables sorting by clicking the title bar for i in range(len(av)): if i == 0: tableView.tableColumns()[i].setResizingMask_(1) else: tableView.tableColumns()[i].setResizingMask_(0) # setResizingMask_() 0=Fixed, 1=Auto-Resizable (Not user-resizable). There may be more options? tableView.setColumnAutoresizingStyle_(5) # AutoresizingStyle: # 0 Disable table column autoresizing. # 1 Autoresize all columns by distributing space equally, simultaneously. # 2 Autoresize each table column sequentially, from the last auto-resizable column to the first auto-resizable column; proceed to the next column when the current column has reached its minimum or maximum size. # 3 Autoresize each table column sequentially, from the first auto-resizable column to the last auto-resizable column; proceed to the next column when the current column has reached its minimum or maximum size. # 4 Autoresize only the last table column. When that table column can no longer be resized, stop autoresizing. Normally you should use one of the sequential autoresizing modes instead. # 5 Autoresize only the first table column. When that table column can no longer be resized, stop autoresizing. Normally you should use one of the sequential autoresizing modes instead. self.w.line = vanilla.HorizontalLine((0, -(YOffset - 18), -0, 1)) self.w.open() self.w.makeKey() # initialisation: # set the first instance in preview if there is an instance # set the slider and text # set preview area if closed # redraw uiList = self.w.list if len(f.instances) > 0: if f.currentTab == None: f.newTab("HALOGEN halogen 0123") if f.currentTab.previewHeight <= 20.0: f.currentTab.previewHeight = 150 self.setupSliders(0, uiList[0])
def __init__(self): if Font is None: Message("No font selected", "Select a font project!") return self.font = Font self.font.instances.append(GSInstance()) self.font.instances[-1].name = "Interpolator Preview" self.w = vanilla.FloatingWindow((0, 0), "Interpolation Preview") self.axesRanges = [ ] # create a list to contain tuples with the min and max of an axis self.currentCoords = [] self.sliderList = [] # create a list of the slider objects self.popUpButtonList = [] self.inputFieldList = [] self.instanceName = "Regular" self.selectedClasses = ["Medium (normal)", "Regular"] self.selectedParent = 0 self.namePlaceholder = "Regular" self.styleClasses = { "Weight": { 1: "Hairline", 2: "Thin", 3: "Extralight", 4: "Light", 5: "Regular", 6: "Medium", 7: "Semibold", 8: "Bold", 9: "Extrabold", 10: "Black", 11: "Extrablack" }, "Width": { 1: "Ultra Condensed", 2: "Extra Condensed", 3: "Condensed", 4: "SemiCondensed", 5: "Medium (normal)", 6: "Semi Expanded", 7: "Expanded", 8: "Extra Expanded", 9: "Ultra Expanded" } } for coord in self.font.selectedFontMaster.axes: self.currentCoords.append(int(coord)) for i, axis in enumerate( self.font.axes ): # for each axis in the font, create a new slider self.axesRanges.append( set() ) # for each axis in the font, create an empty tuple to store the axis range for master in self.font.masters: # first, build a list of the axis ranges self.axesRanges[i].add(master.axes[i]) self.axesRanges = [sorted(list(a)) for a in self.axesRanges] for axisRange in self.axesRanges: del axisRange[1:-1] # delete intermediate master coordinates if len(self.axesRanges[i]) == 1: Message( "Please add more than one axis coordinate in your masters.", "Invalid axis coordinates for " + axis.name + " axis") return if str(Glyphs.versionNumber)[0] == "3": axis_tag = axis.axisTag axis_name = axis.name else: axis_tag = axis["Tag"] axis_name = axis["Name"] setattr( self.w, axis_tag + "title", vanilla.TextBox((10, 20 + i * 30, -10, 14), axis_name, sizeStyle="small")) s = vanilla.Slider((60, 20 + i * 30, -70, 15), minValue=sorted(self.axesRanges[i])[0], maxValue=sorted(self.axesRanges[i])[1], value=self.currentCoords[i], callback=self.axis_slider) setattr(self.w, axis_tag + "slider", s) self.sliderList.append(s) t = vanilla.EditText((-60, 20 + i * 30 - 1, -10, 22), callback=self.axis_input, text=self.currentCoords[i]) self.inputFieldList.append(t) setattr(self.w, axis_tag + "input", t) self.ypos = s.getPosSize()[1] + 36 if self.font.instances: self.w.selectInstanceTitle = vanilla.TextBox( (10, self.ypos, -10, 14), "Copy from instance:", sizeStyle="small") setattr( self.w, "instanceSelect", vanilla.PopUpButton((130, self.ypos, -10, 17), [i.name for i in self.font.instances], callback=self.instance_selector)) self.ypos += 32 setattr(self.w, "separator", vanilla.HorizontalLine((10, self.ypos, -10, 1))) self.ypos += 16 setattr( self.w, "addMenu", vanilla.Button((155, self.ypos, -10, 20), "Instance...", callback=self.add_instance_menu)) setattr( self.w, "addIntermediate", vanilla.Button((10, self.ypos, -155, 20), "Intermediate...", callback=self.intermediate_menu)) self.w.resize(300, self.w.addMenu.getPosSize()[1] + 30) self.w.open() self.w.makeKey() self.w.bind("close", self.remove_preview)
def __init__(self): self.methods = { 0: "fl", 1: "thirds", 2: "quad", 3: "adjust", 4: "free", } self.methodNames = [ "Circle", "Rule of thirds", "TT (experimental)", "Adjust fixed:", "Adjust free:" ] self.curvatures = { 0: 0.552, 1: 0.577, 2: 0.602, 3: 0.627, 4: 0.652, } height = 160 self.w = vanilla.FloatingWindow((200, height), "Curve EQ") y = 8 self.w.eqMethodSelector = vanilla.RadioGroup( (10, y, -10, 108), titles=self.methodNames, callback=self._changeMethod, sizeStyle="small") y -= 91 self.w.eqCurvatureSelector = vanilla.RadioGroup( (104, y, -8, 14), isVertical=False, titles=["", "", "", "", ""], callback=self._changeCurvature, sizeStyle="small") y += 22 self.w.eqCurvatureSlider = vanilla.Slider( (104, y, -8, 14), callback=self._changeCurvatureFree, minValue=0.5, maxValue=1.0, #value=self.curvatures[self.w.eqCurvatureSelector.get()], sizeStyle="small", ) y = height - 32 self.w.eqSelectedButton = vanilla.Button( (10, y, -10, 25), "Equalize selected", callback=self._eqSelected, sizeStyle="small", ) # default method self.w.eqMethodSelector.set( getExtensionDefault("%s.%s" % (extensionID, "method"), 0)) self.method = self.methods[self.w.eqMethodSelector.get()] self._checkSecondarySelectors() # default curvature self.w.eqCurvatureSelector.set( getExtensionDefault("%s.%s" % (extensionID, "curvature"), 0)) self.curvature = self.curvatures[self.w.eqCurvatureSelector.get()] # default curvature for slider self.w.eqCurvatureSlider.set( getExtensionDefault("%s.%s" % (extensionID, "curvatureFree"), 0.5)) self.curvatureFree = self.w.eqCurvatureSlider.get() addObserver(self, "_curvePreview", "draw") #addObserver(self, "_curvePreview", "drawPreview") addObserver(self, "_curvePreview", "drawInactive") addObserver(self, "_currentGlyphChanged", "currentGlyphChanged") self.tmpGlyph = RGlyph() UpdateCurrentGlyphView() self.setUpBaseWindowBehavior() self.w.open()
def __init__(self): self.histogram_width = 608 self.histogram_height = 380 histogram_x_offset = 10 histogram_y_offset = 10 window_width = 630 window_height = 500 # how much of the em is shown? self.ems_horizontal = 1.3 # how many pixels on the canvas per letter? self.scale_vertical = 10.0 self.units = 18 self.known_units = unitization_info.get_all_units() self.system = None self.show_fixed = True self.glyphs = [] # show glyphs or lines? self.show_glyphs = True y = 10 self.w = vanilla.FloatingWindow((window_width, window_height), "Glyph Width Histogram") self.w.histogram = Canvas((histogram_x_offset, histogram_y_offset, -10, self.histogram_height), canvasSize=(self.histogram_width, self.histogram_height), hasHorizontalScroller=False, hasVerticalScroller=False, delegate=self) y += self.histogram_height + histogram_y_offset + 8 self.w.unit_label = vanilla.TextBox((histogram_x_offset, y, 90, 20), "Units per em:") self.w.unit_display = vanilla.TextBox((histogram_x_offset + 90, y, 30, 20), self.units) self.w.system_selection = vanilla.PopUpButton((histogram_x_offset + 120, y-1, 300, 20), [], callback = self._systemCallback, #sizeStyle = "small", ) self.w.show_fixed = vanilla.CheckBox((histogram_x_offset + 462, y-1, 300, 20), "Show system widths", value=self.show_fixed, callback = self._showFixedCallback, ) y += 28 self.w.unit_slider = vanilla.Slider((histogram_x_offset, y, -10, 20), minValue = 1, maxValue = 64, value = self.units, tickMarkCount = 64, callback = self._unitCallback, stopOnTickMarks = True, ) y += 33 self.w.glyph_selection_label = vanilla.TextBox((histogram_x_offset, y, 120, 20), "Analyze glyphs:") self.w.glyph_selection = vanilla.RadioGroup((histogram_x_offset + 110, y, 210, 20), ["Selected", "All", "Charset:"], isVertical = False, callback = self._glyphSelectionCallback, sizeStyle = "small", ) self.w.charset_selection = vanilla.PopUpButton((histogram_x_offset + 320, y, -110, 20), [], callback = self._charsetCallback, #sizeStyle = "small", ) self.w.update_button = vanilla.Button((-100, y, -10, 20), "Update", callback = self._updateButtonCallback ) self._unitCallback() self.w.system_selection.setItems(unitization_info.get_ui_list()) if self.units in self.known_units: self.system = unitization_info.get_systems_by_upm(self.units)[0] self.w.system_selection.set(unitization_info.get_ui_list().index(self.system.name)) else: self.system = None self.w.system_selection.set(0) self.w.glyph_selection.set(0) self.w.charset_selection.enable(False) self.update_charset_selection() self.glyphs = self.get_glyphnames_for_histogram() self.calculate_histogram() self.setUpBaseWindowBehavior() #addObserver(self, "glyphChanged", "currentGlyphChanged") #addObserver(self, "glyphChanged", "draw") #addObserver(self, "removeFontFromList", "fontWillClose") #addObserver(self, "updateFontList", "fontDidOpen") 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.FloatingWindow( (windowWidth, windowHeight), # default window size "Find Small Paths", # window title minSize=(windowWidth, windowHeight), # minimum size (for resizing) maxSize=(windowWidth + windowWidthResize, windowHeight + windowHeightResize), # maximum size (for resizing) autosaveName= "com.mekkablue.FindSmallPaths.mainwindow" # stores last window position and size ) # UI elements: self.w.text_1 = vanilla.TextBox( (15, 10, -15, 30), "Open a new tab with glyphs that contain paths with an area smaller than:", sizeStyle='small') self.w.minArea = vanilla.TextBox((15, 42, -15, 15 + 3), "1000 square units", sizeStyle='small', alignment="center") self.w.sliderMin = vanilla.EditText((15, 60 - 1, 50, 19), "10", sizeStyle='small', callback=self.SliderUpdate) self.w.sliderMax = vanilla.EditText((-15 - 50, 60 - 1, -15, 19), "10000", sizeStyle='small', callback=self.SliderUpdate) self.w.areaSlider = vanilla.Slider( (15 + 50 + 10, 60, -15 - 50 - 10, 19), value=0.1, minValue=0.0, maxValue=1.0, sizeStyle='small', callback=self.SliderUpdate) self.w.deleteThemRightAway = vanilla.CheckBox( (15, 80 + 10, -15, 20), "Delete Small Paths Right Away", value=False, callback=self.CheckBoxUpdate, sizeStyle='small') self.w.afterOverlapRemoval = vanilla.CheckBox( (15, 100 + 10, -15, 20), "After Decomposition and Overlap Removal (slower)", value=False, callback=self.CheckBoxUpdate, sizeStyle='small') # Run Button: self.w.runButton = vanilla.Button((-120, -20 - 15, -15, -15), "Open Tab", sizeStyle='regular', callback=self.FindSmallPathsMain) self.w.setDefaultButton(self.w.runButton) # Load Settings: if not self.LoadPreferences(): print "Note: 'Find Small Paths' could not load preferences. Will resort to defaults" self.CheckBoxUpdate(None) self.SliderUpdate(None) # Open window and focus on it: self.w.open() self.w.makeKey()
def __init__(self): self.screenInfo = getScreenInfo() self.screenNames = [] for screen in self.screenInfo: for location in ["↖︎", "↗︎"]: self.screenNames += ["%s %s" % (location, screen["name"])] self.dsPath = None self.ds = None self.sourceFonts = {} step = 10 self.w = vanilla.Window((660, 600), "Rotated DesignSpace Preview", minSize=(320, 500), autosaveName="Rotated DesignSpace Preview") self.w.openButton = vanilla.SquareButton((10, step, 150, 25), "Open Designspace", sizeStyle="small", callback=self.openDesignSpace) self.w.reloadButton = vanilla.SquareButton( (10, step + 35, 150, 25), "Update/Reload Fonts", sizeStyle="small", callback=self.reloadDesignSpace) #self.w.saveButton = vanilla.SquareButton((10, step+70, 40, 25), "Save", sizeStyle="small", callback=self.saveSources) self.w.screenChoice = vanilla.PopUpButton( (10, step + 65, 150, 25), self.screenNames, sizeStyle="small", callback=self.positionSourceWindows) self.w.vr1 = vanilla.VerticalLine((170, 10, 1, 100)) self.w.glyphNameTitle = vanilla.TextBox((190, step + 5, 100, 25), "Glyph name:") self.w.glyphName = vanilla.EditText((190, step + 35, 100, 25), "", callback=self.glyphChanged) self.w.fillBox = vanilla.CheckBox((190, step + 65, 100, 25), "Fill Preview", callback=self.settingsChanged) self.w.vr2 = vanilla.VerticalLine((310, 10, 1, 100)) mid = 330 self.w.selectedPointTitle = vanilla.TextBox((mid, step + 5, 100, 25), "Selected BCP:") self.w.setRatioButton = vanilla.SquareButton( (mid, step + 35, 175, 25), "Match “default” master ratio...", sizeStyle="small", callback=self.setPointRatio) self.w.setRatioButton.id = "ratio" self.w.setRatioButton2 = vanilla.SquareButton( (mid + 174, step + 35, 135, 25), "...move off-curves only", sizeStyle="small", callback=self.setPointRatio) self.w.setRatioButton2.id = "ratioLeaveAnchor" mid = 439 self.w.magTitle = vanilla.TextBox((mid - 100, step + 70, 100, 25), "Scale off-curves:", sizeStyle="small") self.w.magButton0 = vanilla.SquareButton( (mid, step + 64, 51, 25), "-20", sizeStyle="small", callback=self.pointMagCallback) self.w.magButton0.value = 0.8 self.w.magButton1 = vanilla.SquareButton( (mid + 50, step + 64, 51, 25), "-5", sizeStyle="small", callback=self.pointMagCallback) self.w.magButton1.value = 0.95 self.w.magButton2 = vanilla.SquareButton( (mid + 100, step + 64, 51, 25), "+5", sizeStyle="small", callback=self.pointMagCallback) self.w.magButton2.value = 1.05 self.w.magButton3 = vanilla.SquareButton( (mid + 150, step + 64, 50, 25), "+20", sizeStyle="small", callback=self.pointMagCallback) self.w.magButton3.value = 1.2 #self.w.closeButton = vanilla.SquareButton((550, step+35, 40, 25), "Close", sizeStyle="small", callback=self.closeSourceWindows) self.w.hr1 = vanilla.HorizontalLine((10, 110, -10, 1)) step += 110 # Sliders for tag in ["HROT", "VROT"]: posSize = (10, step + 5, 50, 25) control = vanilla.TextBox(posSize, tag, sizeStyle="small") setattr(self.w, "label_%s" % tag, control) posSize = (50, step, 60, 25) control = vanilla.EditText(posSize, 0, callback=self.valueChangedCallback) control.id = tag setattr(self.w, "value_%s" % tag, control) posSize = (120, step, -10, 25) control = vanilla.Slider(posSize, callback=self.sliderChangedCallback, tickMarkCount=1) control.id = tag # axis min, max, default control.setMinValue(-45) control.setMaxValue(45) control.set(0) setattr(self.w, "slider_%s" % tag, control) step += 30 self.w.glyphPreview = GlyphView((10, step, -10, -10)) #self.w.bind("close", self.windowClosed) self.settingsChanged() self.w.open()
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, glyph, font): self.model = "Superellipse" self.angle = radians(30) self.width = 60 self.height = 2 self.superness = 2.5 self.line_join = "round" # bevel, round self.guide_layer = None self.nib_pen = nib_models[self.model] self._draw_nib_faces = False self._draw_in_preview_mode = False self.glyph = glyph self.font = font # window dimensions width = 300 height = 322 self.w = vanilla.FloatingWindow((width, height), "Nib Simulator") col = 60 y = 10 self.w.model_label = vanilla.TextBox((8, y, col - 8, 20), "Model") self.w.model_select = vanilla.PopUpButton( (col, y, -48, 20), nib_models.keys(), callback=self._model_select_callback, ) y += 32 self.w.angle_label = vanilla.TextBox((8, y, col - 8, 20), "Angle") self.w.angle_slider = vanilla.Slider( (col, y, -48, 20), minValue=0, maxValue=pi, value=radians(30), tickMarkCount=7, callback=self._nib_angle_callback, stopOnTickMarks=False, ) self.w.angle_text = vanilla.TextBox( (-40, y, -8, 20), "%i" % int(round(degrees(self.angle)))) y += 24 self.w.width_label = vanilla.TextBox((8, y, col - 8, 20), "Width") self.w.width_slider = vanilla.Slider( (col, y, -48, 20), minValue=0, maxValue=200, value=self.width, # tickMarkCount=7, callback=self._nib_width_callback, # stopOnTickMarks=False, ) self.w.width_text = vanilla.TextBox((-40, y, -8, 20), "%i" % self.width) y += 24 self.w.height_label = vanilla.TextBox((8, y, col - 8, 20), "Height") self.w.height_slider = vanilla.Slider( (col, y, -48, 20), minValue=1, maxValue=200, value=self.height, # tickMarkCount=7, callback=self._nib_height_callback, # stopOnTickMarks=False, ) self.w.height_text = vanilla.TextBox((-40, y, -8, 20), "%i" % self.height) y += 24 self.w.superness_label = vanilla.TextBox((8, y, col - 8, 20), "Super") self.w.superness_slider = vanilla.Slider( (col, y, -48, 20), minValue=1.01, maxValue=15.0, value=self.superness, callback=self._nib_superness_callback, ) self.w.superness_text = vanilla.TextBox((-40, y, -8, 20), "%0.2f" % self.superness) y += 32 self.w.guide_label = vanilla.TextBox((8, y, col - 8, 20), "Guide") self.w.guide_select = vanilla.PopUpButton( (col, y, -48, 20), [] # callback=self._guide_select_callback, ) y += 32 self.w.glyph_local = vanilla.CheckBox( (col, y, -40, 20), "Glyph Uses Local Parameters", callback=self._glyph_local_callback, value=False, ) y += 32 self.w.display_label = vanilla.TextBox((8, y, col - 8, 20), "Display") self.w.draw_space = vanilla.CheckBox( (col, y, -48, 20), "Draw In Space Center", callback=self._draw_space_callback, value=False, ) y += 24 self.w.draw_preview = vanilla.CheckBox( (col, y, -48, 20), "Draw In Preview Mode", callback=self._draw_preview_callback, value=False, ) y += 24 self.w.draw_faces = vanilla.CheckBox( (col, y, -48, 20), "Draw Nib Faces In RGB", callback=self._draw_faces_callback, value=False, ) y += 32 self.w.trace_outline = vanilla.Button((col, y, 120, 20), title="Trace Outline", callback=self._trace_callback) self.envSpecificInit() # self._update_ui() # self.w.trace_outline.enable(False) self.w.open() self._update_current_glyph_view()