Exemplo n.º 1
0
    def buildBaseWindow(self, parentWindow):
        """ Make the base window. """
        self._dirty = False
        self._sheetWidth = 400
        self._sheetHeight = 500
        if parentWindow is None:
            self.w = vanilla.Window((self._sheetWidth, self._sheetHeight),
                title = self._title,
                closable=False,
                miniaturizable=False,
                minSize=(self._sheetWidth, self._sheetHeight),
                textured=False)
        else:
            self.w = vanilla.Sheet((self._sheetWidth, self._sheetHeight),
                parentWindow,
                minSize=(self._sheetWidth, self._sheetHeight),
            )
        # cancel button
        self.w.cancelButton = vanilla.Button((-205, -30, 100, 20),
            'Cancel',
            callback=self.callbackCancelButton,
            sizeStyle='small')
        self.w.cancelButton.bind(".", ["command"])
        self.w.cancelButton.bind(unichr(27), [])
        # ok button
        self.w.applyButton = vanilla.Button((-100, -30, -10, 20),
            'Add Glyphs',
            callback=self.callbackApplyAddGlyphsToTargetFont,
            sizeStyle='small')
        self.w.setDefaultButton(self.w.applyButton)

        # get the specialised stuff in
        self.fillSheet()
        self.setUpBaseWindowBehavior()
        #self.refresh()
        self.w.open()
	def __init__( self ):
		self.w = vanilla.FloatingWindow( (250, windowHeight), "Transform Images", minSize=(250, windowHeight), maxSize=(250, windowHeight), autosaveName="com.mekkablue.TransformImages.mainwindow" )

		self.w.scale_text1 = vanilla.TextBox( (15-1, 12+2, 75, 14), "Scale x/y:", sizeStyle='small' )
		self.w.scale_X = vanilla.EditText( (15+60,    12, 55, 15+3), "+10.5", sizeStyle = 'small')
		self.w.scale_Y = vanilla.EditText( (15+60+60, 12, 55, 15+3), "-11.0", sizeStyle = 'small')
		self.w.scale_text2 = vanilla.TextBox( (15+60+60+60, 12+2, -15, 14), "%", sizeStyle='small' )
		
		self.w.move_text1 = vanilla.TextBox( (15-1,  25+12+2, 75, 14), "Move x/y:", sizeStyle='small' )
		self.w.move_X = vanilla.EditText( (15+60,    25+12, 55, 15+3), "10", sizeStyle = 'small')
		self.w.move_Y = vanilla.EditText( (15+60+60, 25+12, 55, 15+3), "10", sizeStyle = 'small')
		self.w.move_text2 = vanilla.TextBox( (15+60+60+60,  25+12+2, -15, 14), "units", sizeStyle='small' )
		
		#self.w.resetButton = vanilla.Button((-80-80-15, -20-15, -85, -15), "Reset", sizeStyle='regular', callback=self.ResetStructs )
		self.w.backButton   = vanilla.Button((-60-60-23, -20-15, -60-23, -15), "Back", sizeStyle='regular', callback=self.TransformImagesMain )
		self.w.runButton   = vanilla.Button((-60-15, -20-15, -15, -15), "Go", sizeStyle='regular', callback=self.TransformImagesMain )
		self.w.setDefaultButton( self.w.runButton )
		
		try:
			self.LoadPreferences( )
		except:
			pass

		self.w.open()
	def __init__( self ):
		# Window 'self.w':
		windowWidth  = 350
		windowHeight = 260
		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
			"Punctuation Unifier", # window title
			minSize = ( windowWidth, windowHeight ), # minimum size (for resizing)
			maxSize = ( windowWidth + windowWidthResize, windowHeight + windowHeightResize ), # maximum size (for resizing)
			autosaveName = "com.mekkablue.PunctuationUnifier.mainwindow" # stores last window position and size
		)
		
		# UI elements:
		linePos, inset, lineHeight = 12, 15, 22
		
		self.w.descriptionText = vanilla.TextBox( (inset, linePos+2, -inset, 14), u"Unifies the shapes of the periods in punctuation.", sizeStyle='small', selectable=True )
		linePos += lineHeight
		
		self.w.periodBaseText = vanilla.TextBox( (inset, linePos+2, 100, 14), u"Model for period:", sizeStyle='small', selectable=True )
		self.w.periodBase = vanilla.PopUpButton( (inset+100, linePos, -inset, 17), self.periodBase, sizeStyle='small', callback=self.SavePreferences )
		linePos += lineHeight
		
		self.w.commaBaseText = vanilla.TextBox( (inset, linePos+2, 100, 14), u"Model for comma:", sizeStyle='small', selectable=True )
		self.w.commaBase = vanilla.PopUpButton( (inset+100, linePos, -inset, 17), self.commaBase, sizeStyle='small', callback=self.SavePreferences )
		linePos += lineHeight
		
		self.w.scaleToHeight = vanilla.CheckBox( (inset, linePos-1, -inset, 20), u"Scale to height", value=False, callback=self.SavePreferences, sizeStyle='small' )
		linePos += lineHeight
		
		
		self.w.text_1 = vanilla.TextBox( (inset-1, linePos+2, 75, 14), "inset", sizeStyle='small' )
		self.w.popup_1 = vanilla.PopUpButton( (inset+80, linePos, 50, 17), [str(x) for x in range( 3, 12 )], callback=self.SavePreferences, sizeStyle='small' )
		self.w.edit_1 = vanilla.EditText( (inset+80+55, linePos, -inset, 19), "insert text here", 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.PunctuationUnifierMain )
		self.w.setDefaultButton( self.w.runButton )
		
		# Load Settings:
		if not self.LoadPreferences():
			print "Note: 'Punctuation Unifier' could not load preferences. Will resort to defaults"
		
		# Open window and focus on it:
		self.w.open()
		self.w.makeKey()
Exemplo n.º 4
0
	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()
Exemplo n.º 5
0
    def __init__(self):
        # Window 'self.w':
        edY = 22
        txY = 17
        sp = 10
        btnX = 100
        btnY = 22
        windowWidth = 300
        windowHeight = sp * 5 + edY * 2 + edY + btnY + sp
        # 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
            "Search Glyph In Class Features",  # window title
            # minSize = ( windowWidth, windowHeight ), # minimum size (for resizing)
            # maxSize = ( windowWidth, windowHeight ), # maximum size (for resizing)
            autosaveName=
            "com.Tosche.SearchGlyphInClassFeatures.mainwindow"  # stores last window position and size
        )

        listOfOptions = [
            "Check which alternates are unused",
            "Check if/where the selected glyph is used",
            "Same as the above, but by name"
        ]
        self.w.radioButtons = vanilla.RadioGroup(
            (sp, sp, -sp, edY * len(listOfOptions)),
            listOfOptions,
            sizeStyle='regular',
            callback=self.radio)
        self.w.edit_1 = vanilla.EditText(
            (sp + 20, sp * 1.5 + edY * len(listOfOptions), -sp, edY),
            "",
            sizeStyle='regular')

        # Run Button:
        self.w.runButton = vanilla.Button(
            (-sp - btnX, sp * 5 + edY * 2 + edY, -sp, btnY),
            "Check",
            sizeStyle='regular',
            callback=self.Search)
        self.w.setDefaultButton(self.w.runButton)

        # Open window and focus on it:
        self.w.radioButtons.set(0)
        self.w.edit_1.enable(False)
        self.w.open()
        self.w.makeKey()
    def add_instance_menu(self, sender):
        try:
            delattr(self.w, "intermediateTitle")
            delattr(self.w, "parentSelector")
            delattr(self.w, "makeIntermediate")
        except Exception:
            print()

        self.ypos = self.w.addMenu.getPosSize()[1] + 40

        try:
            setattr(
                self.w, "instanceName",
                vanilla.TextBox((10, self.ypos, 60, 14),
                                "Name",
                                sizeStyle="small"))
            setattr(
                self.w, "nameSelector",
                vanilla.EditText((60, self.ypos, -10, 19),
                                 placeholder=self.namePlaceholder,
                                 sizeStyle="small",
                                 callback=self.instance_name))

            self.ypos += 41

            for i, axis in enumerate(self.styleClasses):
                c = vanilla.PopUpButton((60, self.ypos + i * 30, -10, 17),
                                        list(self.styleClasses[axis].values()),
                                        callback=self.class_selector)
                c.set(4)
                setattr(self.w, axis + "classSelector", c)
                self.popUpButtonList.append(c)
                setattr(
                    self.w, axis + "ClassTitle",
                    vanilla.TextBox((10, self.ypos + i * 30, 60, 14),
                                    axis,
                                    sizeStyle="small"))
                if i == 2:
                    break
            setattr(
                self.w, "generate",
                vanilla.Button((10, c.getPosSize()[1] + 30, -10, 20),
                               "Make Instance",
                               callback=self.write_instance))
            self.w.setDefaultButton(self.w.generate)
            self.w.resize(300, self.w.generate.getPosSize()[1] + 30)
        except Exception:
            return
Exemplo n.º 7
0
	def __init__( self ):
		# Window 'self.w':
		windowWidth  = 320
		windowHeight = 200
		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
			"Compare Glyph Heights of Frontmost Fonts", # window title
			minSize = ( windowWidth, windowHeight ), # minimum size (for resizing)
			maxSize = ( windowWidth + windowWidthResize, windowHeight + windowHeightResize ), # maximum size (for resizing)
			autosaveName = "com.mekkablue.CompareGlyphHeightsOfFrontmostFonts.mainwindow" # stores last window position and size
		)
		
		# UI elements:
		linePos, inset, lineHeight = 12, 15, 22
		
		self.w.descriptionText = vanilla.TextBox( (inset, linePos+2, -inset, 28), u"Lists all glyphs that differ in height more than the given threshold. Detailed report in Macro Window.", sizeStyle='small', selectable=True )
		linePos += lineHeight*2
		
		self.w.tolerateText = vanilla.TextBox( (inset, linePos+2, 140, 14), u"Tolerate difference up to:", sizeStyle='small', selectable=True )
		self.w.tolerate = vanilla.EditText( (inset+140, linePos, -inset, 19), "5", callback=self.SavePreferences, sizeStyle='small' )
		self.w.tolerate.getNSTextField().setToolTip_("How much of a difference is OK. Hint: overshoot size is a good idea for this one.")
		linePos += lineHeight
		
		self.w.heights = vanilla.CheckBox( (inset, linePos-1, -inset, 20), u"Compare top bounds (‘heights’)", value=True, callback=self.SavePreferences, sizeStyle='small' )
		self.w.heights.getNSButton().setToolTip_("Measures and compares the heights of the top edges (bbox maximum).")
		linePos += lineHeight
		
		self.w.depths = vanilla.CheckBox( (inset, linePos-1, -inset, 20), u"Compare bottom bounds (‘depths’)", value=False, callback=self.SavePreferences, sizeStyle='small' )
		self.w.depths.getNSButton().setToolTip_("Measures and compares the heights of the bottom edges (bbox minimum).")
		linePos += lineHeight
		
		self.w.includeNonExporting = vanilla.CheckBox( (inset, linePos-1, -inset, 20), u"Include non-exporting glyphs", value=False, callback=self.SavePreferences, sizeStyle='small' )
		self.w.includeNonExporting.getNSButton().setToolTip_("If enabled, also measures glyphs that are set to not export.")
		linePos += lineHeight
		
		# Run Button:
		self.w.runButton = vanilla.Button( (-120-inset, -20-inset, -inset, -inset), "Compare", sizeStyle='regular', callback=self.CompareGlyphHeightsOfFrontmostFontsMain )
		self.w.setDefaultButton( self.w.runButton )
		
		# Load Settings:
		if not self.LoadPreferences():
			print("Note: 'Compare Glyph Heights of Frontmost Fonts' could not load preferences. Will resort to defaults")
		
		# Open window and focus on it:
		self.w.open()
		self.w.makeKey()
Exemplo n.º 8
0
    def __init__(self):
        InputPosX = 90
        InputWidth = 30
        textHeight = 40

        self.w = vanilla.FloatingWindow((250, 130), "Proportions as Ratio")

        # ascender
        self.w.ascenderText = vanilla.TextBox((10, 10, -10, textHeight),
                                              "ascender")
        self.w.ascenderValue = vanilla.EditText(
            (InputPosX, 10, InputWidth, 20), "5.5", sizeStyle='small')

        # xHeight
        self.w.xHeightText = vanilla.TextBox((10, 35, -10, textHeight),
                                             "xHeight")
        self.w.xHeightValue = vanilla.EditText((InputPosX, 35, InputWidth, 20),
                                               "10",
                                               sizeStyle='small')

        # descender
        self.w.descenderText = vanilla.TextBox((10, 60, -10, textHeight),
                                               "descender")
        self.w.descenderValue = vanilla.EditText(
            (InputPosX, 60, InputWidth, 20), "5", sizeStyle='small')

        self.w.myTextBox1b = vanilla.TextBox((130, 10, 10, textHeight),
                                             unichr(int('23AB', 16)))
        # bracket extension
        self.w.myTextBox2 = vanilla.TextBox((130, 22, 10, textHeight),
                                            unichr(int('23AA', 16)))
        self.w.myTextBox3b = vanilla.TextBox((130, 35, 10, textHeight),
                                             unichr(int('23AC', 16)))
        # bracket extension
        self.w.myTextBox4 = vanilla.TextBox((130, 47, 10, textHeight),
                                            unichr(int('23AA', 16)))
        self.w.myTextBox5b = vanilla.TextBox((130, 60, 10, textHeight),
                                             unichr(int('23AD', 16)))
        self.w.myTextBox3c = vanilla.TextBox((150, 35, -10, textHeight),
                                             str(upm) + " upm")

        # Button
        self.w.myButton = vanilla.Button((10, 100, -10, 20),
                                         "Do it!",
                                         sizeStyle='small',
                                         callback=self.buttonCallback)
        self.w.setDefaultButton(self.w.myButton)
        self.w.open()
Exemplo n.º 9
0
 def __init__(self):
     self.w = vanilla.FloatingWindow((200, 120), "Sidebearings EQ")
     self.w.iconAll = vanilla.ImageView((15, 16, 13, 10))
     self.w.iconAll.setImage(imagePath="allglyphs.png")
     self.w.iconSelected = vanilla.ImageView((15, 43, 13, 10))
     self.w.iconSelected.setImage(imagePath="selectedglyphs.png")
     self.w.scopeRadioGroup = vanilla.RadioGroup(
         (35, 10, -15, 50), ["All Glyphs", "Selected Glyphs"],
         sizeStyle="small")
     self.w.scopeRadioGroup.set(1)
     self.w.divider1 = vanilla.HorizontalLine((15, 70, -15, 1))
     self.w.applyButton = vanilla.Button((15, 85, -15, 20),
                                         "Equalize Sidebearings",
                                         sizeStyle="small",
                                         callback=self.applyButtonCallback)
     self.w.open()
 def __init__(self):
     self.w = vanilla.FloatingWindow((500, 100), "Open Tab:")
     self.w.myTextBox = vanilla.TextBox((10, 10, -10, 40),
                                        "Open Tab wit these guys:")
     self.w.editText = vanilla.EditText(
         (10, 30, -100, 50),
         ListJoined +
         "\n/H/H/Placeholder/H/H/O/O/Placeholder/O/O\n/n/n/Placeholder/n/n/o/o/Placeholder/o/o",
         sizeStyle='small',
         callback=self.editTextCallback)
     self.w.myButton = vanilla.Button((410, 30, -10, 20),
                                      "Do it!",
                                      sizeStyle='small',
                                      callback=self.buttonCallback)
     self.w.setDefaultButton(self.w.myButton)
     self.w.open()
    def __init__(self):

        self.w = vanilla.Window((180, 300), "Tab Collector")
        y = 10

        for name in self.windowNames:
            obj = vanilla.CheckBox((10, y, -10, 22), name)
            setattr(self.w, name, obj)
            y += 30

        self.w.resize(180, y + 40)

        self.w.collect = vanilla.Button((10, -30, -10, 22),
                                        "Collect",
                                        callback=self.collectCallback)
        self.w.open()
Exemplo n.º 12
0
    def __init__(self):
        # Window 'self.w':
        windowWidth = 350
        windowHeight = 130
        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
            "Remove Component from Selected Glyphs",  # window title
            minSize=(windowWidth, windowHeight),  # minimum size (for resizing)
            maxSize=(windowWidth + windowWidthResize, windowHeight +
                     windowHeightResize),  # maximum size (for resizing)
            autosaveName=
            "com.mekkablue.RemoveComponentfromSelectedGlyphs.mainwindow"  # stores last window position and size
        )

        # UI elements:
        self.w.text1 = vanilla.TextBox((15, 12 + 3, 130, 14),
                                       "Remove component",
                                       sizeStyle='small')
        self.w.componentName = vanilla.ComboBox((15 + 130, 12, -15, 19),
                                                self.glyphList(),
                                                sizeStyle='small')
        self.w.fromWhere = vanilla.RadioGroup(
            (15, 40, -15, 40),
            ["from all selected glyphs", "from all glyphs in the font"],
            callback=self.SavePreferences,
            sizeStyle='small')
        self.w.fromWhere.set(0)

        # Run Button:
        self.w.runButton = vanilla.Button(
            (-100 - 15, -20 - 15, -15, -15),
            "Remove",
            sizeStyle='regular',
            callback=self.RemoveComponentfromSelectedGlyphsMain)
        self.w.setDefaultButton(self.w.runButton)

        # Load Settings:
        if not self.LoadPreferences():
            print(
                "Note: 'Remove Component from Selected Glyphs' could not load preferences. Will resort to defaults"
            )

        # Open window and focus on it:
        self.w.open()
        self.w.makeKey()
Exemplo n.º 13
0
    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()
Exemplo n.º 14
0
	def __init__( self ):
		# Window 'self.w':
		windowWidth  = 240
		windowHeight = 180
		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
			"Insert Special Layers", # window title
			minSize = ( windowWidth, windowHeight ), # minimum size (for resizing)
			maxSize = ( windowWidth + windowWidthResize, windowHeight + windowHeightResize ), # maximum size (for resizing)
			autosaveName = "com.mekkablue.InsertSpecialLayers.mainwindow" # stores last window position and size
		)
		
		# UI elements:
		linePos, inset, lineHeight = 12, 15, 22
		self.w.descriptionText = vanilla.TextBox( (inset, linePos+2, -inset, 14), "Insert layer into selected glyphs:", sizeStyle='small', selectable=True )
		linePos += lineHeight
		
		self.w.layerNameText = vanilla.TextBox( (inset, linePos+2, 70, 14), "Layer name:", sizeStyle='small', selectable=True )
		self.w.layerName = vanilla.EditText( (inset+70, linePos-1, -inset, 19), "Intermediate {100}", callback=self.SavePreferences, sizeStyle='small' )
		linePos += lineHeight
		
		self.w.prefillWithMasterContent = vanilla.CheckBox( (inset, linePos-1, -inset, 20), "Create as duplicate of master layer", value=False, callback=self.SavePreferences, sizeStyle='small' )
		self.w.prefillWithMasterContent.getNSButton().setToolTip_("Will add the new layer with the content of the associated master layer. If checkbox is off, will insert empty layer. In case of brace layers, the Reinterpolate option (further down) takes precedence, though.")
		linePos += lineHeight
		
		self.w.keepExistingBrace = vanilla.CheckBox( (inset, linePos-1, -inset, 20), "Keep existing brace layer", value=True, callback=self.SavePreferences, sizeStyle='small' )
		self.w.keepExistingBrace.getNSButton().setToolTip_("Only applies to brace layers. If checkbox is on and a glyph already contains (on any master) a brace layer at the indicated value, the script will skip the glyph. If the checkbox is off, it will deactivate the existing brace layer by replacing the curly braces with hashtags.")
		linePos += lineHeight
		
		self.w.reinterpolateBrace = vanilla.CheckBox( (inset, linePos-1, -inset, 20), "Reinterpolate brace layers", value=False, callback=self.SavePreferences, sizeStyle='small' )
		self.w.reinterpolateBrace.getNSButton().setToolTip_("Only applies to brace layers. If checkbox is on and a brace layer is inserted, it will reinterpolate the newly generated brace layer. It only does this for newly generated layer, and will not reinterpolate existing brace layers.")
		linePos += lineHeight
		
		
		# Run Button:
		self.w.runButton = vanilla.Button( (-80-inset, -20-inset, -inset, -inset), "Insert", sizeStyle='regular', callback=self.InsertSpecialLayersMain )
		self.w.setDefaultButton( self.w.runButton )
		
		# Load Settings:
		if not self.LoadPreferences():
			print("Note: 'Insert Special Layers' could not load preferences. Will resort to defaults")
		
		# Open window and focus on it:
		self.w.open()
		self.w.makeKey()
Exemplo n.º 15
0
	def __init__( self ):
		# Window 'self.w':
		windowWidth  = 300
		windowHeight = 130
		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 Unicode Values to Selected Glyphs", # window title
			minSize = ( windowWidth, windowHeight ), # minimum size (for resizing)
			maxSize = ( windowWidth + windowWidthResize, windowHeight + windowHeightResize ), # maximum size (for resizing)
			autosaveName = "com.mekkablue.CustomUnicode.mainwindow" # stores last window position and size
		)
		
		# UI elements:
		linePos, inset, lineHeight = 12, 15, 22
		
		self.w.descriptionText = vanilla.TextBox( (inset, linePos+3, 190, 14), u"Assign Unicode values starting at:", sizeStyle='small', selectable=True )
		self.w.unicode = vanilla.EditText( (inset+190, linePos, -inset-25, 19), "E700", callback=self.sanitizeEntry, sizeStyle='small' )
		self.w.unicode.getNSTextField().setToolTip_(u"The first selected glyph will receive this Unicode value. Subsequent glyphs will get the next respective Unicode value, until all selected glyphs have received one.")
		self.w.updateButton = vanilla.SquareButton( (-inset-20, linePos, -inset, 18), u"↺", sizeStyle='small', callback=self.update )
		self.w.updateButton.getNSButton().setToolTip_(u"Resets the starting Unicode to the first BMP PUA available in the font. Useful if you do not wish to overwrite existing PUA codes.")
		linePos += lineHeight

		self.w.keepExistingUnicodes = vanilla.CheckBox( (inset, linePos-1, -inset, 20), u"Keep existing Unicode values", value=False, callback=self.SavePreferences, sizeStyle='small' )
		self.w.keepExistingUnicodes.getNSButton().setToolTip_(u"Two things: it keeps (does not overwrite) the Unicode value of a selected glyph, and it skips Unicode values that are already in use elsewhere in the font. Allows you to select all glyphs and run the script, and thus, assign PUA codes to all unencoded glyphs.")
		linePos += lineHeight

		self.w.includeNonExportingGlyphs = vanilla.CheckBox( (inset, linePos-1, -inset, 20), u"Include non-exporting glyphs", value=False, callback=self.SavePreferences, sizeStyle='small' )
		self.w.includeNonExportingGlyphs.getNSButton().setToolTip_(u"If disabled, will skip all glyphs that are set to not export. If enabled, will treat all selected glyphs, including non-exporting glyphs.")
		linePos += lineHeight
		
		# Status Message:
		self.w.status = vanilla.TextBox( (inset, -16-inset, -inset, -inset), u"", sizeStyle='small', selectable=True )
		linePos += lineHeight
		
		# Run Button:
		self.w.runButton = vanilla.Button((-80-inset, -20-inset, -inset, -inset), "Assign", sizeStyle='regular', callback=self.CustomUnicodeMain )
		self.w.setDefaultButton( self.w.runButton )
		
		# Load Settings:
		if not self.LoadPreferences():
			print("Note: 'Add PUA Unicode Values to Selected Glyphs' could not load preferences. Will resort to defaults")
		
		# Open window and focus on it:
		self.w.open()
		self.w.makeKey()
    def __init__(self):
        # Window 'self.w':
        windowWidth = 520
        windowHeight = 58
        windowWidthResize = 0  # 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
            "Search And Replace In Anchor Names",  # window title
            minSize=(windowWidth, windowHeight),  # minimum size (for resizing)
            maxSize=(windowWidth + windowWidthResize, windowHeight +
                     windowHeightResize),  # maximum size (for resizing)
            autosaveName=
            "com.mekkablue.SearchAndReplaceInAnchorNames.mainwindow"  # stores last window position and size
        )

        # UI elements:
        self.w.textSearch = vanilla.TextBox((15, 12 + 2, 67, 14),
                                            "Search for:",
                                            sizeStyle='small')
        self.w.searchFor = vanilla.EditText((15 + 67, 12, 135, 19),
                                            "tip",
                                            sizeStyle='small')

        self.w.textReplace = vanilla.TextBox((225, 12 + 2, 67, 14),
                                             "Replace by:",
                                             sizeStyle='small')
        self.w.replaceBy = vanilla.EditText((225 + 67, 12, 135, 19),
                                            "top",
                                            sizeStyle='small')

        self.w.replaceButton = vanilla.Button(
            (-80, 12 + 1, -15, 17),
            "Replace",
            sizeStyle='small',
            callback=self.SearchAndReplaceInAnchorNamesMain)
        self.w.setDefaultButton(self.w.replaceButton)

        # Load Settings:
        if not self.LoadPreferences():
            print(
                "Note: 'Search And Replace In Anchor Names' could not load preferences. Will resort to defaults"
            )

        # Open window and focus on it:
        self.w.open()
        self.w.makeKey()
    def __init__(self):
        # Window 'self.w':
        windowWidth = 200
        windowHeight = 130
        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 and Replace in Layer Names",  # window title
            minSize=(windowWidth, windowHeight),  # minimum size (for resizing)
            maxSize=(windowWidth + windowWidthResize, windowHeight +
                     windowHeightResize),  # maximum size (for resizing)
            autosaveName=
            "com.mekkablue.FindAndReplaceInLayerNames.mainwindow"  # stores last window position and size
        )

        self.w.textSearch = vanilla.TextBox((15, 15, 67, 14),
                                            "Search for:",
                                            sizeStyle='small')
        self.w.searchFor = vanilla.EditText((15 + 67, 12, -15, 19),
                                            "[130]",
                                            sizeStyle='small',
                                            callback=self.SavePreferences)

        self.w.textReplace = vanilla.TextBox((15, 15 + 22, 67, 14),
                                             "Replace by:",
                                             sizeStyle='small')
        self.w.replaceBy = vanilla.EditText((15 + 67, 12 + 22, -15, 19),
                                            "[150]",
                                            sizeStyle='small',
                                            callback=self.SavePreferences)

        self.w.allGlyphs = vanilla.CheckBox((15, 15 + 44, -15, 20),
                                            "Include all glyphs in font",
                                            value=True,
                                            callback=self.SavePreferences,
                                            sizeStyle='small')
        self.w.replaceButton = vanilla.Button((-80, -40, -15, -5),
                                              "Replace",
                                              sizeStyle='small',
                                              callback=self.buttonCallback)

        self.LoadPreferences()

        self.w.setDefaultButton(self.w.replaceButton)
        self.w.open()
        self.w.makeKey()
 def __init__(self):
     self.w = vanilla.FloatingWindow((500, 100), "Open new tab with:")
     self.w.myTextBox = vanilla.TextBox((128, 35, -10, 40),
                                        "/(Selected Glyphs)/")
     self.w.editTextLeft = vanilla.EditText(
         (20, 20, 100, 50),
         sizeStyle='small',
         callback=self.editTextCallbackLeft)
     self.w.editTextRight = vanilla.EditText(
         (260, 20, 100, 50),
         sizeStyle='small',
         callback=self.editTextCallbackRight)
     self.w.myButton = vanilla.Button((380, 35, -10, 20),
                                      "Generate",
                                      sizeStyle='small',
                                      callback=self.buttonCallback)
     self.w.open()
Exemplo n.º 19
0
    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):
        # Window 'self.w':
        windowWidth = 250
        windowHeight = 120
        windowWidthResize = 150  # 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
            "Layers for Rotating Components",  # window title
            minSize=(windowWidth, windowHeight),  # minimum size (for resizing)
            maxSize=(windowWidth + windowWidthResize, windowHeight +
                     windowHeightResize),  # maximum size (for resizing)
            autosaveName=
            "com.mekkablue.InsertBraceLayersForComponentRotation.mainwindow"  # stores last window position and size
        )

        # UI elements:
        self.w.text_1 = vanilla.TextBox((14, 12 + 2, 170, 14),
                                        "Insert steps between masters:",
                                        sizeStyle='small')
        self.w.steps = vanilla.EditText((185, 11, -15, 20),
                                        "5",
                                        sizeStyle='small')
        self.w.replace = vanilla.CheckBox((15, 38, -15, 16),
                                          "Replace existing Brace Layers",
                                          value=True,
                                          callback=self.SavePreferences,
                                          sizeStyle='small')

        # Run Button:
        self.w.runButton = vanilla.Button(
            (-80 - 15, -20 - 15, -15, -15),
            "Insert",
            sizeStyle='regular',
            callback=self.InsertBraceLayersForComponentRotationMain)
        self.w.setDefaultButton(self.w.runButton)

        # Load Settings:
        if not self.LoadPreferences():
            print(
                "Note: 'Insert Brace Layers for Component Rotation' could not load preferences. Will resort to defaults"
            )

        # Open window and focus on it:
        self.w.open()
        self.w.makeKey()
Exemplo n.º 21
0
	def __init__( self ):
		# Window 'self.w':
		windowWidth  = 350
		windowHeight = 180
		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
			u"🔥 Rewire Fire 🔥", # window title
			minSize = ( windowWidth, windowHeight ), # minimum size (for resizing)
			maxSize = ( windowWidth + windowWidthResize, windowHeight + windowHeightResize ), # maximum size (for resizing)
			autosaveName = "com.mekkablue.RewireFire.mainwindow" # stores last window position and size
		)
		
		# UI elements:
		linePos, inset, lineHeight = 12, 15, 22
		self.w.descriptionText = vanilla.TextBox( (inset, linePos+2, -inset, 14), u"Finds candidates for rewiring with Reconnect Nodes.", sizeStyle='small', selectable=True )
		linePos += lineHeight
		
		self.w.includeNonExporting = vanilla.CheckBox( (inset, linePos-1, -inset, 20), u"Include non-exporting glyphs", value=True, callback=self.SavePreferences, sizeStyle='small' )
		self.w.includeNonExporting.getNSButton().setToolTip_("Also check in glyphs that are not set to export. Recommended if you have modular components in the font.")
		linePos += lineHeight
		
		self.w.markWithCircle = vanilla.CheckBox( (inset, linePos-1, -inset, 20), u"Circle duplicate coordinates with annotation ⭕️", value=False, callback=self.SavePreferences, sizeStyle='small' )
		self.w.markWithCircle.getNSButton().setToolTip_("Circle annotations remain after reconnecting the nodes.")
		linePos += lineHeight
		
		self.w.setFireToNode = vanilla.CheckBox( (inset, linePos-1, -inset, 20), u"Mark nodes with fire emoji 🔥", value=True, callback=self.SavePreferences, sizeStyle='small' )
		self.w.setFireToNode.getNSButton().setToolTip_("Emoji will be added as a node name. Node names may disappear after reconnection and path cleanup.")
		linePos += lineHeight
		
		self.w.openTabWithAffectedLayers = vanilla.CheckBox( (inset, linePos-1, -inset, 20), u"New tab with affected layers (otherwise report only)", value=False, callback=self.SavePreferences, sizeStyle='small' )
		self.w.openTabWithAffectedLayers.getNSButton().setToolTip_("If checked, will open a new tab with all layers that contain duplicate coordinates. Otherwise, will report in Macro Window only.")
		linePos += lineHeight
		
		# Run Button:
		self.w.runButton = vanilla.Button( (-80-inset, -20-inset, -inset, -inset), "Fire", sizeStyle='regular', callback=self.RewireFireMain )
		self.w.setDefaultButton( self.w.runButton )
		
		# Load Settings:
		if not self.LoadPreferences():
			print "Note: 'Rewire Fire' could not load preferences. Will resort to defaults"
		
		# Open window and focus on it:
		self.w.open()
		self.w.makeKey()
	def __init__( self ):
		windowWidth  = 240
		windowHeight = 560
		windowWidthResize  = 0 # 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
			"Start-from-scratch", # window title
			minSize = ( windowWidth, windowHeight ), # minimum size (for resizing)
			maxSize = ( windowWidth + windowWidthResize, windowHeight + windowHeightResize ), # maximum size (for resizing)
			autosaveName = "com.pedroarilla.StartFromScratch.mainwindow" # stores last window position and size
		)

		# UI elements:
		self.w.text_1 = vanilla.TextBox( (15, 20*1, -15, 20), "Delete:", sizeStyle='regular' )
		self.w.cleanAnchors = vanilla.CheckBox( (15, 20*2+10, -15, 20), "Anchors", value=False, callback=self.SavePreferences, sizeStyle='regular' )
		self.w.cleanAnnotations = vanilla.CheckBox( (15, 20*3+10, -15, 20), "Annotations", value=False, callback=self.SavePreferences, sizeStyle='regular' )
		self.w.cleanBackgrounds = vanilla.CheckBox( (15, 20*4+10, -15, 20), "Backgrounds", value=False, callback=self.SavePreferences, sizeStyle='regular' )
		self.w.cleanGuidelines = vanilla.CheckBox( (15, 20*5+10, -15, 20), "Guidelines", value=False, callback=self.SavePreferences, sizeStyle='regular' )
		self.w.cleanImages = vanilla.CheckBox( (15, 20*6+10, -15, 20), "Images", value=False, callback=self.SavePreferences, sizeStyle='regular' )
		self.w.cleanKerning = vanilla.CheckBox( (15, 20*7+10, -15, 20), "Kerning groups", value=False, callback=self.SavePreferences, sizeStyle='regular' )
		self.w.cleanLabels = vanilla.CheckBox( (15, 20*8+10, -15, 20), "Labels", value=False, callback=self.SavePreferences, sizeStyle='regular' )
		self.w.cleanMetrics = vanilla.CheckBox( (15, 20*9+10, -15, 20), "Metric keys", value=False, callback=self.SavePreferences, sizeStyle='regular' )
		self.w.cleanLayers = vanilla.CheckBox( (15, 20*10+10, -15, 20), "Non-master layers", value=False, callback=self.SavePreferences, sizeStyle='regular' )
		self.w.cleanPaths = vanilla.CheckBox( (15, 20*11+10, -15, 20), "Paths and components", value=False, callback=self.SavePreferences, sizeStyle='regular' )

		self.w.text_2 = vanilla.TextBox( (15, 20*13, -15, 20), "Apply to glyphs:", sizeStyle='regular' )
		self.w.applyToGlyphs = vanilla.RadioGroup( (35, 20*14+10, -15, 20*2), ["Only selected glyphs", "All the glyphs in font"], isVertical = True, sizeStyle='regular', callback=self.SavePreferences )

		self.w.text_3 = vanilla.TextBox( (15, 20*17, -15, 20), "Apply to masters:", sizeStyle='regular' )
		self.w.applyToMasters = vanilla.RadioGroup( (35, 20*18+10, -15, 20*2), ["Only selected master", "All the masters"], isVertical = True, sizeStyle='regular', callback=self.SavePreferences )

		self.w.text_4 = vanilla.TextBox( (15, 20*21, -15, 20), "Apply to layers:", sizeStyle='regular' )
		self.w.applyToLayers = vanilla.RadioGroup( (35, 20*22+10, -15, 20*2), ["Only master layers", "All the layers"], isVertical = True, sizeStyle='regular', callback=self.SavePreferences )

		# Run Button:
		self.w.runButton = vanilla.Button( (-240+15, -20-15, -15, -15), "Are you sure? START!", sizeStyle='regular', callback=self.StartFromScratchMain )
		self.w.setDefaultButton( self.w.runButton )

		# Load Settings:
		if not self.LoadPreferences():
			print("Note: 'Start-from-scratch' could not load preferences. Will resort to defaults")

		# Open window and focus on it:
		self.w.open()
		self.w.makeKey()
Exemplo n.º 23
0
    def __init__(self):
        self.keysToControls = {}

        self.w = vanilla.FloatingWindow((185, 415), "Glyph Nanny")

        self.top = 10

        controls = [
            dict(key="unicodeValue", title="Unicode Value"),
            dict(key="contourCount", title="Contour Count")
        ]
        self.buildSettingsGroup("glyphChecks", "Glyph Checks", controls)

        controls = [
            dict(key="strayPoints", title="Stray Points"),
            dict(key="smallContours", title="Small Contours"),
            dict(key="openContours", title="Open Contours"),
            dict(key="duplicateContours", title="Duplicate Contours"),
            dict(key="extremePoints", title="Extreme Points"),
            dict(key="unnecessaryPoints", title="Unnecessary Points"),
            dict(key="unnecessaryHandles", title="Unnecessary Handles"),
            dict(key="overlappingPoints", title="Overlapping Points"),
            dict(key="pointsNearVerticalMetrics",
                 title="Points Near Vertical Metrics"),
            dict(key="complexCurves", title="Complex Curves"),
            dict(key="crossedHandles", title="Crossed Handles"),
            dict(key="straightLines", title="Straight Lines"),
            dict(key="unsmoothSmooths", title="Unsmooth Smooths"),
        ]
        self.buildSettingsGroup("outlineChecks", "Outline Checks", controls)

        self.w.fontLine = vanilla.HorizontalLine((10, self.top, -10, 1))
        self.top += 10
        self.w.testFontButton = vanilla.Button(
            (10, self.top, -10, 17),
            "Test Entire Font",
            sizeStyle="small",
            callback=self.testFontButtonCallback)

        self.setUpBaseWindowBehavior()
        self.startObserver()

        self.settingsCallback(None)

        self.w.open()
Exemplo n.º 24
0
    def __init__(self):
        # Window 'self.w':
        windowWidth = 250
        windowHeight = 200
        windowWidthResize = 800  # user can resize width by this value
        windowHeightResize = 800  # user can resize height by this value
        self.w = vanilla.FloatingWindow(
            (windowWidth, windowHeight),  # default window size
            "Rename Glyphs",  # window title
            minSize=(windowWidth, windowHeight),  # minimum size (for resizing)
            maxSize=(windowWidth + windowWidthResize, windowHeight +
                     windowHeightResize),  # maximum size (for resizing)
            autosaveName=
            "com.mekkablue.RenameGlyphs.mainwindow"  # stores last window position and size
        )

        # UI elements:
        self.w.text_1 = vanilla.TextBox((10, 12 + 2, -10, 14),
                                        "Add lines like oldname=newname:",
                                        sizeStyle='small')
        self.w.renameList = vanilla.TextEditor((1, 40, -1, -40),
                                               "oldname=newname",
                                               callback=self.SavePreferences)
        self.w.renameList.getNSTextView().setFont_(
            NSFont.userFixedPitchFontOfSize_(-1.0))
        self.w.renameList.getNSTextView().turnOffLigatures_(1)
        self.w.renameList.getNSTextView().useStandardLigatures_(0)
        self.w.renameList.selectAll()

        # Run Button:
        self.w.runButton = vanilla.Button((-100, -35, -15, -15),
                                          "Rename",
                                          sizeStyle='regular',
                                          callback=self.RenameGlyphsMain)
        #self.w.setDefaultButton( self.w.runButton )

        # Load Settings:
        if not self.LoadPreferences():
            print(
                "Note: 'Rename Glyphs' could not load preferences. Will resort to defaults"
            )

        # Open window and focus on it:
        self.w.open()
        self.w.makeKey()
Exemplo n.º 25
0
    def __init__(self):
        InputPosX = 90
        InputWidth = 50
        textHeight = 40
        self.w = vanilla.FloatingWindow((250, 45), "suffix glyphs")

        self.w.suffixText = vanilla.TextBox((10, 10, -10, textHeight),
                                            "suffix:")
        self.w.suffixValue = vanilla.EditText((InputPosX, 10, InputWidth, 20),
                                              ".ss01",
                                              sizeStyle='small')

        self.w.make_button = vanilla.Button((-80, 12, -15, 17),
                                            "Create",
                                            sizeStyle='small',
                                            callback=self.addSuffix)

        self.w.open()
Exemplo n.º 26
0
 def __init__(self):
     try:
         self.w = vanilla.FloatingWindow((200, windowHeight),
                                         "Cadence grid")
         self.w.text_anchor = vanilla.TextBox((15, 12, 130, 17),
                                              "Stem width",
                                              sizeStyle='small')
         self.w.stemWidth = vanilla.EditText((100, 10, 50, 20),
                                             "70",
                                             sizeStyle='small')
         self.w.go = vanilla.Button((-80, -32, -15, 17),
                                    "Cadence",
                                    sizeStyle='small',
                                    callback=self.addGrid)
         self.w.setDefaultButton(self.w.go)
         self.w.open()
     except Exception, e:
         print(e)
    def __init__(self):
        self.w = vanilla.FloatingWindow((280, 40), "Search for")

        self.w.textSearch = vanilla.TextBox((15, 12 + 2, 67, 14),
                                            "Search for:",
                                            sizeStyle='small')
        self.w.searchFor = vanilla.EditText((15 + 67, 12, 110, 19),
                                            "[",
                                            sizeStyle='small')

        self.w.findButton = vanilla.Button((-80, 12 + 1, -15, 17),
                                           "Find",
                                           sizeStyle='small',
                                           callback=self.buttonCallback)
        self.w.setDefaultButton(self.w.findButton)

        self.w.center()
        self.w.open()
 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  = 290
		windowHeight = 170	
		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
			"Alignment Zones for Selected Glyphs", # window title
			minSize = ( windowWidth, windowHeight ), # minimum size (for resizing)
			maxSize = ( windowWidth + windowWidthResize, windowHeight + windowHeightResize ), # maximum size (for resizing)
			autosaveName = "com.mekkablue.CreateAlignmentZonesforSelectedGlyphs.mainwindow" # stores last window position and size
		)
		
		# UI elements:
		linePos, inset, lineHeight = 8, 12, 22
		
		self.w.descriptionText = vanilla.TextBox( (inset, linePos+2, -inset, int(lineHeight*1.5)), u"Create alignment zones for selected glyphs. Detailed report in Macro Window.", sizeStyle='small', selectable=True )
		linePos += int(lineHeight*1.7)
		
		self.w.createTopZones = vanilla.CheckBox( (inset, linePos-1, -inset, 20), u"Create top zones for selected glyphs", value=True, callback=self.SavePreferences, sizeStyle='small' )
		self.w.createTopZones.getNSButton().setToolTip_(u"If enabled, will create top zones that match the currently selected glyphs, for every master. The height of the lowest selected glyph will be the zone position, the difference to the highest glyph will be the size of the zone.")
		linePos += lineHeight
		
		self.w.createBottomZones = vanilla.CheckBox( (inset, linePos-1, -inset, 20), u"Create bottom zones for selected glyphs", value=True, callback=self.SavePreferences, sizeStyle='small' )
		self.w.createBottomZones.getNSButton().setToolTip_(u"If enabled, will create bottom zones that match the currently selected glyphs, for every master. The highest bottom edge is the zone position, the difference to the lowest bottom edge will be the zone size.")
		linePos += lineHeight
		
		self.w.dontExceedExistingZones = vanilla.CheckBox( (inset, linePos-1, -inset, 20), u"Prevent zone sizes bigger than current zones", value=True, callback=self.SavePreferences, sizeStyle='small' )
		self.w.dontExceedExistingZones.getNSButton().setToolTip_(u"Recommended. If enabled, will make sure that no zone will be added that is larger than existing zones in the master.")
		linePos += lineHeight
		
		
		# Run Button:
		self.w.runButton = vanilla.Button( (-120-inset, -20-inset, -inset, -inset), "Create Zones", sizeStyle='regular', callback=self.CreateAlignmentZonesforSelectedGlyphsMain )
		self.w.setDefaultButton( self.w.runButton )
		
		# Load Settings:
		if not self.LoadPreferences():
			print("Note: 'Create Alignment Zones for Selected Glyphs' could not load preferences. Will resort to defaults")
		
		# Open window and focus on it:
		self.w.open()
		self.w.makeKey()
Exemplo n.º 30
0
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()