コード例 #1
0
ファイル: suffixer.py プロジェクト: ninastoessinger/Suffixer
    def openWindow(self, sender=None):
    	""" Initialize the input window. """
        presets = [
            "case", "dnom", "fina", "hist", "init", "isol", "locl", "lnum", "medi", "numr", "onum", "ordn", "tnum",
            "pcap", "salt", "sinf", "smcp", "ss01", "ss02", "ss03", "ss04", "ss05", "ss06", "ss07", "ss08",
            "ss09", "ss10", "ss11", "ss12", "ss13", "ss14", "ss15", "ss16", "ss17", "ss18", "ss19", "ss20",
            "subs", "sups", "swsh", "titl", "zero" ]
        presetList = " ".join(presets)
        registerExtensionDefaults({"nl.typologic.suffixer.presetSuffixes" : presetList})
        currentPresets = getExtensionDefault("nl.typologic.suffixer.presetSuffixes").split()
        
        self.f = CurrentFont()
        if self.f is None:
            print "Suffixer: No font open"
            return
        
        existingSuffixes = []
        for g in self.f:
            suf = self._findSuffix(g.name)
            if suf != None and suf not in existingSuffixes:
                existingSuffixes.append(suf)
        existingSuffixes.sort()
        
        currentSuffix = ""
        if CurrentGlyph() is not None:
            currentSuffix = self._findSuffix(CurrentGlyph().name)
        elif self.f.selection is not None:
            for gn in self.f.selection:
                currentSuffix = self._findSuffix(gn)
                if currentSuffix != None:
                    break
        
        self.w = FloatingWindow((300, 166), "Suffixer")
        p = 10
        h = 20
        y1, y2, y3, y4 = 15, 49, 82, 135
        w1, x2 = 160, 180
        
        self.w.labelTwo = TextBox((p, y1, w1, h), "Add suffix to glyph names:")
        self.w.dotTwo = TextBox((x2, y1, 15, h), ".")
        self.w.newSuffix = ComboBox((x2+p, y1, -p, h), currentPresets)
        
        self.w.replace = CheckBox((p+2, y2, w1, h), "Replace existing suffix:", callback=self.replaceCheckCallback)
        
        self.w.dotOne = TextBox((x2, y2, 15, h), ".")
        self.w.oldSuffix = PopUpButton((x2+p, y2, -p, h), existingSuffixes)
        if currentSuffix != "" and currentSuffix != None:
            self.w.oldSuffix.set(existingSuffixes.index(currentSuffix))
        
        self.w.scope = RadioGroup((p, y3, -p, h*2), ["Target selected glyphs", "Replace all in current font"], isVertical=True)
        self.w.scope.set(0)

        currentState = 0 if currentSuffix == "" or currentSuffix == None else 1
        self.w.replace.set(currentState)
        self.w.scope.enable(currentState)
            
        self.w.submit = Button((p, y4, -p, h), "Change suffixes", callback=self.replaceSuffixes)
        self.w.setDefaultButton(self.w.submit)
        self.w.open()
        self.w.makeKey()
コード例 #2
0
def registerMechanicDefaults(reset=False):
    defaults = {
        "com.mechanic.urlstreams": [extensionStoreDataURL, mechanicDataURL],
        "com.mechanic.checkForUpdate": True,
        "com.mechanic.singleExtensionItems": [],
        "com.mechanic.lastUpdateCheck": 0,
    }
    if reset:
        for key in defaults:
            removeExtensionDefault(key)
    registerExtensionDefaults(defaults)
コード例 #3
0
    def __init__(self):

        self.prefKey = 'com.okaytype.addOverlap'
        initialDefaults = {self.pref: '-30'}
        registerExtensionDefaults(initialDefaults)
        self.toolValue = getExtensionDefault(self.pref)

        addObserver(self, "addOverlapToolbarItem",
                    "glyphWindowWillShowToolbarItems")
        addObserver(self, "addOverlapValueUI", "glyphWindowWillOpen")
        addObserver(self, 'updateSelfWindow', 'currentGlyphChanged')
コード例 #4
0
ファイル: controller.py プロジェクト: typoman/robohud
 def __init__(self):
     extensions.registerExtensionDefaults(defaults)
     self._active = True
     self._classes = {}
     self._positions = {}
     self._displayed = {}
     self._margin = None
     self._foregroundColor = None
     self._backgroundColor = None
     self._inactiveOpacity = None
     self._loadDefaults()
     events.addObserver(self, "_glyphWindowWillCloseCallback",
                        "glyphWindowWillClose")
     events.addObserver(self, "_glyphWindowWillOpenCallback",
                        "glyphWindowWillOpen")
     self.addControlsToExistingWindows()
コード例 #5
0
ファイル: Sidebear.py プロジェクト: ryanbugden/Sidebear
    def __init__(self, resources_path):

        self.pref_key = 'com.ryanbugden.sidebear.increment'

        initialDefaults = {
            self.pref_key: 2,
        }
        registerExtensionDefaults(initialDefaults)

        try:
            self.g = CurrentGlyph()
        except:
            self.g = None

        window_width = 255
        window_margin = 20
        gutter = 25
        vert_gutter = 12
        rule_gutter = vert_gutter - 2
        text_box_height = 20
        row_1_y = -14
        row_2_y = row_1_y + vert_gutter + text_box_height - 5
        row_3_y = row_2_y + vert_gutter + text_box_height
        row_4_y = row_3_y + text_box_height + rule_gutter
        row_5_y = row_4_y + rule_gutter
        third_width = (window_width - (window_margin * 2) - (gutter * 2)) / 3
        self.window_height = window_margin * 2 + row_5_y + text_box_height + 8

        # The group of elements
        self.w = vanilla.Group((0, 0, -0, -0))

        # Current glyph
        self.w.curr_glyph_note = vanilla.TextBox(
            (window_margin + third_width / 2, window_margin + row_1_y,
             third_width * 2 + gutter * 2, text_box_height),
            "None",
            sizeStyle="regular",
            alignment="center")

        # Left width span rule
        self.w.left_w_span = vanilla.HorizontalLine(
            (window_margin + 2,
             window_margin + row_1_y + (text_box_height / 2), third_width, 1))

        # Left width vert rule
        self.w.left_w_vert = vanilla.VerticalLine(
            (window_margin + 1, window_margin + row_1_y, 1, text_box_height))

        # Right width span rule
        self.w.right_w_span = vanilla.HorizontalLine(
            (window_margin + third_width * 2 + gutter * 2,
             window_margin + row_1_y + (text_box_height / 2), third_width - 1,
             1))

        # Right width vert rule
        self.w.right_w_vert = vanilla.VerticalLine(
            (window_margin + third_width * 3 + gutter * 2 - 1,
             window_margin + row_1_y, 1, text_box_height))

        # Left side-bearing
        self.w.LSB = vanilla.EditText((window_margin, window_margin + row_2_y,
                                       third_width, text_box_height),
                                      text="",
                                      sizeStyle="small",
                                      callback=self.editLSBCallback,
                                      continuous=False)
        self.w.LSB.getNSTextField().setFocusRingType_(1)
        self.w.LSB.getNSTextField().setAlignment_(2)

        # Left swap bridge rule
        self.w.left_sw_rule = vanilla.HorizontalLine(
            (window_margin + third_width,
             window_margin + row_2_y + text_box_height / 2, gutter, 1))

        # Swap SB button
        self.w.swap_SB = vanilla.ImageButton(
            (window_margin + third_width + gutter, window_margin + row_2_y,
             third_width, text_box_height),
            imagePath=resources_path + '/_icon_Swap.pdf',
            callback=self.swapSBButtonCallback,
            sizeStyle='regular')

        # Right swap bridge rule
        self.w.right_sw_rule = vanilla.HorizontalLine(
            (window_margin + third_width * 2 + gutter,
             window_margin + row_2_y + text_box_height / 2, gutter, 1))

        # Right side-bearing
        self.w.RSB = vanilla.EditText(
            (window_margin + third_width * 2 + gutter * 2,
             window_margin + row_2_y, third_width, text_box_height),
            text="",
            sizeStyle="small",
            callback=self.editRSBCallback,
            continuous=False)
        self.w.RSB.getNSTextField().setFocusRingType_(1)
        self.w.RSB.getNSTextField().setAlignment_(2)

        # Center Glyph button
        self.w.center_glyph = vanilla.ImageButton(
            (window_margin + third_width + gutter, window_margin + row_3_y,
             third_width, text_box_height),
            imagePath=resources_path + '/_icon_Center.pdf',
            callback=self.centerGlyphButtonCallback,
            sizeStyle='regular')

        # Left vert bridge rule
        self.w.left_vert_rule = vanilla.VerticalLine(
            (window_margin + third_width / 2,
             window_margin + row_2_y + text_box_height, 1, vert_gutter))

        # Right vert bridge rule
        self.w.right_vert_rule = vanilla.VerticalLine(
            (window_margin + third_width * 2.5 + gutter * 2,
             window_margin + row_2_y + text_box_height, 1, vert_gutter))

        # Equals RSB button
        self.w.equals_RSB = vanilla.ImageButton(
            (window_margin, window_margin + row_3_y, third_width,
             text_box_height),
            imagePath=resources_path + '/_icon_EqualRSB.pdf',
            callback=self.equalsRSBButtonCallback,
            sizeStyle='regular')

        # Equals LSB button
        self.w.equals_LSB = vanilla.ImageButton(
            (window_margin + third_width * 2 + gutter * 2,
             window_margin + row_3_y, third_width, text_box_height),
            imagePath=resources_path + '/_icon_EqualLSB.pdf',
            callback=self.equalsLSBButtonCallback,
            sizeStyle='regular')

        # Rule
        self.w.rule = vanilla.HorizontalLine(
            (window_margin, window_margin + row_4_y,
             third_width * 3 + gutter * 2, 1))

        # Increment input
        self.increment = getExtensionDefault(self.pref_key, 2)
        self.w.inc_text_box = vanilla.EditText(
            (window_margin + gutter + third_width, window_margin + row_5_y,
             third_width, text_box_height),
            text="%s" % self.increment,
            sizeStyle="small",
            callback=self.incrementCallback)
        self.w.inc_text_box.getNSTextField().setFocusRingType_(1)
        self.w.inc_text_box.getNSTextField().setAlignment_(2)

        # Left expand/contract bridge rule
        self.w.left_ec_rule = vanilla.HorizontalLine(
            (window_margin + third_width,
             window_margin + row_5_y + text_box_height / 2, gutter, 1))

        # Right expand/contract bridge rule
        self.w.right_ec_rule = vanilla.HorizontalLine(
            (window_margin + third_width * 2 + gutter,
             window_margin + row_5_y + text_box_height / 2, gutter, 1))

        # Close SBs
        self.w.close_SB = vanilla.ImageButton(
            (window_margin, window_margin + row_5_y, third_width,
             text_box_height),
            imagePath=resources_path + '/_icon_Close.pdf',
            callback=self.closeSBButtonCallback,
            sizeStyle='regular')

        # Open SBs
        self.w.open_SB = vanilla.ImageButton(
            (window_margin + third_width * 2 + gutter * 2,
             window_margin + row_5_y, third_width, text_box_height),
            imagePath=resources_path + '/_icon_Open.pdf',
            callback=self.openSBButtonCallback,
            sizeStyle='regular')

        # Increment
        self.w.incr_caption = vanilla.TextBox(
            (window_margin + third_width, window_margin + row_5_y + 23,
             third_width + gutter * 2, text_box_height),
            "Increment",
            sizeStyle="mini",
            alignment="center")

        addObserver(self, "glyphChanged", "currentGlyphChanged")
        addObserver(self, "glyphChanged", "viewDidChangeGlyph")
        addObserver(self, "glyphChanged", "glyphWindowDidOpen")
        addObserver(self, "glyphDraw", "draw")

        self.updateUI_BothSB()
コード例 #6
0
ファイル: suffixer.py プロジェクト: typoman/Suffixer
    def openWindow(self, sender=None):
        """ Initialize the input window. """
        presets = [
            "case", "dnom", "fina", "hist", "init", "isol", "locl", "lnum",
            "medi", "numr", "onum", "ordn", "tnum", "pcap", "salt", "sinf",
            "smcp", "ss01", "ss02", "ss03", "ss04", "ss05", "ss06", "ss07",
            "ss08", "ss09", "ss10", "ss11", "ss12", "ss13", "ss14", "ss15",
            "ss16", "ss17", "ss18", "ss19", "ss20", "subs", "sups", "swsh",
            "titl", "zero"
        ]
        presetList = " ".join(presets)
        registerExtensionDefaults(
            {"nl.typologic.suffixer.presetSuffixes": presetList})
        currentPresets = getExtensionDefault(
            "nl.typologic.suffixer.presetSuffixes").split()

        self.f = CurrentFont()
        if self.f is None:
            print "Suffixer: No font open"
            return

        existingSuffixes = []
        for g in self.f:
            suf = self._findSuffix(g.name)
            if suf != None and suf not in existingSuffixes:
                existingSuffixes.append(suf)
        existingSuffixes.sort()

        currentSuffix = ""
        if CurrentGlyph() is not None:
            currentSuffix = self._findSuffix(CurrentGlyph().name)
        elif self.f.selection is not None:
            for gn in self.f.selection:
                currentSuffix = self._findSuffix(gn)
                if currentSuffix != None:
                    break

        self.w = FloatingWindow((300, 166), "Suffixer")
        p = 10
        h = 20
        y1, y2, y3, y4 = 15, 49, 82, 135
        w1, x2 = 160, 180

        self.w.labelTwo = TextBox((p, y1, w1, h), "Add suffix to glyph names:")
        self.w.dotTwo = TextBox((x2, y1, 15, h), ".")
        self.w.newSuffix = ComboBox((x2 + p, y1, -p, h), currentPresets)

        self.w.replace = CheckBox((p + 2, y2, w1, h),
                                  "Replace existing suffix:",
                                  callback=self.replaceCheckCallback)

        self.w.dotOne = TextBox((x2, y2, 15, h), ".")
        self.w.oldSuffix = PopUpButton((x2 + p, y2, -p, h), existingSuffixes)
        if currentSuffix != "" and currentSuffix != None:
            self.w.oldSuffix.set(existingSuffixes.index(currentSuffix))

        self.w.scope = RadioGroup(
            (p, y3, -p, h * 2),
            ["Target selected glyphs", "Replace all in current font"],
            isVertical=True)
        self.w.scope.set(0)

        currentState = 0 if currentSuffix == "" or currentSuffix == None else 1
        self.w.replace.set(currentState)
        self.w.scope.enable(currentState)

        self.w.submit = Button((p, y4, -p, h),
                               "Change suffixes",
                               callback=self.replaceSuffixes)
        self.w.setDefaultButton(self.w.submit)
        self.w.open()
        self.w.makeKey()
コード例 #7
0
ファイル: robosounds.py プロジェクト: typesupply/robosounds
        "speak": "New font did open."
    },
    "newFontWillOpen": {
        "frequency": 1.0,
        "sound": "no sound",
        "speak": "New font will open."
    }
}

# --------
# Defaults
# --------

extensions.registerExtensionDefaults({
    defaultStub + "audible": True,
    defaultStub + "soundDirectory": "",
    defaultStub + "events": coachMode,
})

# ----------
# Controller
# ----------


class _RoboSoundsController(object):
    def __init__(self):
        self.loadUserDefaults()
        self.loadSounds()

    # -----------
    # Observation
コード例 #8
0
_PDFFolderKey = "%s.Folder" % PDFKey
_PDFTimeStampOnOffKey = "%s.TimeStampOnOff" % PDFKey
_PDFTimeStampKey = "%s.TimeStamp" % PDFKey
_PDFOpenPDFKey = "%s.OpenKey" % PDFKey
_PDFTextLimitKey = "%s.TextLimit" %PDFKey


defaults = dict()
defaults[_PDFFileNameKey] = 'RoboFontSpaceCenter'
defaults[_PDFFolderPathKey] = '/Users/%s/Desktop' % getlogin()
defaults[_PDFFolderKey] = 0
defaults[_PDFTimeStampOnOffKey] = False
defaults[_PDFTimeStampKey] = "%y%m%d_%H%M%S"
defaults[_PDFOpenPDFKey] = True
defaults[_PDFTextLimitKey] = 5
registerExtensionDefaults(defaults)

extra = """Extra options for file name:
%ufo = ufo file name
%text = actual text in the spacecenter"""

class PDFSettings(object):
	def __init__(self):
		width = 300
		height = 400
		y=7
		self.w = FloatingWindow((width, height), "PDF Settings")

		# file name
		self.w.fileNameText = TextBox((10,y,-10,22), "File name", sizeStyle='small')
		self.w.fileNameEdit = EditText((10,y+22,-10,25), text=getExtensionDefault(_PDFFileNameKey), callback=self._warning, continuous=False)