예제 #1
0
    def __init__(self, posSize, callback):
        super(WordListController, self).__init__(posSize)
        x, y, self.ctrlWidth, self.ctrlHeight = posSize
        self.callback = callback

        # handling kerning words
        self.kerningWordsDB = loadKerningTexts(STANDARD_KERNING_TEXT_FOLDER)
        self.kerningTextBaseNames = self.kerningWordsDB.keys()
        self.activeKerningTextBaseName = self.kerningTextBaseNames[0]
        # this is the list used for data manipulation
        self.wordsWorkingList = self.kerningWordsDB[self.activeKerningTextBaseName]
        # this list instead is used for data visualization in the ctrl
        self._makeWordsDisplayList(self.activeKerningTextBaseName)
        self.activeWord = self.wordsWorkingList[0]['word']
        self.wordFilter = ''

        jumping_Y = 0
        self.kerningVocabularyPopUp = PopUpButton((0, jumping_Y, self.ctrlWidth*.6, vanillaControlsSize['PopUpButtonRegularHeight']),
                                                  self.kerningTextBaseNames,
                                                  callback=self.kerningVocabularyPopUpCallback)

        self.openTextsFolderButton = SquareButton((self.ctrlWidth*.62, jumping_Y, self.ctrlWidth*.38, vanillaControlsSize['PopUpButtonRegularHeight']+1),
                                                  'Load texts...',
                                                  sizeStyle='small',
                                                  callback=self.openTextsFolderButtonCallback)

        wordsColumnDescriptors = [
            {'title': '#', 'width': 30, 'editable': False},
            {'title': 'word', 'width': self.ctrlWidth-80, 'editable': False},
            {'title': 'done?', 'width': 35, 'cell': CheckBoxListCell(), 'editable': False}]

        jumping_Y += self.openTextsFolderButton.getPosSize()[3] + MARGIN_VER
        self.wordsListCtrl = List((0, jumping_Y, self.ctrlWidth, 170),
                                  self.wordsDisplayList,
                                  enableDelete=False,
                                  allowsMultipleSelection=False,
                                  columnDescriptions=wordsColumnDescriptors,
                                  selectionCallback=self.wordsListCtrlSelectionCallback,
                                  doubleClickCallback=self.wordsListCtrlDoubleClickCallback)

        jumping_Y += self.wordsListCtrl.getPosSize()[3] + MARGIN_VER
        self.wordsFilterCtrl = EditText((-70, jumping_Y-1, 70, vanillaControlsSize['EditTextRegularHeight']),
                                        placeholder='filter...',
                                        callback=self.wordsFilterCtrlCallback)

        self.wordsDone = len([row['done?'] for row in self.wordsWorkingList if row['done?'] != 0])
        self.infoCaption = TextBox((0, jumping_Y+2, self.ctrlWidth-self.wordsFilterCtrl.getPosSize()[2], vanillaControlsSize['TextBoxRegularHeight']),
                                   'done: {:d}/{:d}'.format(self.wordsDone, len(self.wordsWorkingList)))

        jumping_Y += self.wordsFilterCtrl.getPosSize()[3] + MARGIN_VER
        self.loadStatus = SquareButton((0, jumping_Y, 90, vanillaControlsSize['ButtonRegularHeight']+2),
                                       'Load status',
                                       callback=self.loadStatusCallback)

        self.saveButton = SquareButton((-90, jumping_Y, 90, vanillaControlsSize['ButtonRegularHeight']+2),
                                       'Save status',
                                       callback=self.saveButtonCallback)
예제 #2
0
    def __init__(self):
        self.transferList = NAME_2_GLYPHLIST[GLYPHLISTS_OPTIONS[0]]
        self.target = TARGET_OPTIONS[0]

        self.w = FloatingWindow((0, 0, PLUGIN_WIDTH, 400), PLUGIN_TITLE)
        jumpingY = MARGIN_VER

        # target fonts
        self.w.targetFontsPopUp = PopUpButton(
            (MARGIN_HOR, jumpingY, NET_WIDTH,
             vanillaControlsSize['PopUpButtonRegularHeight']),
            TARGET_OPTIONS,
            callback=self.targetFontsPopUpCallback)
        jumpingY += vanillaControlsSize['PopUpButtonRegularHeight'] + MARGIN_VER

        # transfer lists pop up
        self.w.glyphListPopUp = PopUpButton(
            (MARGIN_HOR, jumpingY, NET_WIDTH,
             vanillaControlsSize['PopUpButtonRegularHeight']),
            GLYPHLISTS_OPTIONS,
            callback=self.glyphListPopUpCallback)
        jumpingY += vanillaControlsSize['PopUpButtonRegularHeight'] + MARGIN_VER

        # offset caption
        self.w.offsetCaption = TextBox(
            (MARGIN_HOR, jumpingY + 2, NET_WIDTH * .22,
             vanillaControlsSize['TextBoxRegularHeight']), 'Offset:')

        # offset edit text
        self.w.offsetEdit = EditText(
            (MARGIN_HOR + NET_WIDTH * .25, jumpingY, NET_WIDTH * .35,
             vanillaControlsSize['EditTextRegularHeight']),
            continuous=False,
            callback=self.offsetEditCallback)
        self.w.offsetEdit.set('%d' % self.verticalOffset)
        jumpingY += vanillaControlsSize['EditTextRegularHeight'] + MARGIN_VER

        # clean button
        self.w.cleanButton = Button(
            (MARGIN_HOR, jumpingY, NET_WIDTH * .45,
             vanillaControlsSize['ButtonRegularHeight']),
            'Clean',
            callback=self.cleanButtonCallback)

        # run button
        self.w.runButton = Button(
            (MARGIN_HOR + NET_WIDTH * .55, jumpingY, NET_WIDTH * .45,
             vanillaControlsSize['ButtonRegularHeight']),
            'Run!',
            callback=self.runButtonCallback)
        jumpingY += vanillaControlsSize['ButtonRegularHeight'] + MARGIN_VER

        self.w.setPosSize((0, 0, PLUGIN_WIDTH, jumpingY))
        self.w.open()
예제 #3
0
    def __init__(self):
        self.fontTarget = FONT_TARGET_OPTIONS[0]
        self.glyphTarget = GLYPH_TARGET_OPTIONS[0]
        self.gridSize = 4

        self.w = FloatingWindow((0, 0, PLUGIN_WIDTH, 400), PLUGIN_TITLE)
        jumpingY = MARGIN_VER

        # font target
        self.w.fontTargetPopUp = PopUpButton(
            (MARGIN_HOR, jumpingY, NET_WIDTH,
             vanillaControlsSize['PopUpButtonRegularHeight']),
            FONT_TARGET_OPTIONS,
            callback=self.fontTargetPopUpCallback)
        jumpingY += vanillaControlsSize['PopUpButtonRegularHeight'] + MARGIN_VER

        # glyph target
        self.w.glyphTargetPopUp = PopUpButton(
            (MARGIN_HOR, jumpingY, NET_WIDTH,
             vanillaControlsSize['PopUpButtonRegularHeight']),
            GLYPH_TARGET_OPTIONS,
            callback=self.glyphTargetPopUpCallback)
        jumpingY += vanillaControlsSize['PopUpButtonRegularHeight'] + MARGIN_VER

        # grid size captions
        self.w.gridSizeCaption = TextBox(
            (MARGIN_HOR, jumpingY + 2, NET_WIDTH * .32,
             vanillaControlsSize['TextBoxRegularHeight']), 'Grid Size:')

        # grid size edit
        self.w.gridSizeEdit = EditText(
            (MARGIN_HOR + NET_WIDTH * .32, jumpingY, NET_WIDTH * .3,
             vanillaControlsSize['EditTextRegularHeight']),
            text='{:d}'.format(self.gridSize),
            callback=self.gridSizeEditCallback)
        jumpingY += vanillaControlsSize['EditTextRegularHeight'] + MARGIN_VER

        self.w.moveBcpHandlesCheck = CheckBox(
            (MARGIN_HOR, jumpingY, NET_WIDTH,
             vanillaControlsSize['CheckBoxRegularHeight']),
            'move bcp handles',
            value=self.bcpHandlesFit,
            callback=self.moveBcpHandlesCheckCallback)
        jumpingY += vanillaControlsSize['CheckBoxRegularHeight'] + MARGIN_VER

        # fit button
        self.w.fitButton = Button((MARGIN_HOR, jumpingY, NET_WIDTH,
                                   vanillaControlsSize['ButtonRegularHeight']),
                                  'Fit!',
                                  callback=self.fitButtonCallback)
        jumpingY += vanillaControlsSize['ButtonRegularHeight'] + MARGIN_VER

        self.w.setPosSize((0, 0, PLUGIN_WIDTH, jumpingY))
        self.w.open()
예제 #4
0
    def __init__(self):
        self.master_names = [m.name for m in Glyphs.font.masters][1:]

        item_height = 24.0
        w_width = 350.0
        w_height = item_height * 5
        margin = 10
        next_y = margin
        col_1_width = w_width - (margin * 2)
        item_height = 24

        self.w = Window((w_width, w_height), "Convert Master to Brace Layers")

        next_y = margin
        self.w.master_names_label = TextBox((margin, next_y + 2, col_1_width, item_height), "Master to Convert (Cannot be the first Master)", sizeStyle='regular')
        next_y += item_height
        self.w.master_names = PopUpButton((margin, next_y, col_1_width, item_height), self.master_names)
        next_y += item_height + margin
        selected_master_index = Glyphs.font.masters.index(Glyphs.font.selectedFontMaster)
        self.w.master_names.set(selected_master_index - 1)

        self.w.gobutton = Button((margin + (col_1_width / 4), next_y, col_1_width / 2, item_height), 'Add Brace Layers', callback=self.makeitso)

        self.w.setDefaultButton(self.w.gobutton)

        self.w.open()
예제 #5
0
    def __init__(self):
        super(VisualReporter, self).__init__()

        self.allFonts = AllFonts()
        self.sortAllFonts()
        self.collectFontNames()

        self.w = Window((0, 0, PLUGIN_WIDTH, 1), PLUGIN_TITLE)

        jumpingY = UI_MARGIN
        self.w.fontsPopUp = PopUpButton(
            (UI_MARGIN, jumpingY, NET_WIDTH,
             vanillaControlsSize['PopUpButtonRegularHeight']),
            self.fontNames,
            callback=None)

        jumpingY += vanillaControlsSize['PopUpButtonRegularHeight'] + UI_MARGIN
        self.w.reportButton = SquareButton(
            (UI_MARGIN, jumpingY, NET_WIDTH,
             vanillaControlsSize['ButtonRegularHeight'] * 1.5),
            'Generate PDF Report',
            callback=self.reportButtonCallback)
        jumpingY += vanillaControlsSize['ButtonRegularHeight'] * 1.5 + UI_MARGIN

        self.setUpBaseWindowBehavior()
        addObserver(self, 'updateFontOptions', "newFontDidOpen")
        addObserver(self, 'updateFontOptions', "fontDidOpen")
        addObserver(self, 'updateFontOptions', "fontWillClose")
        self.w.bind("close", self.windowCloseCallback)
        self.w.resize(PLUGIN_WIDTH, jumpingY)
        self.w.open()
예제 #6
0
    def __init__(self):

        # base window
        self.w = FloatingWindow((0, 0, PLUGIN_WIDTH, PLUGIN_HEIGHT))

        jumpingY = MARGIN_VER
        self.w.libChoice = PopUpButton(
            (MARGIN_HOR, jumpingY, NET_WIDTH,
             vanillaControlsSize['PopUpButtonRegularHeight']), ['A', 'B', 'C'],
            callback=self.libChoiceCallback)

        jumpingY += vanillaControlsSize['PopUpButtonRegularHeight'] + MARGIN_VER
        self.w.addButton = SquareButton(
            (MARGIN_HOR, jumpingY, NET_WIDTH * .6, SQUARE_BUTTON_HEIGHT),
            'add stem',
            callback=self.addButtonCallback)

        self.w.checkBoxStar = CheckBoxStar(
            (MARGIN_HOR + MARGIN_VER + NET_WIDTH * .6, jumpingY,
             NET_WIDTH * .35, NET_WIDTH * .35),
            callback=self.checkBoxStarCallback)

        jumpingY += SQUARE_BUTTON_HEIGHT + MARGIN_VER
        self.w.removeButton = SquareButton(
            (MARGIN_HOR, jumpingY, NET_WIDTH * .6, SQUARE_BUTTON_HEIGHT),
            'remove stem',
            callback=self.removeButtonCallback)

        # lit up!
        self.w.open()
예제 #7
0
    def __init__(self, posSize, fontOptions, whichFont, actions, whichAction,
                 glyphLists, whichGlyphList, markColor, markEditedGlyphs,
                 callback):
        super(SharedCtrls, self).__init__(posSize)

        x, y, width, height = posSize
        self.fontOptions = fontOptions
        self.fontOptionsRepr = ['All Fonts', 'Current Font'] + [
            '{} {}'.format(ff.info.familyName, ff.info.styleName)
            for ff in self.fontOptions[2:]
        ]
        self.whichFont = whichFont
        self.actions = actions
        self.whichAction = whichAction
        self.glyphLists = glyphLists
        self.whichGlyphList = whichGlyphList
        self.markColor = markColor
        self.markEditedGlyphs = markEditedGlyphs
        self.callback = callback

        jumpinY = 0
        self.popFonts = PopUpButton(
            (1, jumpinY, width - 1,
             vanillaControlsSize['PopUpButtonRegularHeight']),
            self.fontOptionsRepr,
            callback=self.popFontsCallback)

        jumpinY += vanillaControlsSize['PopUpButtonRegularHeight'] + MARGIN_ROW
        self.popAction = PopUpButton(
            (1, jumpinY, width - 1,
             vanillaControlsSize['PopUpButtonRegularHeight']),
            self.actions,
            callback=self.popActionCallback)

        jumpinY += vanillaControlsSize['PopUpButtonRegularHeight'] + MARGIN_ROW
        self.popGlyphList = PopUpButton(
            (1, jumpinY, width - 1,
             vanillaControlsSize['PopUpButtonRegularHeight']),
            self.glyphLists[self.whichAction].keys(),
            callback=self.popGlyphListCallback)

        jumpinY += vanillaControlsSize[
            'PopUpButtonRegularHeight'] + MARGIN_ROW + 2
        self.checkMarkEditedColors = CheckBox(
            (0, jumpinY, width * .35,
             vanillaControlsSize['CheckBoxRegularHeight']),
            "Color",
            value=self.markEditedGlyphs,
            callback=self.checkMarkEditedColorsCallback)

        self.popColors = PopUpButton(
            (width * .4, jumpinY, width * .6,
             vanillaControlsSize['PopUpButtonRegularHeight']),
            glyphCollectionColors.keys(),
            callback=self.popColorsCallback)
        self.popColors.enable(self.markEditedGlyphs)
예제 #8
0
    def __init__(self, posSize, title, isActive, openedFontPaths,
                 activeFontPath, activeGlyphName, callback):
        Group.__init__(self, posSize)
        self.isActive = isActive
        self.openedFontPaths = openedFontPaths
        self.activeFontPath = activeFontPath
        self.activeGlyphName = activeGlyphName
        self.callback = callback
        ctrlWidth = posSize[2]

        # ui
        jumpingY = 4
        self.isActiveCheck = CheckBox(
            (0, jumpingY, ctrlWidth,
             vanillaControlsSize['CheckBoxRegularHeight']),
            title,
            value=self.isActive,
            callback=self.isActiveCallback)

        jumpingY += vanillaControlsSize['CheckBoxRegularHeight'] + 2
        self.fontPop = PopUpButton(
            (1, jumpingY, ctrlWidth - 1,
             vanillaControlsSize['PopUpButtonRegularHeight']),
            makeFontList(openedFontPaths),
            callback=self.fontPopCallback)

        jumpingY += vanillaControlsSize['PopUpButtonRegularHeight'] + MARGIN_VER

        if self.activeFontPath == CURRENT_FONT_REPR:
            activeFont = CurrentFont()
        else:
            activeFont = getOpenedFontFromPath(AllFonts(), self.activeFontPath)
        self.glyphPop = PopUpButton(
            (1, jumpingY, ctrlWidth - 1,
             vanillaControlsSize['ComboBoxRegularHeight']),
            makeGlyphList(activeFont),
            callback=self.glyphPopCallback)
예제 #9
0
    def __init__(self):
        item_height = 24.0
        w_width = 500.0
        w_height = item_height * 12
        margin = 10
        next_y = margin
        col_1_width = w_width - (margin * 2)
        item_height = 24

        self.get_prefs('copyMetricsFromFont.pref')

        self.available_layers = dict(
            ('{} - {}'.format(os.path.basename(font.filepath), master), master)
            for font in Glyphs.fonts for master in font.masters)

        self.w = Window((w_width, w_height), "Copy Metrics")

        self.w.hText_2 = TextBox((margin, next_y, col_1_width, item_height),
                                 "Copy metrics from this font/layer:",
                                 sizeStyle='regular')
        next_y += item_height
        self.w.available_layers = PopUpButton(
            (margin, next_y, col_1_width, item_height),
            sorted(self.available_layers.keys()
                   ))  # , callback=self.update_brace_value)
        next_y += item_height + margin
        metrics_options = [
            'Left sidebearing Only',
            'Right sidebearing Only',
            'Width Only (keep LSB)',
            'Width Only (assign proportionally)',
            "Left sidebearing and Width",
            "Left sidebearing and Right sidebearing",
            'Width and Right sidebearing',
        ]
        self.w.metrics_to_copy = RadioGroup(
            (margin, next_y, col_1_width, item_height * len(metrics_options)),
            metrics_options)
        self.w.metrics_to_copy.set(int(self.prefs.get('metrics_to_copy', 0)))
        next_y += item_height * len(metrics_options) + margin

        self.w.gobutton = Button(
            (margin + (col_1_width / 4), next_y, col_1_width / 2, item_height),
            'Copy Metrics',
            callback=self.makeitso)
        next_y += item_height

        self.w.setDefaultButton(self.w.gobutton)
        self.w.open()
    def __init__(self):
        item_height = 24.0
        margin = 10
        next_y = margin
        w_width = 400.0
        w_height = item_height * 7 + margin
        col_1_width = w_width - (margin * 2)

        self.this_font = Glyphs.font
        try:
            self.other_font = [f for f in Glyphs.fonts
                               if f != self.this_font][0]
        except IndexError:
            Glyphs.showNotification('Copy kerning for Class from Other Font:',
                                    'There is only 1 file open!')
            raise

        self.other_fonts_classes = self.get_other_fonts_classes()
        self.w = Window((w_width, w_height),
                        "Copy kerning for Class from Other Font")

        self.w.text_1 = TextBox(
            (margin, next_y, w_width, item_height),
            "Copy the kerning for this class to this font:",
            sizeStyle='small')
        next_y += item_height
        self.w.class_to_copy = PopUpButton(
            (margin, next_y, w_width - (margin * 2), item_height),
            self.other_fonts_classes,
            sizeStyle='regular')
        next_y += item_height + item_height

        self.w.copy_for_all = RadioGroup(
            (margin, next_y, w_width, item_height * 2), [
                ' Copy only for the current Master',
                ' Copy for All masters',
            ])
        self.w.copy_for_all.set(0)
        next_y += (item_height * 2) + margin

        self.w.gobutton = Button(
            (margin + (col_1_width / 4), next_y, col_1_width / 2, item_height),
            'Copy',
            callback=self.makeitso)

        self.w.setDefaultButton(self.w.gobutton)
        self.w.center()
        self.w.open()
예제 #11
0
    def buildMenu(self):
        """Builds buttons at top.

        TODO: put in a group.
        """
        x = 4
        y = 4
        w = 100
        h = 24
        self.window.proof = Button((x, y, w, h), 'Proof',
                                sizeStyle='small', callback=self.proofCallback)
        x += 110

        self.window.selectFont = PopUpButton((x, y, w, h), self.FONTS,
            sizeStyle='small', callback=self.setFontCallback)

        x += 110
예제 #12
0
    def __init__(self):
        item_height = 24.0
        w_width = 300.0
        w_height = item_height * 8
        margin = 10
        next_y = margin
        col_1_width = w_width - (margin * 2)
        item_height = 24

        self.messages = []
        self.interpolated_fonts = dict()
        self.current_glyph = None

        self.all_kern_groups = self.get_all_kern_groups()
        self.w = Window((w_width, w_height), "Rename Kern Groups")

        self.w.text_1 = TextBox((margin, next_y, w_width, item_height),
                                "Rename:",
                                sizeStyle='small')
        next_y += item_height
        self.w.nameFind = PopUpButton(
            (margin, next_y, w_width - (margin * 2), item_height),
            self.all_kern_groups,
            sizeStyle='regular')
        next_y += item_height + item_height

        self.w.text_2 = TextBox((margin, next_y, w_width, item_height),
                                "To:",
                                sizeStyle='small')
        next_y += item_height
        self.w.nameReplace = EditText(
            (margin, next_y, w_width - (margin * 2), item_height),
            "",
            sizeStyle='regular')
        next_y += item_height + margin

        self.w.gobutton = Button(
            (margin + (col_1_width / 4), next_y, col_1_width / 2, item_height),
            'Rename',
            callback=self.makeitso)

        self.w.setDefaultButton(self.w.gobutton)
        self.w.center()
        self.w.open()
예제 #13
0
    def __init__(self):
        self.doMarkGlyphs = 0
        self.doOverwrite = 1
        self.sourceFontList = AllFonts()
        self.destinationFontList = AllFonts()
        self.source_font = self.sourceFontList[0]
        self.destination_fonts = None
        self.glyphs = None
        self.mark = NSColor.redColor()

        sl = []
        for f in self.sourceFontList:
            if f.info.familyName != None:
                fn = f.info.familyName
            else:
                fn = "None"
            if f.info.styleName != None:
                fs = f.info.styleName
            else:
                fs = "None"
            sl.append(fn+" "+fs)

        ## create a window
        self.w = Window((700, 500), "Copy Glyphs", minSize=(700, 500))
        self.w.sourceTitle = TextBox((15, 20, 200, 20), "Source Font:")
        self.w.sourceFont = PopUpButton((15, 42, -410, 20), sl, callback=self.sourceCallback)
        self.w.glyphs = GlyphCollectionView((16, 70, -410, -65), initialMode="list", enableDelete=False, allowDrag=False, selectionCallback=self.glyphCallback)
        self._sortGlyphs(self.source_font)
        self.w.desTitle = TextBox((-400, 20, 200, 20), "Destination Fonts:")
        self.w.destinationFonts = FontList((-400, 42, -15, -115), self.destinationFontList, selectionCallback=self.desCallback)
        self.w.overwrite = CheckBox((-395, -105, 130, 22), "Overwrite glyphs", callback=self.overwriteCallback, value=self.doOverwrite)
        self.w.markGlyphs = CheckBox((-395, -84, 100, 22), "Mark Glyphs", callback=self.markCallback, value=self.doMarkGlyphs)
        self.w.copyButton = Button((-115, -40, 100, 20), 'Copy Glyphs', callback=self.copyCallback)
        self.w.line = HorizontalLine((10, -50, -10, 1))
        self._checkSelection()
        self._updateDest()
        ## open the window
        self.w.open()
예제 #14
0
    def __init__(self):
        super(VFB2UFO, self).__init__()
        self.w = FloatingWindow((PLUGIN_WIDTH, 2), PLUGIN_TITLE)
        self.jumpingY = MARGIN_VER

        # options button
        self.w.optionsPopUp = PopUpButton(
            (MARGIN_HOR, self.jumpingY, NET_WIDTH,
             vanillaControlsSize['PopUpButtonRegularHeight']),
            self.inputOptions,
            callback=self.optionsPopUpCallback)
        self.jumpingY += vanillaControlsSize[
            'PopUpButtonRegularHeight'] + MARGIN_HOR

        # suffix option
        self.w.suffixRadio = RadioGroup(
            (MARGIN_HOR, self.jumpingY, NET_WIDTH,
             vanillaControlsSize['ButtonRegularHeight'] * 2),
            ["From VFB to UFO", "From UFO to VFB"],
            callback=self.suffixRadioCallback)
        self.w.suffixRadio.set(0)
        self.w.suffixRadio.enable(False)
        self.jumpingY += vanillaControlsSize[
            'ButtonRegularHeight'] * 2 + MARGIN_HOR

        # convert button
        self.w.convertButton = Button(
            (MARGIN_HOR, self.jumpingY, NET_WIDTH,
             vanillaControlsSize['ButtonRegularHeight']),
            'Choose file and convert',
            callback=self.convertButtonCallback)
        self.jumpingY += vanillaControlsSize['ButtonRegularHeight'] + MARGIN_HOR

        self.w.resize(PLUGIN_WIDTH, self.jumpingY)
        self.setUpBaseWindowBehavior()
        self.w.open()
예제 #15
0
    def glyphWindowDidOpenObserver(self, info):

        f = CurrentFont()
        self.clearGuides(f)

        if not self.bar:
            return

        if hasattr(self.bar, "menuButton"):
            del self.bar.menuButton

        menuItems = list(self.items.keys())
        menuItems.insert(0, self.title)
        self.bar.menuButton = PopUpButton((120, 0, self.width, 16),
                                          menuItems,
                                          sizeStyle="small",
                                          callback=self.callback)
        self.bar.menuButton.getNSPopUpButton().setPullsDown_(True)
        self.bar.menuButton.getNSPopUpButton().setBordered_(False)

        for i, menuItem in enumerate(
                self.bar.menuButton.getNSPopUpButton().itemArray()[1:]):
            value = list(self.items.values())[i - 1]
            menuItem.setState_(value)
예제 #16
0
class SharedCtrls(Group):
    def __init__(self, posSize, fontOptions, whichFont, actions, whichAction,
                 glyphLists, whichGlyphList, markColor, markEditedGlyphs,
                 callback):
        super(SharedCtrls, self).__init__(posSize)

        x, y, width, height = posSize
        self.fontOptions = fontOptions
        self.fontOptionsRepr = ['All Fonts', 'Current Font'] + [
            '{} {}'.format(ff.info.familyName, ff.info.styleName)
            for ff in self.fontOptions[2:]
        ]
        self.whichFont = whichFont
        self.actions = actions
        self.whichAction = whichAction
        self.glyphLists = glyphLists
        self.whichGlyphList = whichGlyphList
        self.markColor = markColor
        self.markEditedGlyphs = markEditedGlyphs
        self.callback = callback

        jumpinY = 0
        self.popFonts = PopUpButton(
            (1, jumpinY, width - 1,
             vanillaControlsSize['PopUpButtonRegularHeight']),
            self.fontOptionsRepr,
            callback=self.popFontsCallback)

        jumpinY += vanillaControlsSize['PopUpButtonRegularHeight'] + MARGIN_ROW
        self.popAction = PopUpButton(
            (1, jumpinY, width - 1,
             vanillaControlsSize['PopUpButtonRegularHeight']),
            self.actions,
            callback=self.popActionCallback)

        jumpinY += vanillaControlsSize['PopUpButtonRegularHeight'] + MARGIN_ROW
        self.popGlyphList = PopUpButton(
            (1, jumpinY, width - 1,
             vanillaControlsSize['PopUpButtonRegularHeight']),
            self.glyphLists[self.whichAction].keys(),
            callback=self.popGlyphListCallback)

        jumpinY += vanillaControlsSize[
            'PopUpButtonRegularHeight'] + MARGIN_ROW + 2
        self.checkMarkEditedColors = CheckBox(
            (0, jumpinY, width * .35,
             vanillaControlsSize['CheckBoxRegularHeight']),
            "Color",
            value=self.markEditedGlyphs,
            callback=self.checkMarkEditedColorsCallback)

        self.popColors = PopUpButton(
            (width * .4, jumpinY, width * .6,
             vanillaControlsSize['PopUpButtonRegularHeight']),
            glyphCollectionColors.keys(),
            callback=self.popColorsCallback)
        self.popColors.enable(self.markEditedGlyphs)

    # set public attrs
    def setFontOptions(self, fontOptions):
        originalIndex = self.fontOptions.index(self.whichFont)
        self.fontOptions = fontOptions
        self.fontOptionsRepr = ['All Fonts', 'Current Font'] + [
            '{} {}'.format(ff.info.familyName, ff.info.styleName)
            for ff in self.fontOptions[2:]
        ]
        self.popFonts.setItems(self.fontOptionsRepr)

        if self.whichFont not in self.fontOptions:
            self.whichFont = self.fontOptions[0]
            self.whichFontRepr = 'All Fonts'
            self.popFonts.set(0)
        else:
            self.popFonts.set(originalIndex)

    # public attrs
    def getWhichFont(self):
        return self.whichFont

    def getWhichAction(self):
        return self.whichAction

    def getWhichGlyphList(self):
        return self.whichGlyphList

    def getMarkEditedGlyphs(self):
        return self.markEditedGlyphs, self.markColor

    # callback
    def popFontsCallback(self, sender):
        self.whichFont = self.fontOptions[sender.get()]
        self.callback(self)

    def popActionCallback(self, sender):
        self.whichAction = self.actions[sender.get()]
        # update ctrls
        self.popGlyphList.setItems(self.glyphLists[self.whichAction].keys())

        # load first list of new section
        firstKey = self.glyphLists[self.whichAction].keys()[0]
        self.whichGlyphList = self.glyphLists[self.whichAction][firstKey]
        self.callback(self)

    def popGlyphListCallback(self, sender):
        rightKey = self.glyphLists[self.whichAction].keys()[sender.get()]
        self.whichGlyphList = self.glyphLists[self.whichAction][rightKey]
        self.callback(self)

    def checkMarkEditedColorsCallback(self, sender):
        self.markEditedGlyphs = bool(sender.get())
        self.popColors.enable(self.markEditedGlyphs)
        self.callback(self)

    def popColorsCallback(self, sender):
        self.markColor = glyphCollectionColors.values()[sender.get()]
        self.callback(self)
예제 #17
0
 def __init__(self):
     u"""
     Initialize the window and open it.
     """
     self.w = view = Window((AppC.WINDOW_WIDTH, AppC.WINDOW_HEIGHT),
                            "Xierpa 3",
                            closable=True,
                            minSize=(200, 200),
                            maxSize=(1600, 1000))
     siteLabels = self.getSiteLabels()
     #y = len(siteLabels)*20
     y = 10
     bo = 25  # Button offset
     view.optionalSites = PopUpButton((10, y, 150, 24),
                                      siteLabels,
                                      sizeStyle='small',
                                      callback=self.selectSiteCallback)
     #view.optionalSites = RadioGroup((10, 10, 150, y), siteLabels,
     #    callback=self.selectSiteCallback, sizeStyle='small')
     self.w.optionalSites.set(0)
     y = y + 32
     view.openSite = Button((10, y, 150, 20),
                            'Open site',
                            callback=self.openSiteCallback,
                            sizeStyle='small')
     y += bo
     self.w.saveSite = Button((10, y, 150, 20),
                              'Save HTML+CSS',
                              callback=self.saveSiteCallback,
                              sizeStyle='small')
     y += bo
     view.openCss = Button((10, y, 150, 20),
                           'Open CSS',
                           callback=self.openCssCallback,
                           sizeStyle='small')
     y += bo
     #view.openSass = Button((10, y, 150, 20), 'Open SASS', callback=self.openSassCallback, sizeStyle='small')
     #y += bo
     view.openDocumentation = Button(
         (10, y, 150, 20),
         'Documentation',
         callback=self.openDocumentationCallback,
         sizeStyle='small')
     y += bo
     view.openAsPhp = Button((10, y, 150, 20),
                             'Open as PHP',
                             callback=self.openAsPhpCallback,
                             sizeStyle='small')
     #view.makeSite = Button((10, y+95, 150, 20), 'Make site', callback=self.makeSiteCallback, sizeStyle='small')
     view.forceCss = CheckBox((180, 10, 150, 20),
                              'Force make CSS',
                              sizeStyle='small',
                              value=True)
     view.doIndent = CheckBox((180, 30, 150, 20),
                              'Build indents',
                              sizeStyle='small',
                              value=True)
     view.forceCopy = CheckBox((180, 50, 150, 20),
                               'Overwrite files',
                               sizeStyle='small',
                               value=True)
     view.isOnline = CheckBox((180, 70, 150, 20),
                              'Online',
                              sizeStyle='small',
                              value=True,
                              callback=self.isOnlineCallback)
     view.console = EditText((10, -200, -10, -10), sizeStyle='small')
     # Path defaults
     y = 20
     view.mampRootLabel = TextBox((300, y, 100, 20),
                                  'MAMP folder',
                                  sizeStyle='small')
     view.mampRoot = EditText((400, y, -10, 20),
                              self.C.PATH_MAMP,
                              sizeStyle='small')
     y += bo
     view.exampleRootLabel = TextBox((300, y, 100, 20),
                                     'Root folder',
                                     sizeStyle='small')
     view.exampleRoot = EditText((400, y, -10, 20),
                                 self.C.PATH_EXAMPLES,
                                 sizeStyle='small')
     # Scripting
     y += bo
     view.script = TextEditor((300, y, -10, -240))
     view.runScript = Button((500, -230, 150, -210),
                             'Run script',
                             callback=self.runScriptCallback,
                             sizeStyle='small')
     view.script.set(self.EXAMPLE_SCRIPT)
     view.open()
예제 #18
0
    def __init__(self, willOpen=True):
        super(SidebearingsLinker, self).__init__()

        # collecting fonts
        self.allFonts = AllFonts()
        if self.allFonts != []:
            self.selectedFont = self.allFonts[0]

        # interface
        self.w = FloatingWindow((PLUGIN_WIDTH, PLUGIN_HEIGHT), PLUGIN_TITLE)

        jumpingY = MARGIN_VER
        self.w.fontPopUp = PopUpButton(
            (MARGIN_HOR, jumpingY, NET_WIDTH,
             vanillaControlsSize['PopUpButtonRegularHeight']),
            getNamesFrom(self.allFonts),
            callback=self.fontPopUpCallback)

        jumpingY += vanillaControlsSize['PopUpButtonRegularHeight'] + MARGIN_ROW
        self.w.canvas = CanvasGroup(
            (MARGIN_HOR, jumpingY, NET_WIDTH, CANVAS_HEIGHT), delegate=self)

        jumpingY += CANVAS_HEIGHT + MARGIN_ROW
        linksColumnDescriptions = [{
            "title": "left",
            'key': 'lft',
            'width': LIST_WIDE_COL
        }, {
            "title": "active",
            "cell": CheckBoxListCell(),
            'key': 'lftActive',
            'width': LIST_NARROW_COL
        }, {
            "title": "glyph",
            'key': 'servant',
            'width': LIST_WIDE_COL,
            "editable": False
        }, {
            "title": "active",
            "cell": CheckBoxListCell(),
            'key': 'rgtActive',
            'width': LIST_NARROW_COL
        }, {
            "title": "right",
            'key': 'rgt',
            'width': LIST_WIDE_COL
        }]

        if self.selectedFont is not None:
            links = loadLinksFromFont(self.selectedFont)
        else:
            links = []

        self.w.linksList = List(
            (MARGIN_HOR, jumpingY, NET_WIDTH, 200),
            links,
            showColumnTitles=False,
            allowsMultipleSelection=False,
            drawVerticalLines=True,
            columnDescriptions=linksColumnDescriptions,
            selectionCallback=self.selectionLinksListCallback,
            editCallback=self.editLinksListCallback)

        if self.selectedFont is not None:
            self.w.linksList.setSelection([0])
            self.currentRow = self.w.linksList[0]
            self.matchDisplayedSubscriptions()

        jumpingY += self.w.linksList.getPosSize()[3] + MARGIN_ROW
        buttonWidth = (NET_WIDTH - MARGIN_HOR) / 2
        self.w.linkAllButton = SquareButton(
            (MARGIN_HOR, jumpingY, buttonWidth,
             vanillaControlsSize['ButtonRegularHeight'] * 1.5),
            'Link All',
            callback=self.linkAllButtonCallback)

        self.w.unlockAllButton = SquareButton(
            (MARGIN_HOR * 2 + buttonWidth, jumpingY, buttonWidth,
             vanillaControlsSize['ButtonRegularHeight'] * 1.5),
            'Unlink All',
            callback=self.unlockAllButtonCallback)

        jumpingY += vanillaControlsSize[
            'ButtonRegularHeight'] * 1.5 + MARGIN_ROW
        self.w.separationLineOne = HorizontalLine(
            (MARGIN_HOR, jumpingY, NET_WIDTH,
             vanillaControlsSize['HorizontalLineThickness']))

        jumpingY += MARGIN_ROW
        self.w.pushIntoFontButton = SquareButton(
            (MARGIN_HOR, jumpingY, buttonWidth,
             vanillaControlsSize['ButtonRegularHeight'] * 1.5),
            'Push into font',
            callback=self.pushIntoFontButtonCallback)
        self.w.pushIntoFontButton.enable(False)

        self.w.clearLibsButton = SquareButton(
            (MARGIN_HOR * 2 + buttonWidth, jumpingY, buttonWidth,
             vanillaControlsSize['ButtonRegularHeight'] * 1.5),
            'Clear Libs',
            callback=self.clearLibsButtonCallback)

        jumpingY += vanillaControlsSize[
            'ButtonRegularHeight'] * 1.5 + MARGIN_ROW
        self.w.loadFromTable = SquareButton(
            (MARGIN_HOR, jumpingY, buttonWidth,
             vanillaControlsSize['ButtonRegularHeight'] * 1.5),
            'Load from table',
            callback=self.loadFromTableCallback)
        self.w.loadFromTable.enable(True)

        self.w.exportTable = SquareButton(
            (MARGIN_HOR * 2 + buttonWidth, jumpingY, buttonWidth,
             vanillaControlsSize['ButtonRegularHeight'] * 1.5),
            'Export table',
            callback=self.exportTableCallback)
        self.w.exportTable.enable(True)

        jumpingY += vanillaControlsSize[
            'ButtonRegularHeight'] * 1.5 + MARGIN_VER * 2
        self.w.resize(PLUGIN_WIDTH, jumpingY)

        self.setUpBaseWindowBehavior()

        if self.selectedFont is not None:
            self.matchSubscriptions()
            result = askYesNo('Warning',
                              'Do you want to align servants to masters?')
            if bool(result) is True:
                self._alignServantsToMasters()

        addObserver(self, "drawOnGlyphCanvas", "draw")
        addObserver(self, "drawOnGlyphCanvas", "drawInactive")
        addObserver(self, 'fontDidOpenCallback', 'fontDidOpen')
        addObserver(self, 'fontDidCloseCallback', 'fontDidClose')
        if willOpen is True:
            self.w.open()
예제 #19
0
    def __init__(self):
        super(TestMetrics, self).__init__()

        # load data
        self.fontOptions = AllFonts()
        if self.fontOptions:
            self.chosenFont = self.fontOptions[0]

        # init win
        self.w = FloatingWindow((0, 0, PLUGIN_WIDTH, PLUGIN_HEIGHT),
                                "Metrics Tester")

        # target pop up
        jumpingY = MARGIN_TOP
        self.w.targetPopUp = PopUpButton(
            (MARGIN_LFT, jumpingY, NET_WIDTH,
             vanillaControlsSize['PopUpButtonRegularHeight']), [
                 '{} {}'.format(font.info.familyName, font.info.styleName)
                 for font in self.fontOptions
             ],
            callback=self.targetPopUpCallback)

        # test choice
        jumpingY += MARGIN_HALFROW + vanillaControlsSize[
            'PopUpButtonRegularHeight']
        self.w.testChoice = PopUpButton(
            (MARGIN_LFT, jumpingY, NET_WIDTH,
             vanillaControlsSize['PopUpButtonRegularHeight']),
            self.testOptions,
            callback=self.testChoiceCallback)

        # separation line
        jumpingY += vanillaControlsSize[
            'PopUpButtonRegularHeight'] + MARGIN_HALFROW
        # self.w.separationLine = HorizontalLine((MARGIN_LFT, jumpingY, NET_WIDTH, 1))

        # jumpingY += RADIO_GROUP_HEIGHT + MARGIN_ROW
        self.w.missingGlyphCheck = CheckBox(
            (MARGIN_LFT, jumpingY, NET_WIDTH,
             vanillaControlsSize['CheckBoxRegularHeight']),
            'Show missing glyphs',
            callback=self.missingGlyphCheckCallback)

        jumpingY += vanillaControlsSize['CheckBoxRegularHeight'] + MARGIN_ROW
        self.w.runButton = Button((MARGIN_LFT, jumpingY, NET_WIDTH,
                                   vanillaControlsSize['ButtonRegularHeight']),
                                  "Run Tests",
                                  callback=self.runButtonCallback)

        # adjust height
        jumpingY += vanillaControlsSize['ButtonRegularHeight'] + MARGIN_BTM
        self.w.setPosSize((0, 0, PLUGIN_WIDTH, jumpingY))

        # observers
        addObserver(self, "updateFontList", "fontWillClose")
        addObserver(self, "updateFontList", "fontDidOpen")
        addObserver(self, "updateFontList", "newFontDidOpen")
        self.setUpBaseWindowBehavior()

        # open win
        self.w.open()
예제 #20
0
class SingleNeighborController(Group):
    def __init__(self, posSize, title, isActive, openedFontPaths,
                 activeFontPath, activeGlyphName, callback):
        Group.__init__(self, posSize)
        self.isActive = isActive
        self.openedFontPaths = openedFontPaths
        self.activeFontPath = activeFontPath
        self.activeGlyphName = activeGlyphName
        self.callback = callback
        ctrlWidth = posSize[2]

        # ui
        jumpingY = 4
        self.isActiveCheck = CheckBox(
            (0, jumpingY, ctrlWidth,
             vanillaControlsSize['CheckBoxRegularHeight']),
            title,
            value=self.isActive,
            callback=self.isActiveCallback)

        jumpingY += vanillaControlsSize['CheckBoxRegularHeight'] + 2
        self.fontPop = PopUpButton(
            (1, jumpingY, ctrlWidth - 1,
             vanillaControlsSize['PopUpButtonRegularHeight']),
            makeFontList(openedFontPaths),
            callback=self.fontPopCallback)

        jumpingY += vanillaControlsSize['PopUpButtonRegularHeight'] + MARGIN_VER

        if self.activeFontPath == CURRENT_FONT_REPR:
            activeFont = CurrentFont()
        else:
            activeFont = getOpenedFontFromPath(AllFonts(), self.activeFontPath)
        self.glyphPop = PopUpButton(
            (1, jumpingY, ctrlWidth - 1,
             vanillaControlsSize['ComboBoxRegularHeight']),
            makeGlyphList(activeFont),
            callback=self.glyphPopCallback)

    def updateCurrentGlyph(self):
        pass
        # if self.glyphPop.get() == 0:
        #     glyphName = CurrentGlyphWindow().getGlyph().name
        #     if self.activeFont.has_key(glyphName):
        #         self.activeGlyph = self.activeFont[glyphName]
        #     else:
        #         self.activeGlyph = None
        #     self.callback(self)

    def get(self):
        return self.isActive, self.activeFontPath, self.activeGlyphName

    def setOpenedFonts(self, openedFontPaths):
        self.openedFontPaths = openedFontPaths
        if self.openedFontPaths:
            fontList = makeFontList(self.openedFontPaths)
            self.fontPop.setItems(fontList)
            self.fontPop.set(fontList.index(self.activeFontPath))
        else:
            self.fontPop.setItems([])

    def updateGlyphList(self):
        if self.activeFontPath == CURRENT_FONT_REPR:
            activeFont = CurrentFont()
        else:
            activeFont = getOpenedFontFromPath(AllFonts(), self.activeFontPath)
        activeGlyphOrder = makeGlyphList(activeFont)
        self.glyphPop.setItems(activeGlyphOrder)
        self.glyphPop.set(activeGlyphOrder.index(self.activeGlyphName))

    def isActiveCallback(self, sender):
        self.isActive = bool(sender.get())
        self.callback(self)

    def fontPopCallback(self, sender):
        if sender.get() > 1:
            self.activeFontPath = self.openedFontPaths[sender.get() - 2]
            activeFont = getOpenedFontFromPath(AllFonts(), self.activeFontPath)
        else:
            self.fontPop.set(0)
            self.activeFontPath = CURRENT_FONT_REPR
            activeFont = CurrentFont()

        activeGlyphOrder = makeGlyphList(activeFont)
        self.glyphPop.setItems(activeGlyphOrder)

        if not activeFont.has_key(self.activeGlyphName):
            self.activeGlyphName = activeGlyphOrder[0]

        self.glyphPop.set(activeGlyphOrder.index(self.activeGlyphName))
        self.callback(self)

    def glyphPopCallback(self, sender):
        if self.activeFontPath == CURRENT_FONT_REPR:
            activeFont = CurrentFont()
        else:
            activeFont = getOpenedFontFromPath(AllFonts(), self.activeFontPath)

        if sender.get() == 0:
            self.activeGlyphName = CurrentGlyph().name
        elif sender.get() == 1:
            self.activeGlyphName = None
        else:
            self.activeGlyphName = self.glyphPop.getItems()[sender.get()]

        self.callback(self)
예제 #21
0
    def __init__(self):
        self.all_layer_combos = self.get_all_layer_combos()
        self.instance_values = self.get_instance_values()
        item_height = 24.0
        w_width = 300.0
        w_height = item_height * 10
        margin = 10
        next_y = margin
        col_1_width = w_width - (margin * 2)
        col_2_width = (w_width / 2) - (margin * 1.5)
        item_height = 24

        radio_height = 20 * 2
        self.get_prefs('addBraceLayers.pref')

        self.w = Window((w_width, w_height), "Add Layers")

        self.w.text_1 = TextBox((margin, next_y, col_1_width, item_height),
                                "Layer Combinations:",
                                sizeStyle='regular')
        next_y += item_height
        self.w.parent_layers = PopUpButton(
            (margin, next_y, col_1_width, item_height),
            self.all_layer_combos,
            sizeStyle='regular')
        self.set_all_layer_combos()
        next_y += item_height + margin

        self.w.brace_or_bracket = RadioGroup(
            (margin, next_y, col_1_width, radio_height),
            ['Bracket Layer [X]', 'Brace Layer {X}'],
            sizeStyle='regular')
        self.w.brace_or_bracket.set(int(self.prefs.get('brace_or_bracket', 0)))
        next_y += radio_height + margin

        self.w.text_2 = TextBox((margin, next_y, col_1_width, item_height),
                                "Layer Value:",
                                sizeStyle='regular')
        next_y += item_height
        self.w.layer_value = EditText(
            (margin, next_y, col_2_width, item_height),
            '',
            sizeStyle='small',
            placeholder='e.g. 700')
        self.w.instance_value_popup = PopUpButton(
            (margin + margin + col_2_width, next_y, col_2_width, item_height),
            self.instance_values,
            sizeStyle='regular',
            callback=self.changeinstance_value)
        next_y += item_height + margin
        if self.prefs.get('layer_value') is not None:
            self.w.layer_value.set(self.prefs.get('layer_value'))

        self.w.gobutton = Button(
            (margin + (col_1_width / 4), next_y, col_1_width / 2, item_height),
            'Add Layers',
            callback=self.makeitso)

        self.w.setDefaultButton(self.w.gobutton)
        self.w.center()
        self.w.open()
예제 #22
0
class WordListController(Group):
    """this controller takes good care of word list flow"""

    def __init__(self, posSize, callback):
        super(WordListController, self).__init__(posSize)
        x, y, self.ctrlWidth, self.ctrlHeight = posSize
        self.callback = callback

        # handling kerning words
        self.kerningWordsDB = loadKerningTexts(STANDARD_KERNING_TEXT_FOLDER)
        self.kerningTextBaseNames = self.kerningWordsDB.keys()
        self.activeKerningTextBaseName = self.kerningTextBaseNames[0]
        # this is the list used for data manipulation
        self.wordsWorkingList = self.kerningWordsDB[self.activeKerningTextBaseName]
        # this list instead is used for data visualization in the ctrl
        self._makeWordsDisplayList(self.activeKerningTextBaseName)
        self.activeWord = self.wordsWorkingList[0]['word']
        self.wordFilter = ''

        jumping_Y = 0
        self.kerningVocabularyPopUp = PopUpButton((0, jumping_Y, self.ctrlWidth*.6, vanillaControlsSize['PopUpButtonRegularHeight']),
                                                  self.kerningTextBaseNames,
                                                  callback=self.kerningVocabularyPopUpCallback)

        self.openTextsFolderButton = SquareButton((self.ctrlWidth*.62, jumping_Y, self.ctrlWidth*.38, vanillaControlsSize['PopUpButtonRegularHeight']+1),
                                                  'Load texts...',
                                                  sizeStyle='small',
                                                  callback=self.openTextsFolderButtonCallback)

        wordsColumnDescriptors = [
            {'title': '#', 'width': 30, 'editable': False},
            {'title': 'word', 'width': self.ctrlWidth-80, 'editable': False},
            {'title': 'done?', 'width': 35, 'cell': CheckBoxListCell(), 'editable': False}]

        jumping_Y += self.openTextsFolderButton.getPosSize()[3] + MARGIN_VER
        self.wordsListCtrl = List((0, jumping_Y, self.ctrlWidth, 170),
                                  self.wordsDisplayList,
                                  enableDelete=False,
                                  allowsMultipleSelection=False,
                                  columnDescriptions=wordsColumnDescriptors,
                                  selectionCallback=self.wordsListCtrlSelectionCallback,
                                  doubleClickCallback=self.wordsListCtrlDoubleClickCallback)

        jumping_Y += self.wordsListCtrl.getPosSize()[3] + MARGIN_VER
        self.wordsFilterCtrl = EditText((-70, jumping_Y-1, 70, vanillaControlsSize['EditTextRegularHeight']),
                                        placeholder='filter...',
                                        callback=self.wordsFilterCtrlCallback)

        self.wordsDone = len([row['done?'] for row in self.wordsWorkingList if row['done?'] != 0])
        self.infoCaption = TextBox((0, jumping_Y+2, self.ctrlWidth-self.wordsFilterCtrl.getPosSize()[2], vanillaControlsSize['TextBoxRegularHeight']),
                                   'done: {:d}/{:d}'.format(self.wordsDone, len(self.wordsWorkingList)))

        jumping_Y += self.wordsFilterCtrl.getPosSize()[3] + MARGIN_VER
        self.loadStatus = SquareButton((0, jumping_Y, 90, vanillaControlsSize['ButtonRegularHeight']+2),
                                       'Load status',
                                       callback=self.loadStatusCallback)

        self.saveButton = SquareButton((-90, jumping_Y, 90, vanillaControlsSize['ButtonRegularHeight']+2),
                                       'Save status',
                                       callback=self.saveButtonCallback)

    def _filterDisplayList(self):
        self.wordsDisplayList = [row for row in self.wordsWorkingList if self.wordFilter in row['word']]

    def _makeWordsDisplayList(self, textBaseName):
        self.wordsDisplayList = []
        for eachRow in self.kerningWordsDB[self.activeKerningTextBaseName]:
            fixedWord = eachRow['word'].replace('//', '/')
            self.wordsDisplayList.append({'#': eachRow['#'], 'word': fixedWord, 'done?': eachRow['done?']})

    def _updateInfoCaption(self):
        self.infoCaption.set('done: {:d}/{:d}'.format(self.wordsDone, len(self.wordsWorkingList)))

    def get(self):
        return self.activeWord

    def getActiveIndex(self):
        activeWordData = [wordData for wordData in self.wordsDisplayList if wordData['word'] == self.activeWord][0]
        activeWordIndex = self.wordsDisplayList.index(activeWordData)
        return activeWordIndex

    def nextWord(self):
        activeWordData = [wordData for wordData in self.wordsDisplayList if wordData['word'] == self.activeWord][0]
        activeWordIndex = self.wordsDisplayList.index(activeWordData)
        nextWordIndex = (activeWordIndex+1)%len(self.wordsDisplayList)
        self.activeWord = self.wordsDisplayList[nextWordIndex]['word']
        self.wordsListCtrl.setSelection([nextWordIndex])

    def previousWord(self):
        activeWordData = [wordData for wordData in self.wordsDisplayList if wordData['word'] == self.activeWord][0]
        activeWordIndex = self.wordsDisplayList.index(activeWordData)
        previousWordIndex = (activeWordIndex-1)%len(self.wordsDisplayList)
        self.activeWord = self.wordsDisplayList[previousWordIndex]['word']
        self.wordsListCtrl.setSelection([previousWordIndex])

    def jumpToLine(self, lineIndex):
        try:
            self.activeWord = self.wordsDisplayList[lineIndex]['word']
            self.wordsListCtrl.setSelection([lineIndex])
        except IndexError:
            pass

    def switchActiveWordSolvedAttribute(self):
        activeWordData = [wordData for wordData in self.wordsDisplayList if wordData['word'] == self.activeWord][0]
        activeWordIndex = self.wordsDisplayList.index(activeWordData)
        if activeWordData['done?'] == 0:
            self.wordsDisplayList[activeWordIndex]['done?'] = 1
        else:
            self.wordsDisplayList[activeWordIndex]['done?'] = 0
        self.wordsListCtrl.set(self.wordsDisplayList)
        self.wordsListCtrl.setSelection([activeWordIndex])

    # ctrls callbacks
    def kerningVocabularyPopUpCallback(self, sender):
        self.activeKerningTextBaseName = self.kerningTextBaseNames[sender.get()]
        self.wordsWorkingList = self.kerningWordsDB[self.activeKerningTextBaseName]
        self.activeWord = self.wordsWorkingList[0]['word']
        self._makeWordsDisplayList(self.activeKerningTextBaseName)
        self._filterDisplayList()
        self.wordsListCtrl.set(self.wordsDisplayList)
        self.callback(self)

    def openTextsFolderButtonCallback(self, sender):
        textFolder = u'{}'.format(getFolder('Choose a folder for texts files')[0])
        # handling kerning words
        self.kerningWordsDB = loadKerningTexts(textFolder)
        self.kerningTextBaseNames = self.kerningWordsDB.keys()
        self.activeKerningTextBaseName = self.kerningTextBaseNames[0]
        # this is the list used for data manipulation
        self.wordsWorkingList = self.kerningWordsDB[self.activeKerningTextBaseName]
        # this list instead is used for data visualization in the ctrl
        self._makeWordsDisplayList(self.activeKerningTextBaseName)
        self.activeWord = self.wordsWorkingList[0]['word']
        self.wordFilter = ''
        self._filterDisplayList()
        self._updateInfoCaption()
        # ctrls to be updated
        self.kerningVocabularyPopUp.setItems(self.kerningTextBaseNames)
        self.wordsListCtrl.set(self.wordsDisplayList)
        self.wordsFilterCtrl.set(self.wordFilter)
        self.callback(self)

    def wordsListCtrlSelectionCallback(self, sender):
        """this takes care of word count"""
        self.wordsDisplayList = [{'#': row['#'], 'word': row['word'], 'done?': row['done?']} for row in sender.get()]
        for eachDisplayedRow in self.wordsDisplayList:
            for indexWorkingRow, eachWorkingRow in enumerate(self.wordsWorkingList):
                if eachWorkingRow['word'] == eachDisplayedRow['word']:
                    self.wordsWorkingList[indexWorkingRow] = eachDisplayedRow
        self.wordsDone = len([row['done?'] for row in self.wordsWorkingList if row['done?'] != 0])
        self._updateInfoCaption()

    def wordsListCtrlDoubleClickCallback(self, sender):
        self.activeWord = self.wordsDisplayList[sender.getSelection()[0]]['word']
        self.callback(self)


    def wordsFilterCtrlCallback(self, sender):
        self.wordFilter = sender.get()
        self._filterDisplayList()
        self.wordsListCtrl.set(self.wordsDisplayList)
        if len(self.wordsDisplayList) == 0:
            self.activeWord = None
        else:
            if self.activeWord not in [row['word'] for row in self.wordsDisplayList]:
                self.activeWord = self.wordsDisplayList[0]['word']
        self.callback(self)

    def loadStatusCallback(self, sender):
        kerningStatusPath = getFile(title='Load Kerning Status JSON file',
                                    allowsMultipleSelection=False)[0]

        if os.path.splitext(os.path.basename(kerningStatusPath))[1] == '.json':
            jsonFile = open(kerningStatusPath, 'r')
            statusDictionary = json.load(jsonFile)
            jsonFile.close()

            # unwrap dictionaries
            self.kerningWordsDB = statusDictionary['kerningWordsDB']
            self.kerningTextBaseNames = statusDictionary['kerningTextBaseNames']
            self.activeKerningTextBaseName = statusDictionary['activeKerningTextBaseName']
            self.wordsWorkingList = statusDictionary['wordsWorkingList']
            self.wordsDisplayList = statusDictionary['wordsDisplayList']
            self.activeWord = statusDictionary['activeWord']
            self.wordFilter = statusDictionary['wordFilter']

            # adjust controllers
            self.kerningVocabularyPopUp.setItems(self.kerningTextBaseNames)
            self.kerningVocabularyPopUp.set(self.kerningTextBaseNames.index(self.activeKerningTextBaseName))
            self.wordsListCtrl.set(self.wordsDisplayList)

            for indexRow, eachRow in enumerate(self.wordsDisplayList):
                if eachRow['word'] == self.activeWord:
                    self.wordsListCtrl.setSelection([indexRow])
                    break

            self._updateInfoCaption()
            self.callback(self)

        else:
            message('No JSON, no party!', 'Chosen file is not in the right format')

    def saveButtonCallback(self, sender):
        statusDict = {
            'kerningWordsDB': self.kerningWordsDB,
            'kerningTextBaseNames': self.kerningTextBaseNames,
            'activeKerningTextBaseName': self.activeKerningTextBaseName,
            'wordsWorkingList': self.wordsWorkingList,
            'wordsDisplayList': self.wordsDisplayList,
            'activeWord': self.activeWord,
            'wordFilter': self.wordFilter}

        kerningStatusPath = putFile(title='Save Kerning Status JSON file',
                                    fileName='kerningStatus.json',
                                    canCreateDirectories=True)

        jsonFile = open(kerningStatusPath, 'w')
        json.dump(statusDict, jsonFile, indent=4)
        jsonFile.write('\n')
        jsonFile.close()
예제 #23
0
파일: main.py 프로젝트: sycomix/unicron
    def __init__(self):
        self.locations = [
            'User Agents', 'Global Agents', 'Global Daemons', 'System Agents',
            'System Daemons'
        ]
        self.listItems = []
        self.selected = {}

        # Preferences
        self.homedir = os.path.expanduser('~')
        self.prefsFolder = self.homedir + "/Library/Preferences/"
        self.prefsFile = "de.nelsonfritsch.unicron.plist"

        if os.path.isfile(self.prefsFolder + self.prefsFile):
            self.prefs = self._loadPrefs(self)
        else:
            self.prefs = dict(showSystemWarning=True, windowStyle='System')
            self._savePrefs(self)

        # Preferences Window
        self.prefsWindow = Window((300, 105), 'Preferences')

        self.styles = ['System', 'Light', 'Dark']
        self.prefsWindow.styleTxt = TextBox((10, 10, -10, 20), "Window Style:")
        self.prefsWindow.style = PopUpButton((30, 35, -10, 20),
                                             self.styles,
                                             callback=self.prefsSetStyle)

        self.prefsWindow.restore = Button((10, 75, -10, 20),
                                          'Restore Warnings',
                                          callback=self.prefsRestoreWarnings)

        # Main Window
        minsize = 285
        self.w = Window((minsize, 400),
                        'Unicron',
                        closable=True,
                        fullSizeContentView=True,
                        titleVisible=False,
                        minSize=(minsize, minsize),
                        maxSize=(600, 1200),
                        autosaveName="UnicronMainWindow")

        self.pathList = NSPopUpButton.alloc().initWithFrame_(
            ((0, 0), (160, 20)))
        self.pathList.addItemsWithTitles_(self.locations)

        refreshIcon = NSImage.alloc().initWithSize_((32, 32))
        sourceImage = NSImage.imageNamed_(NSImageNameRefreshTemplate)

        w, h = sourceImage.size()

        if w > h:
            diffx = 0
            diffy = w - h
        else:
            diffx = h - w
            diffy = 0

        maxSize = max([w, h])
        refreshIcon.lockFocus()
        sourceImage.drawInRect_fromRect_operation_fraction_(
            NSMakeRect(diffx, diffy + 4, 22, 22),
            NSMakeRect(0, 0, maxSize, maxSize), NSCompositeSourceOver, 1)
        refreshIcon.unlockFocus()
        refreshIcon.setTemplate_(True)

        toolbarItems = [
            dict(itemIdentifier="Daemons",
                 label="Daemons",
                 toolTip="Daemon Group",
                 view=self.pathList,
                 callback=self.populateList),
            dict(itemIdentifier="image",
                 label="Image",
                 imageObject=refreshIcon,
                 callback=self.populateList),
        ]
        self.w.addToolbar("Unicron Toolbar",
                          toolbarItems=toolbarItems,
                          displayMode="icon")

        self.w.blend = Group((0, 0, 0, 0), blendingMode='behindWindow')

        self.listColumnDescriptions = [{
            'title': '',
            'key': 'image',
            'width': 25,
            'typingSensitive': True,
            'allowsSorting': True,
            'cell': ImageListCell()
        }, {
            'title': 'Name',
            'key': 'name',
            'typingSensitive': True,
            'allowsSorting': True,
        }]
        self.rowHeight = 20
        self.w.list = List((0, 37, -0, 0),
                           items=self.listItems,
                           columnDescriptions=self.listColumnDescriptions,
                           showColumnTitles=True,
                           allowsEmptySelection=True,
                           allowsMultipleSelection=False,
                           autohidesScrollers=True,
                           drawFocusRing=False,
                           rowHeight=self.rowHeight,
                           selectionCallback=self._selectionCallback,
                           menuCallback=self._menuCallback)

        self.w.list._nsObject.setBorderType_(NSNoBorder)

        self.w.statusbar = Group((0, -26, 0, 0), blendingMode='behindWindow')
        self.w.statusbar.border = HorizontalLine((0, 0, 0, 1))

        self.w.counter = TextBox((16, -20, -16, 15),
                                 '',
                                 alignment='center',
                                 sizeStyle='small')
        self.populateList(self)
        self.w.rowIndicator = Group((0, 0, 0, 10))

        self.prefsSetStyle(self)

        self.w.open()
예제 #24
0
    def __init__(self):
        flushAlign = 76
        firstRowY = 12
        rowOffsetY = 30
        firstCheckY = 135
        checkOffsetY = 27
        rightMarginX = -12
        self.windowWidth = 410
        self.windowHeightWithoutOptions = 45
        self.windowHeightWithOptions = 280
        self.scriptIsRTL = False

        windowPos = getExtensionDefault("%s.%s" % (extensionKey, "windowPos"))
        if not windowPos:
            windowPos = (100, 100)

        self.optionsVisible = getExtensionDefault(
            "%s.%s" % (extensionKey, "optionsVisible"))
        if self.optionsVisible:
            optionsButtonSign = '-'
            windowHeight = self.windowHeightWithOptions
        else:
            self.optionsVisible = False  # needs to be set because the first time the extension runs self.optionsVisible will be None
            optionsButtonSign = '+'
            windowHeight = self.windowHeightWithoutOptions

        self.chars = getExtensionDefault("%s.%s" % (extensionKey, "chars"))
        if not self.chars:
            self.chars = ''

        self.sliderValue = getExtensionDefault("%s.%s" %
                                               (extensionKey, "sliderValue"))
        if not self.sliderValue:
            self.sliderValue = 25

        self.scriptsIndex = getExtensionDefault("%s.%s" %
                                                (extensionKey, "scriptsIndex"))
        if not self.scriptsIndex:
            self.scriptsIndex = 0

        self.langsIndex = getExtensionDefault("%s.%s" %
                                              (extensionKey, "langsIndex"))
        if not self.langsIndex:
            self.langsIndex = 0

        self.w = FloatingWindow(
            (windowPos[0], windowPos[1], self.windowWidth, windowHeight),
            "adhesiontext")

        # 1st row
        self.w.labelChars = TextBox((10, firstRowY, flushAlign, 20),
                                    "Characters:",
                                    alignment="right")
        self.w.chars = EditText((flushAlign + 15, firstRowY - 1, 199, 22),
                                self.chars,
                                callback=self.charsCallback)
        self.w.button = Button((300, firstRowY, 68, 20),
                               "Get text",
                               callback=self.buttonCallback)
        self.w.spinner = FixedSpinner((325, firstRowY, 20, 20),
                                      displayWhenStopped=False)
        self.w.optionsButton = SquareButton((378, firstRowY + 1, 18, 18),
                                            optionsButtonSign,
                                            sizeStyle="small",
                                            callback=self.optionsCallback)
        # set the initial state of the button according to the content of the chars EditText
        if len(self.w.chars.get()): self.w.button.enable(True)
        else: self.w.button.enable(False)
        # keep track of the content of chars EditText
        self.previousChars = self.w.chars.get()

        # 2nd row
        self.w.labelWords = TextBox(
            (10, firstRowY + rowOffsetY, flushAlign, 20),
            "Words:",
            alignment="right")
        self.w.wordCount = TextBox(
            (flushAlign + 12, firstRowY + rowOffsetY, 40, 20),
            alignment="left")
        self.w.slider = Slider(
            (flushAlign + 47, firstRowY + rowOffsetY + 1, 165, 20),
            value=self.sliderValue,
            minValue=5,
            maxValue=200,
            callback=self.sliderCallback)
        # set the initial wordCount value according to the position of the slider
        self.w.wordCount.set(int(self.w.slider.get()))

        # 3rd row
        self.w.labelScripts = TextBox(
            (10, firstRowY + rowOffsetY * 2, flushAlign, 20),
            "Script:",
            alignment="right")
        self.w.scriptsPopup = PopUpButton(
            (flushAlign + 15, firstRowY + rowOffsetY * 2, 150, 20),
            scriptsNameList,
            callback=self.scriptsCallback)
        self.w.scriptsPopup.set(self.scriptsIndex)

        # 4th row
        self.w.labelLangs = TextBox(
            (10, firstRowY + rowOffsetY * 3, flushAlign, 20),
            "Language:",
            alignment="right")
        self.w.langsPopup = PopUpButton(
            (flushAlign + 15, firstRowY + rowOffsetY * 3, 150, 20), [])
        # set the initial list of languages according to the script value
        self.w.langsPopup.setItems(
            langsNameDict[scriptsNameList[self.w.scriptsPopup.get()]])
        self.w.langsPopup.set(self.langsIndex)

        self.punctCheck = getExtensionDefault("%s.%s" %
                                              (extensionKey, "punctCheck"))
        if not self.punctCheck:
            self.punctCheck = 0

        self.figsCheck = getExtensionDefault("%s.%s" %
                                             (extensionKey, "figsCheck"))
        if not self.figsCheck:
            self.figsCheck = 0

        self.figsPopup = getExtensionDefault("%s.%s" %
                                             (extensionKey, "figsPopup"))
        if not self.figsPopup:
            self.figsPopup = 0

        self.trimCheck = getExtensionDefault("%s.%s" %
                                             (extensionKey, "trimCheck"))
        if not self.trimCheck:
            self.trimCheck = 0

        self.caseCheck = getExtensionDefault("%s.%s" %
                                             (extensionKey, "caseCheck"))
        if not self.caseCheck:
            self.caseCheck = 0

        self.casingCheck = getExtensionDefault("%s.%s" %
                                               (extensionKey, "casingCheck"))
        if not self.casingCheck:
            self.casingCheck = 0

        self.casingPopup = getExtensionDefault("%s.%s" %
                                               (extensionKey, "casingPopup"))
        if not self.casingPopup:
            self.casingPopup = 0

        # 1st checkbox
        self.w.punctCheck = CheckBox((flushAlign + 15, firstCheckY, 130, 20),
                                     "Add punctuation")
        self.w.punctCheck.set(self.punctCheck)

        # 2nd checkbox
        self.w.figsCheck = CheckBox(
            (flushAlign + 15, firstCheckY + checkOffsetY, 120, 20),
            "Insert numbers",
            callback=self.figsCallback)
        self.w.figsCheck.set(self.figsCheck)
        self.w.figsPopup = PopUpButton(
            (210, firstCheckY + checkOffsetY, 90, 20), figOptionsList)
        self.w.figsPopup.set(self.figsPopup)
        # enable or disable the figure options PopUp depending on the figures CheckBox
        if scriptsNameList[self.w.scriptsPopup.get()] in enableFigOptionList:
            self.w.figsPopup.show(True)
            if self.w.figsCheck.get():
                self.w.figsPopup.enable(True)
            else:
                self.w.figsPopup.enable(False)
        else:
            self.w.figsPopup.show(False)

        # 3rd checkbox
        self.w.trimCheck = CheckBoxPlus(
            (flushAlign + 15, firstCheckY + checkOffsetY * 2, 120, 20),
            "Trim accents")
        self.w.trimCheck.set(self.trimCheck)
        if scriptsNameList[self.w.scriptsPopup.get()] in enableTrimCheckList:
            self.w.trimCheck.enable(True)
        else:
            self.w.trimCheck.enable(False)

        # 4th checkbox
        self.w.caseCheck = CheckBoxPlus(
            (flushAlign + 15, firstCheckY + checkOffsetY * 3, 120, 20),
            "Ignore casing")
        self.w.caseCheck.set(self.caseCheck)
        if scriptsNameList[self.w.scriptsPopup.get()] in enableCaseCheckList:
            self.w.caseCheck.enable(True)
        else:
            self.w.caseCheck.enable(False)

        # 5th checkbox
        self.w.casingCheck = CheckBoxPlus(
            (flushAlign + 15, firstCheckY + checkOffsetY * 4, 115, 20),
            "Change casing",
            callback=self.casingCallback)
        self.w.casingCheck.set(self.casingCheck)
        if scriptsNameList[self.w.scriptsPopup.get()] in enableCaseCheckList:
            self.w.casingCheck.enable(True)
        else:
            self.w.casingCheck.enable(False)
        self.w.casingPopup = PopUpButton(
            (210, firstCheckY + checkOffsetY * 4, 90, 20), casingNameList)
        self.w.casingPopup.set(self.casingPopup)
        # enable or disable the casing PopUp depending on the casing CheckBox
        if self.w.casingCheck.get() and self.w.casingCheck.isEnable():
            self.w.casingPopup.enable(True)
        else:
            self.w.casingPopup.enable(False)

        self.nsTextField = self.w.chars.getNSTextField()
        self.w.setDefaultButton(self.w.button)
        self.w.bind("close", self.windowClose)
        self.w.open()
        self.w.makeKey()
예제 #25
0
    def __init__(self):
        super(CornersRounder, self).__init__()

        self._initLogger()
        self.rounderLogger.info('we are on air! start: __init__()')

        self._updateFontsAttributes()
        if self.allFonts != []:
            self.selectedFont = self.allFonts[0]

        self._initRoundingsData()
        if self.selectedFont is not None:
            self.layerNames = ['foreground'] + self.selectedFont.layerOrder
            self.sourceLayerName = self.layerNames[0]
            self.targetLayerName = self.layerNames[0]

            if PLUGIN_LIB_NAME in self.selectedFont.lib:
                self.roundingsData = pullRoundingsDataFromFont(
                    self.selectedFont)

        self.w = Window((0, 0, PLUGIN_WIDTH, PLUGIN_HEIGHT), PLUGIN_TITLE)

        jumpingY = MARGIN_VER
        self.w.fontPopUp = PopUpButton(
            (MARGIN_HOR, jumpingY, NET_WIDTH,
             vanillaControlsSize['PopUpButtonRegularHeight']),
            [os.path.basename(item.path) for item in self.allFonts],
            callback=self.fontPopUpCallback)

        jumpingY += vanillaControlsSize['PopUpButtonRegularHeight'] + MARGIN_VER
        self.w.sepLineOne = HorizontalLine(
            (MARGIN_HOR, jumpingY, NET_WIDTH,
             vanillaControlsSize['HorizontalLineThickness']))

        jumpingY += MARGIN_VER
        for eachI in range(LABELS_AMOUNT):
            singleLabel = Label((MARGIN_HOR, jumpingY, NET_WIDTH,
                                 vanillaControlsSize['EditTextRegularHeight']),
                                attachCallback=self.attachCallback,
                                labelName='')

            setattr(self.w, 'label{:d}'.format(eachI), singleLabel)
            jumpingY += MARGIN_ROW + vanillaControlsSize[
                'EditTextRegularHeight']
        self._fromRoundingsData2LabelCtrls()

        jumpingY += MARGIN_ROW
        self.w.sepLineTwo = HorizontalLine(
            (MARGIN_HOR, jumpingY, NET_WIDTH,
             vanillaControlsSize['HorizontalLineThickness']))
        jumpingY += MARGIN_ROW * 2

        # tables
        labelListWdt = 78
        marginTable = 1
        angleListWdt = (NET_WIDTH - labelListWdt - marginTable * 3) // 3
        tableLineHeight = 16
        tableHgt = LABELS_AMOUNT * tableLineHeight + 33

        captionY = jumpingY
        captionOffset = 12
        jumpingY += vanillaControlsSize['TextBoxSmallHeight'] + MARGIN_ROW

        labelColumnDesc = [{"title": "labelName", 'editable': True}]
        jumpingX = MARGIN_HOR

        self.w.labelNameList = List(
            (jumpingX, jumpingY, labelListWdt, tableHgt), [],
            columnDescriptions=labelColumnDesc,
            showColumnTitles=True,
            editCallback=self.labelNameListCallback,
            rowHeight=tableLineHeight,
            drawHorizontalLines=True,
            drawVerticalLines=True,
            autohidesScrollers=True,
            allowsMultipleSelection=False)

        anglesColumnDesc = [{
            "title": "rad",
            'editable': True
        }, {
            "title": "bcp",
            'editable': True
        }]

        jumpingX += labelListWdt + marginTable
        self.w.fortyFiveCaption = TextBox(
            (jumpingX + captionOffset, captionY, angleListWdt,
             vanillaControlsSize['TextBoxSmallHeight']),
            u'45°',
            sizeStyle='small')

        self.w.fortyFiveList = List(
            (jumpingX, jumpingY, angleListWdt, tableHgt), [],
            columnDescriptions=anglesColumnDesc,
            showColumnTitles=True,
            rowHeight=tableLineHeight,
            editCallback=self.fortyFiveListCallback,
            drawHorizontalLines=True,
            drawVerticalLines=True,
            autohidesScrollers=True,
            allowsMultipleSelection=False)

        jumpingX += angleListWdt + marginTable
        self.w.ninetyCaption = TextBox(
            (jumpingX + captionOffset, captionY, angleListWdt,
             vanillaControlsSize['TextBoxSmallHeight']),
            u'90°',
            sizeStyle='small')

        self.w.ninetyList = List((jumpingX, jumpingY, angleListWdt, tableHgt),
                                 [],
                                 columnDescriptions=anglesColumnDesc,
                                 showColumnTitles=True,
                                 rowHeight=tableLineHeight,
                                 editCallback=self.ninetyListCallback,
                                 drawHorizontalLines=True,
                                 drawVerticalLines=True,
                                 autohidesScrollers=True,
                                 allowsMultipleSelection=False)

        jumpingX += angleListWdt + marginTable
        self.w.hundredThirtyFiveCaption = TextBox(
            (jumpingX + captionOffset, captionY, angleListWdt,
             vanillaControlsSize['TextBoxSmallHeight']),
            u'135°',
            sizeStyle='small')

        self.w.hundredThirtyFiveList = List(
            (jumpingX, jumpingY, angleListWdt, tableHgt), [],
            columnDescriptions=anglesColumnDesc,
            showColumnTitles=True,
            rowHeight=tableLineHeight,
            editCallback=self.hundredThirtyFiveListCallback,
            drawHorizontalLines=True,
            drawVerticalLines=True,
            autohidesScrollers=True,
            allowsMultipleSelection=False)
        self._fromRoundingsData2Lists()
        jumpingY += tableHgt + MARGIN_ROW * 2

        rgtX = MARGIN_HOR + NET_WIDTH * .52
        midWdt = NET_WIDTH * .48
        self.w.pushButton = SquareButton(
            (MARGIN_HOR, jumpingY, midWdt,
             vanillaControlsSize['ButtonRegularHeight'] * 1.5),
            'Push Data',
            callback=self.pushButtonCallback)
        self.w.clearLibButton = SquareButton(
            (rgtX, jumpingY, midWdt,
             vanillaControlsSize['ButtonRegularHeight'] * 1.5),
            'Clear Lib',
            callback=self.clearLibButtonCallback)

        jumpingY += vanillaControlsSize[
            'ButtonRegularHeight'] * 1.5 + MARGIN_ROW * 2
        self.w.sepLineThree = HorizontalLine(
            (MARGIN_HOR, jumpingY, NET_WIDTH,
             vanillaControlsSize['HorizontalLineThickness']))
        jumpingY += MARGIN_ROW * 2

        self.w.sourceLayerCaption = TextBox(
            (MARGIN_HOR, jumpingY, midWdt,
             vanillaControlsSize['TextBoxRegularHeight']), 'source layer')
        self.w.targetLayerCaption = TextBox(
            (rgtX, jumpingY, midWdt,
             vanillaControlsSize['TextBoxRegularHeight']), 'target layer')

        jumpingY += vanillaControlsSize['TextBoxRegularHeight'] + MARGIN_ROW
        self.w.sourceLayerPopUp = PopUpButton(
            (MARGIN_HOR, jumpingY, midWdt,
             vanillaControlsSize['PopUpButtonRegularHeight']),
            self.layerNames,
            callback=self.sourceLayerPopUpCallback)
        if self.layerNames and self.sourceLayerName:
            self.w.sourceLayerPopUp.set(
                self.layerNames.index(self.sourceLayerName))

        self.w.targetLayerCombo = ComboBox(
            (rgtX, jumpingY, midWdt,
             vanillaControlsSize['PopUpButtonRegularHeight']),
            self.layerNames,
            callback=self.targetLayerComboCallback)
        if self.layerNames and self.targetLayerName:
            self.w.targetLayerCombo.set(self.targetLayerName)

        jumpingY += vanillaControlsSize[
            'PopUpButtonRegularHeight'] + MARGIN_ROW * 4
        self.w.roundGlyphButton = SquareButton(
            (MARGIN_HOR, jumpingY, midWdt,
             vanillaControlsSize['ButtonRegularHeight'] * 1.5),
            u'Round Glyph (⌘+R)',
            callback=self.roundGlyphButtonCallback)
        self.w.roundGlyphButton.bind('r', ['command'])

        self.w.roundFontButton = SquareButton(
            (rgtX, jumpingY, midWdt,
             vanillaControlsSize['ButtonRegularHeight'] * 1.5),
            'Round Font',
            callback=self.roundFontButtonCallback)
        jumpingY += vanillaControlsSize[
            'ButtonRegularHeight'] * 1.5 + MARGIN_VER * 2

        self.w.resize(PLUGIN_WIDTH, jumpingY)

        self._checkPushButton()
        self._checkRoundButtons()
        self.setUpBaseWindowBehavior()
        addObserver(self, 'fontDidOpenCallback', 'fontDidOpen')
        addObserver(self, 'fontDidCloseCallback', 'fontDidClose')
        addObserver(self, '_keyDown', 'keyDown')
        self.w.open()
예제 #26
0
    def __init__(self):
        super(MultiFontMetricsWindow, self).__init__()

        # ui vars
        originLeft = 0
        originRight = 0
        width = 956
        height = 640

        netWidth = width - MARGIN_LFT - MARGIN_RGT
        jumpingY = MARGIN_TOP

        # let's see if there are opened fonts (fontDB, ctrlFontsList, fontsOrder)
        self.loadFontsOrder()
        self.updateUnicodeMinimum()

        # defining plugin windows
        self.w = Window((originLeft, originRight, width, height),
                        "Multi Font Metrics Window",
                        minSize=(800, 400))
        self.w.bind('resize', self.mainWindowResize)

        switchButtonWdt = 140
        self.w.switchButton = PopUpButton(
            (MARGIN_LFT, jumpingY, switchButtonWdt,
             vanillaControlsSize['PopUpButtonRegularHeight']),
            self.textModeOptions,
            sizeStyle='regular',
            callback=self.switchButtonCallback)

        # free text
        textCtrlX = MARGIN_LFT + MARGIN_COL + switchButtonWdt
        self.w.typewriterCtrl = Typewriter(
            (textCtrlX, jumpingY, -(RIGHT_COLUMN + MARGIN_COL + MARGIN_RGT),
             vanillaControlsSize['EditTextRegularHeight']),
            self.unicodeMinimum,
            callback=self.typewriterCtrlCallback)
        self.w.typewriterCtrl.show(False)

        # strings ctrls
        self.w.textStringsControls = TextStringsControls(
            (textCtrlX, jumpingY, -(RIGHT_COLUMN + MARGIN_COL + MARGIN_RGT),
             vanillaControlsSize['PopUpButtonRegularHeight'] + 1),
            self.unicodeMinimum,
            callback=self.textStringsControlsCallback)
        self.stringDisplayMode, self.glyphNamesToDisplay = self.w.textStringsControls.get(
        )

        # multi line
        jumpingY += vanillaControlsSize['ButtonRegularHeight'] + MARGIN_ROW

        self.calcSpacingMatrixHeight()
        self.multiLineOptions = {
            'Show Kerning': self.applyKerning,
            'Center': False,
            'Show Space Matrix': False,
            'Single Line': False,
            'displayMode': u'Multi Line',
            'Stroke': False,
            'xHeight Cut': False,
            'Upside Down': False,
            'Beam': False,
            'Water Fall': False,
            'Inverse': False,
            'Show Template Glyphs': True,
            'Multi Line': True,
            'Right to Left': False,
            'Show Metrics': self.showMetrics,
            'Show Control glyphs': True,
            'Fill': True,
            'Left to Right': self.leftToRight
        }
        self.w.lineView = MultiLineView(
            (MARGIN_LFT, jumpingY, -(RIGHT_COLUMN + MARGIN_COL + MARGIN_RGT),
             -MARGIN_BTM - MARGIN_HALFROW - self.spacingMatrixHeight),
            pointSize=self.bodySize,
            lineHeight=self.lineHeight,
            doubleClickCallback=self.lineViewDoubleClickCallback,
            selectionCallback=self.lineViewSelectionCallback,
            bordered=True,
            applyKerning=self.applyKerning,
            hasHorizontalScroller=False,
            hasVerticalScroller=True,
            displayOptions=self.multiLineOptions,
            updateUserDefaults=False,
            menuForEventCallback=None)

        # static options
        # body
        self.w.bodyCtrl = ComboBoxWithCaption(
            (-(RIGHT_COLUMN + MARGIN_RGT), jumpingY, RIGHT_COLUMN,
             vanillaControlsSize['ComboBoxSmallHeight'] + 1),
            'Body Size:',
            self.bodySizeOptions,
            '{}'.format(self.bodySize),
            sizeStyle='small',
            callback=self.bodyCtrlCallback)

        # line height
        jumpingY += vanillaControlsSize['ComboBoxSmallHeight'] + int(
            MARGIN_HALFROW)
        self.w.lineHgtCtrl = ComboBoxWithCaption(
            (-(RIGHT_COLUMN + MARGIN_RGT), jumpingY, RIGHT_COLUMN,
             vanillaControlsSize['ComboBoxSmallHeight'] + 1),
            'Line Height:',
            self.lineHeightOptions,
            '{}'.format(self.lineHeight),
            sizeStyle='small',
            callback=self.lineHgtCtrlCallback)

        # show metrics
        jumpingY += vanillaControlsSize['ComboBoxSmallHeight'] + MARGIN_ROW
        self.w.showMetricsCheck = CheckBox(
            (-(RIGHT_COLUMN + MARGIN_RGT), jumpingY, RIGHT_COLUMN,
             vanillaControlsSize['CheckBoxSmallHeight']),
            "Show Metrics",
            value=self.showMetrics,
            sizeStyle='small',
            callback=self.showMetricsCheckCallback)

        # show kerning checkbox
        jumpingY += vanillaControlsSize['CheckBoxSmallHeight'] + MARGIN_ROW * .3
        self.w.applyKerningCheck = CheckBox(
            (-(RIGHT_COLUMN + MARGIN_RGT), jumpingY, RIGHT_COLUMN,
             vanillaControlsSize['CheckBoxSmallHeight']),
            "Show Kerning",
            value=self.applyKerning,
            sizeStyle='small',
            callback=self.applyKerningCheckCallback)

        jumpingY += vanillaControlsSize['CheckBoxSmallHeight'] + MARGIN_ROW * .3
        self.w.leftToRightCheck = CheckBox(
            (-(RIGHT_COLUMN + MARGIN_RGT), jumpingY, RIGHT_COLUMN,
             vanillaControlsSize['CheckBoxSmallHeight']),
            "Left to right",
            value=self.leftToRight,
            sizeStyle='small',
            callback=self.leftToRightCheckCallback)

        # separationLine
        jumpingY += vanillaControlsSize['CheckBoxSmallHeight'] + int(
            MARGIN_HALFROW)
        self.w.separationLineOne = HorizontalLine(
            (-(RIGHT_COLUMN + MARGIN_RGT), jumpingY, RIGHT_COLUMN, 1))

        jumpingY += int(MARGIN_HALFROW)
        fontsOrderControllerHeight = FONT_ROW_HEIGHT * len(self.fontsOrder) + 2
        self.w.fontsOrderController = FontsOrderController(
            (-(RIGHT_COLUMN + MARGIN_RGT), jumpingY, RIGHT_COLUMN,
             fontsOrderControllerHeight),
            self.fontsOrder,
            callback=self.fontsOrderControllerCallback)

        jumpingY += fontsOrderControllerHeight
        self.w.separationLineTwo = HorizontalLine(
            (-(RIGHT_COLUMN + MARGIN_RGT), jumpingY, RIGHT_COLUMN, 1))

        # joystick
        jumpingY += MARGIN_HALFROW
        self.w.joystick = SpacingJoystick(
            (-(RIGHT_COLUMN + MARGIN_RGT), jumpingY, RIGHT_COLUMN, 0),
            verticalMode=self.verticalMode,
            marginCallback=self.joystickMarginCallback,
            verticalCallback=self.joystickVerticalCallback)

        # edit metrics
        self.w.spacingMatrix = SpacingMatrix(
            (MARGIN_LFT, -(MARGIN_BTM + self.spacingMatrixHeight),
             self.w.getPosSize()[2] - MARGIN_LFT - MARGIN_RGT,
             self.spacingMatrixHeight),
            glyphNamesToDisplay=self.glyphNamesToDisplay,
            verticalMode=self.verticalMode,
            fontsOrder=self.fontsOrder,
            callback=self.spacingMatrixCallback)

        # add observer
        addObserver(self, 'newFontOpened', "newFontDidOpen")
        addObserver(self, 'openCloseFontCallback', "fontDidOpen")
        addObserver(self, 'openCloseFontCallback', "fontDidClose")

        # lit up!
        self.updateSubscriptions()
        self.updateLineView()
        self.setUpBaseWindowBehavior()
        self.w.open()
예제 #27
0
    def __init__(self, posSize,
                       fontObj,
                       isSymmetricalEditingOn,
                       isSwappedEditingOn,
                       isVerticalAlignedEditingOn,
                       autoSave,
                       autoSaveSpan,
                       activePair,
                       callback):

        super(JoystickController, self).__init__(posSize)
        self.fontObj = fontObj
        self.activePair = activePair

        self.isSymmetricalEditingOn = isSymmetricalEditingOn
        self.isSwappedEditingOn = isSwappedEditingOn
        self.isVerticalAlignedEditingOn = isVerticalAlignedEditingOn
        self.autoSave = autoSave
        self.autoSaveSpan = autoSaveSpan
        self.callback = callback

        buttonSide = 36
        self.ctrlWidth, self.ctrlHeight = posSize[2], posSize[3]
        self.jumping_X = buttonSide/2.
        self.jumping_Y = 0

        self.minusMajorCtrl = SquareButton((self.jumping_X, self.jumping_Y, buttonSide, buttonSide),
                                           "{:+d}".format(MAJOR_STEP),
                                           sizeStyle='small',
                                           callback=self.minusMajorCtrlCallback)
        self.minusMajorCtrl.bind(*MINUS_MAJOR_SHORTCUT)

        self.jumping_X += buttonSide
        self.minusMinorCtrl = SquareButton((self.jumping_X, self.jumping_Y, buttonSide, buttonSide),
                                           "{:+d}".format(MINOR_STEP),
                                           sizeStyle='small',
                                           callback=self.minusMinorCtrlCallback)
        self.minusMinorCtrl.bind(*MINUS_MINOR_SHORTCUT)

        self.jumping_X += buttonSide
        self.plusMinorCtrl = SquareButton((self.jumping_X, self.jumping_Y, buttonSide, buttonSide),
                                          "{:+d}".format(MINOR_STEP),
                                          sizeStyle='small',
                                          callback=self.plusMinorCtrlCallback)
        self.plusMinorCtrl.bind(*PLUS_MINOR_SHORTCUT)

        self.jumping_X += buttonSide
        self.plusMajorCtrl = SquareButton((self.jumping_X, self.jumping_Y, buttonSide, buttonSide),
                                          "{:+d}".format(MAJOR_STEP),
                                          sizeStyle='small',
                                          callback=self.plusMajorCtrlCallback)
        self.plusMajorCtrl.bind(*PLUS_MAJOR_SHORTCUT)

        self.jumping_X = buttonSide/2.
        self.jumping_Y += buttonSide
        self.lftSwitchCtrl = SquareButton((self.jumping_X, self.jumping_Y, buttonSide*2, buttonSide*.75),
                                        "lft switch",
                                        sizeStyle='small',
                                        callback=self.lftSwitchCtrlCallback)
        self.lftSwitchCtrl.bind(*LEFT_BROWSING_SHORTCUT)

        self.jumping_X += buttonSide*2
        self.rgtSwitchCtrl = SquareButton((self.jumping_X, self.jumping_Y, buttonSide*2, buttonSide*.75),
                                       "rgt switch",
                                       sizeStyle='small',
                                       callback=self.rgtSwitchCtrlCallback)
        self.rgtSwitchCtrl.bind(*RIGHT_BROWSING_SHORTCUT)

        self.jumping_X = buttonSide/2.
        self.jumping_Y += buttonSide
        self.exceptionTrigger = SquareButton((self.jumping_X, self.jumping_Y, buttonSide*2, buttonSide*.75),
                                                'exception',
                                                sizeStyle='small',
                                                callback=self.exceptionTriggerCallback)
        self.exceptionTrigger.bind(*EXCEPTION_SHORTCUT)

        self.jumping_X += buttonSide*2
        self.undoButton = SquareButton((self.jumping_X, self.jumping_Y, buttonSide, buttonSide*.75),
                                       'undo',
                                       sizeStyle='small',
                                       callback=self.undoButtonCallback)
        self.undoButton.bind(*UNDO_SHORTCUT)

        self.jumping_X += buttonSide
        self.redoButton = SquareButton((self.jumping_X, self.jumping_Y, buttonSide, buttonSide*.75),
                                       'redo',
                                       sizeStyle='small',
                                       callback=self.redoButtonCallback)
        self.redoButton.bind(*REDO_SHORTCUT)

        self.jumping_X = buttonSide/2.
        self.jumping_Y += buttonSide*.75
        self.previewCtrl = SquareButton((self.jumping_X, self.jumping_Y, buttonSide*2, buttonSide*.75),
                                        "preview",
                                        sizeStyle='small',
                                        callback=self.previewCtrlCallback)
        self.previewCtrl.bind(*PREVIEW_SHORTCUT)

        self.jumping_X += buttonSide*2
        self.solvedCtrl = SquareButton((self.jumping_X, self.jumping_Y, buttonSide*2, buttonSide*.75),
                                       "solved",
                                       sizeStyle='small',
                                       callback=self.solvedCtrlCallback)
        self.solvedCtrl.bind(*SOLVED_SHORTCUT)

        self.jumping_X = buttonSide/2.
        self.jumping_Y += buttonSide*.75+2
        self.symmetricalModeCheck = CheckBox((self.jumping_X, self.jumping_Y, self.ctrlWidth, vanillaControlsSize['CheckBoxRegularHeight']),
                                          'symmetrical editing',
                                          value=self.isSwappedEditingOn,
                                          callback=self.symmetricalModeCallback)

        self.jumping_Y += buttonSide*.6
        self.swappedModeCheck = CheckBox((self.jumping_X, self.jumping_Y, self.ctrlWidth, vanillaControlsSize['CheckBoxRegularHeight']),
                                          'swapped editing',
                                          value=self.isSwappedEditingOn,
                                          callback=self.swappedModeCallback)

        self.jumping_Y += buttonSide*.6
        self.verticalAlignedModeCheck = CheckBox((self.jumping_X, self.jumping_Y, self.ctrlWidth, vanillaControlsSize['CheckBoxRegularHeight']),
                                                 'vertically aligned editing',
                                                 value=self.isVerticalAlignedEditingOn,
                                                 callback=self.verticalAlignedModeCheckCallback)
        self.verticalAlignedModeCheck.bind(*VERTICAL_MODE_SHORTCUT)

        self.hiddenSwappedEditingButton = Button((self.jumping_X, self.ctrlHeight+40, self.ctrlWidth, vanillaControlsSize['ButtonRegularHeight']),
                                                   'hiddenSymmetriyEditingButton',
                                                   callback=self.hiddenSwappedEditingButtonCallback)
        self.hiddenSwappedEditingButton.bind(*FLIPPED_EDITING_SHORTCUT)

        self.hiddenJumpToLineButton = Button((self.jumping_X, self.ctrlHeight+40, self.ctrlWidth, vanillaControlsSize['ButtonRegularHeight']),
                                                   'hiddenJumpToLineButton',
                                                   callback=self.hiddenJumpToLineButtonCallback)
        self.hiddenJumpToLineButton.bind(*JUMP_TO_LINE_SHORTCUT)

        self.jumping_X = buttonSide
        self.jumping_Y += buttonSide
        self.previousWordCtrl = SquareButton((self.jumping_X, self.jumping_Y, buttonSide, buttonSide),
                                             u'↖',
                                             callback=self.previousWordCtrlCallback)
        self.previousWordCtrl.bind(*PREVIOUS_WORD_SHORTCUT)

        self.jumping_X += buttonSide
        self.cursorUpCtrl = SquareButton((self.jumping_X, self.jumping_Y, buttonSide, buttonSide),
                                         u'↑',
                                         callback=self.cursorUpCtrlCallback)
        self.cursorUpCtrl.bind(*CURSOR_UP_SHORTCUT)

        self.jumping_X += buttonSide*1.5
        self.activePairEditCorrection = EditText((self.jumping_X, self.jumping_Y, 50, vanillaControlsSize['EditTextRegularHeight']),
                                                 text='{:d}'.format(0),   # init value
                                                 continuous=False,
                                                 callback=self.activePairEditCorrectionCallback)

        self.jumping_X = buttonSide
        self.jumping_Y += buttonSide
        self.cursorLeftCtrl = SquareButton((self.jumping_X, self.jumping_Y, buttonSide, buttonSide),
                                           u"←",
                                           callback=self.cursorLeftCtrlCallback)
        self.cursorLeftCtrl.bind(*CURSOR_LEFT_SHORTCUT)

        self.jumping_X += buttonSide*2
        self.cursorRightCtrl = SquareButton((self.jumping_X, self.jumping_Y, buttonSide, buttonSide),
                                            u'→',
                                            callback=self.cursorRightCtrlCallback)
        self.cursorRightCtrl.bind(*CURSOR_RIGHT_SHORTCUT)

        self.jumping_X = buttonSide
        self.jumping_Y += buttonSide

        self.delPairCtrl = SquareButton((self.jumping_X-6, self.jumping_Y+6, buttonSide, buttonSide),
                                        u'Del',
                                        callback=self.delPairCtrlCallback)
        self.delPairCtrl.bind(*DEL_PAIR_SHORTCUT)

        self.jumping_X += buttonSide
        self.cursorDownCtrl = SquareButton((self.jumping_X, self.jumping_Y, buttonSide, buttonSide),
                                           u'↓',
                                           callback=self.cursorDownCtrlCallback)
        self.cursorDownCtrl.bind(*CURSOR_DOWN_SHORTCUT)

        self.jumping_X += buttonSide
        self.nextWordCtrl = SquareButton((self.jumping_X, self.jumping_Y, buttonSide, buttonSide),
                                         u'↘',
                                         callback=self.nextWordCtrlCallback)
        self.nextWordCtrl.bind(*NEXT_WORD_SHORTCUT)

        self.jumping_Y += buttonSide*1.3
        self.jumping_X = buttonSide*.5
        self.autoSaveCheck = CheckBox((self.jumping_X, self.jumping_Y, buttonSide*2.5, vanillaControlsSize['CheckBoxRegularHeight']),
                                      'auto save',
                                      callback=self.autoSaveCheckCallback)

        self.jumping_X += buttonSide*2.5
        self.autoSaveSpanPopUp = PopUpButton((self.jumping_X, self.jumping_Y, buttonSide*1.5, vanillaControlsSize['PopUpButtonRegularHeight']),
                                             AUTO_SAVE_SPAN_OPTIONS,
                                             callback=self.autoSaveSpanPopUpCallback)
        self.autoSaveSpanPopUp.set(AUTO_SAVE_SPAN_OPTIONS.index("{:d}'".format(self.autoSaveSpan)))
    def buildWindow(self):
        jumpingY = MARGIN

        # lux button
        self.w.aCaption = TextBox(
            (MARGIN, jumpingY + 1, 1200, CTRL_SIZES['TextBoxRegularHeight']),
            '(a) Log the luminace data or open saved luminace data.')

        jumpingY += CTRL_SIZES['ButtonRegularHeight'] + MARGIN

        self.w.luxButton = Button(
            (MARGIN, jumpingY, 160, CTRL_SIZES['CheckBoxRegularHeight']),
            'log the luminance',
            callback=self.luxButtonCallback)

        self.w.luxButtonCaption = TextBox(
            (176 + MARGIN * 3, jumpingY + 1, 1200,
             CTRL_SIZES['TextBoxRegularHeight']),
            'Connect the external sensor first!')

        jumpingY += CTRL_SIZES['ButtonRegularHeight'] + MARGIN

        # sensor data folder
        self.w.luxFolderButton = Button(
            (MARGIN, jumpingY, 160, CTRL_SIZES['ButtonRegularHeight']),
            'Luminance Folder',
            callback=self.luxFolderButtonCallback)

        self.w.luxFolderCaption = TextBox(
            (160 + MARGIN * 2, jumpingY + 1, 1200,
             CTRL_SIZES['TextBoxRegularHeight']),
            'Select where to save/read the lumiance sensor data')

        jumpingY += CTRL_SIZES['CheckBoxRegularHeight'] * 2 + MARGIN

        self.w.bCaption = TextBox(
            (MARGIN, jumpingY + 1, 1200, CTRL_SIZES['TextBoxRegularHeight']),
            '(b) Select a recording.')
        jumpingY += CTRL_SIZES['ButtonRegularHeight'] + MARGIN

        # recording folder
        self.w.recFolderButton = Button(
            (MARGIN, jumpingY, 120, CTRL_SIZES['ButtonRegularHeight']),
            'Recording Folder',
            callback=self.recFolderButtonCallback)

        self.w.recordingFolderCaption = TextBox(
            (120 + MARGIN * 2, jumpingY + 1, 1200,
             CTRL_SIZES['TextBoxRegularHeight']), 'Select a recording')

        jumpingY += CTRL_SIZES['ButtonRegularHeight'] + MARGIN

        self.w.recordingFoundCaption = TextBox(
            (120 + MARGIN * 2, jumpingY + 1, 1200,
             CTRL_SIZES['TextBoxRegularHeight']), '')

        jumpingY += CTRL_SIZES['ButtonRegularHeight'] + MARGIN

        self.w.analyzedVideoCaption = TextBox(
            (120 + MARGIN * 2, jumpingY + 1, 1200,
             CTRL_SIZES['TextBoxRegularHeight']), '')

        # export folder
        jumpingY += CTRL_SIZES['ButtonRegularHeight'] * 2 + MARGIN

        self.w.cCaption = TextBox(
            (MARGIN, jumpingY + 1, 1200, CTRL_SIZES['TextBoxRegularHeight']),
            '(c) Select were to save the output (csv and pdf).')

        jumpingY += CTRL_SIZES['ButtonRegularHeight'] + MARGIN
        self.w.exportFolderButton = Button(
            (MARGIN, jumpingY, 120, CTRL_SIZES['ButtonRegularHeight']),
            'Export Folder',
            callback=self.expFolderButtonCallback)
        self.w.exportFolderCaption = TextBox(
            (120 + MARGIN * 2, jumpingY + 1, 600,
             CTRL_SIZES['TextBoxRegularHeight']), 'Select an export folder')

        jumpingY += CTRL_SIZES['ButtonRegularHeight'] * 2 + MARGIN

        self.w.dCaption = TextBox((
            MARGIN, jumpingY + 1, 1200, CTRL_SIZES['TextBoxRegularHeight']
        ), '(d) Analyze the video data to compute the lumince on the gaze area (optional).'
                                  )

        # analyze video
        jumpingY += CTRL_SIZES['ButtonRegularHeight'] + MARGIN

        self.w.analyzeVideoButton = Button(
            (MARGIN, jumpingY, 140, CTRL_SIZES['ButtonRegularHeight']),
            'Analyze World Video',
            callback=self.analyzeVideoButtonCallback)
        self.w.analyzeVideoCaption = TextBox(
            (140 + MARGIN * 2, jumpingY + 1, 600,
             CTRL_SIZES['TextBoxRegularHeight']),
            'Process the world camera video.')

        ## show analyze video
        jumpingY += CTRL_SIZES['CheckBoxRegularHeight'] + MARGIN
        self.w.showAnalizeCheck = CheckBox(
            (MARGIN, jumpingY, 600, CTRL_SIZES['CheckBoxRegularHeight']),
            'Show video analysis (slow)',
            callback=self.showAnalizeCallback)

        jumpingY += CTRL_SIZES['CheckBoxRegularHeight'] + MARGIN
        self.w.analyzeVideoBar = ProgressBar((MARGIN, jumpingY, -10, 16),
                                             minValue=0,
                                             maxValue=100)
        self.w.analyzeVideoBar.show(False)

        jumpingY += CTRL_SIZES['ButtonRegularHeight'] * 1 + MARGIN

        self.w.eCaption = TextBox(
            (MARGIN, jumpingY + 1, 1200, CTRL_SIZES['TextBoxRegularHeight']),
            '(e) Calculate the expected pupil size and workload.')

        # # proceed button
        jumpingY += CTRL_SIZES['CheckBoxRegularHeight'] + MARGIN
        self.w.pupilSizeButton = Button(
            (MARGIN, jumpingY, 220, CTRL_SIZES['CheckBoxRegularHeight']),
            'Calculate Workload',
            callback=self.pupilSizeButtonCallback)
        # # subject age
        jumpingY += CTRL_SIZES['ButtonRegularHeight'] + MARGIN
        self.w.ageCaption = TextBox(
            (MARGIN, jumpingY, 120, CTRL_SIZES['TextBoxRegularHeight']),
            'Subject Age:')
        self.w.agePopUp = PopUpButton((120 + MARGIN * 2, jumpingY, 120,
                                       CTRL_SIZES['PopUpButtonRegularHeight']),
                                      [f'{ii}' for ii in range(99)],
                                      callback=self.agePopUpCallback)

        # options
        jumpingY += CTRL_SIZES['PopUpButtonRegularHeight'] + MARGIN
        ## use camera
        self.w.useCameraCheck = CheckBox(
            (MARGIN, jumpingY, 320, CTRL_SIZES['CheckBoxRegularHeight']),
            'Use world video camera data',
            callback=self.useCameraCheckCallback)

        ## timelag
        jumpingY += CTRL_SIZES['EditTextRegularHeight'] + MARGIN
        self.w.timeLagEditText = EditText(
            (MARGIN, jumpingY, 100, 22),
            "0",
            callback=self.timeLagEditTextCallback)

        self.w.timeLagTextBox = TextBox(
            (100 + MARGIN * 2, jumpingY, -10, 17),
            "Time delta (s) to sicronize sensor data with eye data")

        ## pupilFiltering
        jumpingY += CTRL_SIZES['EditTextRegularHeight'] + MARGIN
        self.w.pupilFilteringEditText = EditText(
            (MARGIN, jumpingY, 100, 22),
            "0",
            callback=self.pupilFilteringEditTextCallback)

        self.w.pupilFilteringTextBox = TextBox(
            (100 + MARGIN * 2, jumpingY, -10, 17),
            "Temporal resolution of the CW data (smoothing, min 1s )")

        ## plot output
        jumpingY += CTRL_SIZES['CheckBoxRegularHeight'] + MARGIN
        self.w.showPlotCheck = CheckBox(
            (MARGIN, jumpingY, 180, CTRL_SIZES['CheckBoxRegularHeight']),
            'Generate/save plot',
            callback=self.showPlotCheckCallback)

        # ## export csv
        jumpingY += CTRL_SIZES['CheckBoxRegularHeight'] + MARGIN
        self.w.exportDatasheet = CheckBox(
            (MARGIN, jumpingY, 120, CTRL_SIZES['CheckBoxRegularHeight']),
            'Export to CSV',
            callback=self.exportDatasheetCallback)

        jumpingY += CTRL_SIZES['ButtonRegularHeight'] * 2 + MARGIN

        self.w.fCaption = TextBox(
            (MARGIN, jumpingY + 1, 1200, CTRL_SIZES['TextBoxRegularHeight']),
            '(f) Plot Workload over GPS data.')

        # # gps button
        jumpingY += CTRL_SIZES['CheckBoxRegularHeight'] + MARGIN
        self.w.gpsButton = Button(
            (MARGIN, jumpingY, 220, CTRL_SIZES['CheckBoxRegularHeight']),
            'Plot CW with GPS',
            callback=self.gpsButtonCallback)
        self.w.gpsCaption = TextBox(
            (220 + MARGIN * 2, jumpingY + 1, 600,
             CTRL_SIZES['TextBoxRegularHeight']),
            'Place "gps_track.gpx" inside the recording folder')
예제 #29
0
class JoystickController(Group):

    lastEvent = None
    keyboardCorrection = 0

    def __init__(self, posSize,
                       fontObj,
                       isSymmetricalEditingOn,
                       isSwappedEditingOn,
                       isVerticalAlignedEditingOn,
                       autoSave,
                       autoSaveSpan,
                       activePair,
                       callback):

        super(JoystickController, self).__init__(posSize)
        self.fontObj = fontObj
        self.activePair = activePair

        self.isSymmetricalEditingOn = isSymmetricalEditingOn
        self.isSwappedEditingOn = isSwappedEditingOn
        self.isVerticalAlignedEditingOn = isVerticalAlignedEditingOn
        self.autoSave = autoSave
        self.autoSaveSpan = autoSaveSpan
        self.callback = callback

        buttonSide = 36
        self.ctrlWidth, self.ctrlHeight = posSize[2], posSize[3]
        self.jumping_X = buttonSide/2.
        self.jumping_Y = 0

        self.minusMajorCtrl = SquareButton((self.jumping_X, self.jumping_Y, buttonSide, buttonSide),
                                           "{:+d}".format(MAJOR_STEP),
                                           sizeStyle='small',
                                           callback=self.minusMajorCtrlCallback)
        self.minusMajorCtrl.bind(*MINUS_MAJOR_SHORTCUT)

        self.jumping_X += buttonSide
        self.minusMinorCtrl = SquareButton((self.jumping_X, self.jumping_Y, buttonSide, buttonSide),
                                           "{:+d}".format(MINOR_STEP),
                                           sizeStyle='small',
                                           callback=self.minusMinorCtrlCallback)
        self.minusMinorCtrl.bind(*MINUS_MINOR_SHORTCUT)

        self.jumping_X += buttonSide
        self.plusMinorCtrl = SquareButton((self.jumping_X, self.jumping_Y, buttonSide, buttonSide),
                                          "{:+d}".format(MINOR_STEP),
                                          sizeStyle='small',
                                          callback=self.plusMinorCtrlCallback)
        self.plusMinorCtrl.bind(*PLUS_MINOR_SHORTCUT)

        self.jumping_X += buttonSide
        self.plusMajorCtrl = SquareButton((self.jumping_X, self.jumping_Y, buttonSide, buttonSide),
                                          "{:+d}".format(MAJOR_STEP),
                                          sizeStyle='small',
                                          callback=self.plusMajorCtrlCallback)
        self.plusMajorCtrl.bind(*PLUS_MAJOR_SHORTCUT)

        self.jumping_X = buttonSide/2.
        self.jumping_Y += buttonSide
        self.lftSwitchCtrl = SquareButton((self.jumping_X, self.jumping_Y, buttonSide*2, buttonSide*.75),
                                        "lft switch",
                                        sizeStyle='small',
                                        callback=self.lftSwitchCtrlCallback)
        self.lftSwitchCtrl.bind(*LEFT_BROWSING_SHORTCUT)

        self.jumping_X += buttonSide*2
        self.rgtSwitchCtrl = SquareButton((self.jumping_X, self.jumping_Y, buttonSide*2, buttonSide*.75),
                                       "rgt switch",
                                       sizeStyle='small',
                                       callback=self.rgtSwitchCtrlCallback)
        self.rgtSwitchCtrl.bind(*RIGHT_BROWSING_SHORTCUT)

        self.jumping_X = buttonSide/2.
        self.jumping_Y += buttonSide
        self.exceptionTrigger = SquareButton((self.jumping_X, self.jumping_Y, buttonSide*2, buttonSide*.75),
                                                'exception',
                                                sizeStyle='small',
                                                callback=self.exceptionTriggerCallback)
        self.exceptionTrigger.bind(*EXCEPTION_SHORTCUT)

        self.jumping_X += buttonSide*2
        self.undoButton = SquareButton((self.jumping_X, self.jumping_Y, buttonSide, buttonSide*.75),
                                       'undo',
                                       sizeStyle='small',
                                       callback=self.undoButtonCallback)
        self.undoButton.bind(*UNDO_SHORTCUT)

        self.jumping_X += buttonSide
        self.redoButton = SquareButton((self.jumping_X, self.jumping_Y, buttonSide, buttonSide*.75),
                                       'redo',
                                       sizeStyle='small',
                                       callback=self.redoButtonCallback)
        self.redoButton.bind(*REDO_SHORTCUT)

        self.jumping_X = buttonSide/2.
        self.jumping_Y += buttonSide*.75
        self.previewCtrl = SquareButton((self.jumping_X, self.jumping_Y, buttonSide*2, buttonSide*.75),
                                        "preview",
                                        sizeStyle='small',
                                        callback=self.previewCtrlCallback)
        self.previewCtrl.bind(*PREVIEW_SHORTCUT)

        self.jumping_X += buttonSide*2
        self.solvedCtrl = SquareButton((self.jumping_X, self.jumping_Y, buttonSide*2, buttonSide*.75),
                                       "solved",
                                       sizeStyle='small',
                                       callback=self.solvedCtrlCallback)
        self.solvedCtrl.bind(*SOLVED_SHORTCUT)

        self.jumping_X = buttonSide/2.
        self.jumping_Y += buttonSide*.75+2
        self.symmetricalModeCheck = CheckBox((self.jumping_X, self.jumping_Y, self.ctrlWidth, vanillaControlsSize['CheckBoxRegularHeight']),
                                          'symmetrical editing',
                                          value=self.isSwappedEditingOn,
                                          callback=self.symmetricalModeCallback)

        self.jumping_Y += buttonSide*.6
        self.swappedModeCheck = CheckBox((self.jumping_X, self.jumping_Y, self.ctrlWidth, vanillaControlsSize['CheckBoxRegularHeight']),
                                          'swapped editing',
                                          value=self.isSwappedEditingOn,
                                          callback=self.swappedModeCallback)

        self.jumping_Y += buttonSide*.6
        self.verticalAlignedModeCheck = CheckBox((self.jumping_X, self.jumping_Y, self.ctrlWidth, vanillaControlsSize['CheckBoxRegularHeight']),
                                                 'vertically aligned editing',
                                                 value=self.isVerticalAlignedEditingOn,
                                                 callback=self.verticalAlignedModeCheckCallback)
        self.verticalAlignedModeCheck.bind(*VERTICAL_MODE_SHORTCUT)

        self.hiddenSwappedEditingButton = Button((self.jumping_X, self.ctrlHeight+40, self.ctrlWidth, vanillaControlsSize['ButtonRegularHeight']),
                                                   'hiddenSymmetriyEditingButton',
                                                   callback=self.hiddenSwappedEditingButtonCallback)
        self.hiddenSwappedEditingButton.bind(*FLIPPED_EDITING_SHORTCUT)

        self.hiddenJumpToLineButton = Button((self.jumping_X, self.ctrlHeight+40, self.ctrlWidth, vanillaControlsSize['ButtonRegularHeight']),
                                                   'hiddenJumpToLineButton',
                                                   callback=self.hiddenJumpToLineButtonCallback)
        self.hiddenJumpToLineButton.bind(*JUMP_TO_LINE_SHORTCUT)

        self.jumping_X = buttonSide
        self.jumping_Y += buttonSide
        self.previousWordCtrl = SquareButton((self.jumping_X, self.jumping_Y, buttonSide, buttonSide),
                                             u'↖',
                                             callback=self.previousWordCtrlCallback)
        self.previousWordCtrl.bind(*PREVIOUS_WORD_SHORTCUT)

        self.jumping_X += buttonSide
        self.cursorUpCtrl = SquareButton((self.jumping_X, self.jumping_Y, buttonSide, buttonSide),
                                         u'↑',
                                         callback=self.cursorUpCtrlCallback)
        self.cursorUpCtrl.bind(*CURSOR_UP_SHORTCUT)

        self.jumping_X += buttonSide*1.5
        self.activePairEditCorrection = EditText((self.jumping_X, self.jumping_Y, 50, vanillaControlsSize['EditTextRegularHeight']),
                                                 text='{:d}'.format(0),   # init value
                                                 continuous=False,
                                                 callback=self.activePairEditCorrectionCallback)

        self.jumping_X = buttonSide
        self.jumping_Y += buttonSide
        self.cursorLeftCtrl = SquareButton((self.jumping_X, self.jumping_Y, buttonSide, buttonSide),
                                           u"←",
                                           callback=self.cursorLeftCtrlCallback)
        self.cursorLeftCtrl.bind(*CURSOR_LEFT_SHORTCUT)

        self.jumping_X += buttonSide*2
        self.cursorRightCtrl = SquareButton((self.jumping_X, self.jumping_Y, buttonSide, buttonSide),
                                            u'→',
                                            callback=self.cursorRightCtrlCallback)
        self.cursorRightCtrl.bind(*CURSOR_RIGHT_SHORTCUT)

        self.jumping_X = buttonSide
        self.jumping_Y += buttonSide

        self.delPairCtrl = SquareButton((self.jumping_X-6, self.jumping_Y+6, buttonSide, buttonSide),
                                        u'Del',
                                        callback=self.delPairCtrlCallback)
        self.delPairCtrl.bind(*DEL_PAIR_SHORTCUT)

        self.jumping_X += buttonSide
        self.cursorDownCtrl = SquareButton((self.jumping_X, self.jumping_Y, buttonSide, buttonSide),
                                           u'↓',
                                           callback=self.cursorDownCtrlCallback)
        self.cursorDownCtrl.bind(*CURSOR_DOWN_SHORTCUT)

        self.jumping_X += buttonSide
        self.nextWordCtrl = SquareButton((self.jumping_X, self.jumping_Y, buttonSide, buttonSide),
                                         u'↘',
                                         callback=self.nextWordCtrlCallback)
        self.nextWordCtrl.bind(*NEXT_WORD_SHORTCUT)

        self.jumping_Y += buttonSide*1.3
        self.jumping_X = buttonSide*.5
        self.autoSaveCheck = CheckBox((self.jumping_X, self.jumping_Y, buttonSide*2.5, vanillaControlsSize['CheckBoxRegularHeight']),
                                      'auto save',
                                      callback=self.autoSaveCheckCallback)

        self.jumping_X += buttonSide*2.5
        self.autoSaveSpanPopUp = PopUpButton((self.jumping_X, self.jumping_Y, buttonSide*1.5, vanillaControlsSize['PopUpButtonRegularHeight']),
                                             AUTO_SAVE_SPAN_OPTIONS,
                                             callback=self.autoSaveSpanPopUpCallback)
        self.autoSaveSpanPopUp.set(AUTO_SAVE_SPAN_OPTIONS.index("{:d}'".format(self.autoSaveSpan)))

    # goes out
    def getLastEvent(self):
        return self.lastEvent

    def getKeyboardCorrection(self):
        return self.keyboardCorrection

    def getAutoSaveState(self):
        return self.autoSave, self.autoSaveSpan

    # comes in
    def setActivePair(self, activePair):
        self.activePair = activePair
        self.updateCorrectionValue()

    def setSwappedEditing(self, value):
        self.isSwappedEditingOn = value
        self.swappedModeCheck.set(self.isSwappedEditingOn)

    def setSymmetricalEditing(self, value):
        self.isSymmetricalEditingOn = value
        self.symmetricalModeCheck.set(self.isSymmetricalEditingOn)

    def setFontObj(self, value):
        self.fontObj = value
        self.updateCorrectionValue()

    def updateCorrectionValue(self):
        correction, kerningReference, pairKind = getCorrection(self.activePair, self.fontObj)
        try:
            self.activePairEditCorrection.set('{:d}'.format(correction))
        except ValueError:
            self.activePairEditCorrection.set('')

    # callbacks
    def minusMajorCtrlCallback(self, sender):
        self.lastEvent = 'minusMajor'
        self.callback(self)

    def minusMinorCtrlCallback(self, sender):
        self.lastEvent = 'minusMinor'
        self.callback(self)

    def plusMinorCtrlCallback(self, sender):
        self.lastEvent = 'plusMinor'
        self.callback(self)

    def plusMajorCtrlCallback(self, sender):
        self.lastEvent = 'plusMajor'
        self.callback(self)

    def delPairCtrlCallback(self, sender):
        self.lastEvent = 'deletePair'
        self.callback(self)

    def exceptionTriggerCallback(self, sender):
        self.lastEvent = 'exceptionTrigger'
        self.callback(self)

    def undoButtonCallback(self, sender):
        self.lastEvent = 'undo'
        self.callback(self)

    def redoButtonCallback(self, sender):
        self.lastEvent = 'redo'
        self.callback(self)

    def previewCtrlCallback(self, sender):
        self.lastEvent = 'preview'
        self.callback(self)

    def solvedCtrlCallback(self, sender):
        self.lastEvent = 'solved'
        self.callback(self)

    def swappedModeCallback(self, sender):
        self.lastEvent = 'swappedEditing'
        self.isSwappedEditingOn = bool(sender.get())
        self.callback(self)

    def symmetricalModeCallback(self, sender):
        self.lastEvent = 'symmetricalEditing'
        self.isSymmetricalEditingOn = bool(sender.get())
        self.callback(self)

    def verticalAlignedModeCheckCallback(self, sender):
        self.lastEvent = 'verticalAlignedEditing'
        self.isVerticalAlignedEditingOn = bool(sender.get())
        self.callback(self)

    def hiddenSwappedEditingButtonCallback(self, sender):
        self.lastEvent = 'swappedEditing'
        self.isSwappedEditingOn = not self.isSwappedEditingOn
        self.swappedModeCheck.set(self.isSwappedEditingOn)
        self.callback(self)

    def hiddenJumpToLineButtonCallback(self, sender):
        self.lastEvent = 'jumpToLineTrigger'
        self.callback(self)

    def previousWordCtrlCallback(self, sender):
        self.lastEvent = 'previousWord'
        self.callback(self)

    def cursorUpCtrlCallback(self, sender):
        self.lastEvent = 'cursorUp'
        self.callback(self)

    def cursorLeftCtrlCallback(self, sender):
        self.lastEvent = 'cursorLeft'
        self.callback(self)

    def cursorRightCtrlCallback(self, sender):
        self.lastEvent = 'cursorRight'
        self.callback(self)

    def cursorDownCtrlCallback(self, sender):
        self.lastEvent = 'cursorDown'
        self.callback(self)

    def nextWordCtrlCallback(self, sender):
        self.lastEvent = 'nextWord'
        self.callback(self)

    def lftSwitchCtrlCallback(self, sender):
        self.lastEvent = 'switchLftGlyph'
        self.callback(self)

    def rgtSwitchCtrlCallback(self, sender):
        self.lastEvent = 'switchRgtGlyph'
        self.callback(self)

    def activePairEditCorrectionCallback(self, sender):
        # removing the pair, if nothing is written
        if sender.get() == '':
            self.keyboardCorrection = None
            self.callback(self)
            return

        # if numbers are there...
        try:
            self.lastEvent = 'keyboardEdit'
            self.keyboardCorrection = int(sender.get())
            self.callback(self)
        except ValueError:
            if sender.get() != '-':
                self.activePairEditCorrection.set('{}'.format(self.keyboardCorrection))
                print traceback.format_exc()

    def autoSaveCheckCallback(self, sender):
        self.lastEvent = 'autoSave'
        self.autoSave = bool(sender.get())
        self.callback(self)

    def autoSaveSpanPopUpCallback(self, sender):
        self.lastEvent = 'autoSave'
        self.autoSaveSpan = INT_2_SPAN[AUTO_SAVE_SPAN_OPTIONS[sender.get()]]
        self.callback(self)
예제 #30
0
    def _buildUI(self):
        editPresetsImgPath = os.path.join(currentFileDir,\
                                          "..", "resources",\
                                          "editPresetsIcon.pdf")

        listForList = [
            {
                "title": "#",
                "key": "order",
                "width": 20,
                "editable": False
            },
            {
                "title": "Group name",
                "key": "name",
                "width": 160,
                "editable": True
            },
            {
                "title": "Type size",
                "key": "typeSize",
                "width": 70,
                "editable": True,
            },
            {
                "title": "Leading",
                "key": "leading",
                "width": 65,
                "editable": True
            },
            {
                "title": " 🖨",
                "key": "print",
                "cell": CheckBoxListCell()
            }
        ]

        width = 425
        left = 10
        row = 10
        textWidth = 48
        textHeight = 20
        popUpLeft = left + textWidth + 5
        presetsPopUpWidth = width - popUpLeft - 47
        listWidth = textWidth + presetsPopUpWidth

        self.w = Window((width, 600), "Proof Drawer")

        self.w.fontText = TextBox((left, row, textWidth, textHeight),
                                  "Font:",
                                  alignment="right")
        self.w.fontsList = PopUpButton((popUpLeft, row, -10, textHeight),
                                       items=self.fonts,
                                       callback=self.fontButtonCB)

        row += 30
        self.w.presetText = TextBox((left, row, textWidth, textHeight),
                                    "Preset:",
                                    alignment="right")

        self.w.presetsList = PopUpButton((popUpLeft, row, presetsPopUpWidth, textHeight),
                                         items=self.presetNamesList,
                                         callback=self.setCurrentPresetCB)

        self.w.editPresets = ImageButton((width - 38, row, 22, 22),
                                         imagePath=editPresetsImgPath,
                                         bordered=False,
                                         callback=self.openPresetsEditorCB)

        row += 35
        self.w.line1 = HorizontalLine((left, row, -10, 1))

        row += 15
        self.w.proofGroups = List((left + 3, row, listWidth, 255),
                                  rowHeight=18,
                                  items=[],
                                  columnDescriptions=listForList,
                                  allowsSorting=False,
                                  allowsMultipleSelection=False,
                                  editCallback=self.editProofGroupCB)

        buttonGroup1Left = popUpLeft + presetsPopUpWidth + 3
        buttonGroup1Top = row + 58
        self.w.inspectGroup = Button((buttonGroup1Left, buttonGroup1Top, 30, 20),
                                     "\u24D8",
                                     callback=self.inspectGroupCB)

        buttonGroup1Top += 40
        self.w.moveGroupUP = Button((buttonGroup1Left, buttonGroup1Top, 30, 20),
                                    "↑",
                                    callback=self.moveGroupCB)
        buttonGroup1Top += 25
        self.w.moveGroupDN = Button((buttonGroup1Left, buttonGroup1Top, 30, 20),
                                    "↓",
                                    callback=self.moveGroupCB)

        buttonGroup1Top += 40
        self.w.removeGroup = Button((buttonGroup1Left, buttonGroup1Top, 30, 20),
                                    "-",
                                    callback=self.removeGroupCB)

        row += 275
        self.w.line2 = HorizontalLine((left, row, -10, 1))

        row += 10
        self.w.additionalGroupNamesText = TextBox((left, row, -10, 20),
                                                  "Add more proof groups:")

        row += 25
        self.w.additionalGroupNames = List((left + 3, row, listWidth, 150),
                                           rowHeight=17,
                                           items=self.currentPreset.uniqueGroupNames,
                                           allowsSorting=False,
                                           allowsMultipleSelection=True)

        self.w.addGroup = Button((buttonGroup1Left, row + 60, 30, 20),
                                 "+",
                                 callback=self.addProofGroupsCB)

        buttonWidth = 100
        self.w.previewButton = Button((width/2 - buttonWidth - 10, -37, buttonWidth, 20),
                                      "Preview",
                                      callback=self.testerCB)

        self.w.printButton = Button((width/2 + 10, -37, buttonWidth, 20),
                                    "Print",
                                    callback=self.testerCB)
        self.w.setDefaultButton(self.w.printButton)