def __init__(self, parameter, posSize, title=None, callback=None): super(ParameterSliderTextInput, self).__init__(posSize) self.parameter = parameter self.callback = callback editTextPosSize = (-65, 0, 40, 22) if title is None: sliderPosSize = (5, 3, -80, 15) elif title is not None: title = title.capitalize() sliderPosSize = (70, 3, -80, 15) self.title = TextBox((0, 3, 65, 30), title, sizeStyle='small') if parameter.dissociable: editTextPosSize = (-65, 0, 40, 22) self.checkBox = CheckBox((-22, 5, 22, 25), u'∞', callback=self.setFree, value=True, sizeStyle='mini') self.slider = Slider(sliderPosSize, minValue=parameter.limits[0], maxValue=parameter.limits[1], value=parameter.value, callback=self.valueInput, sizeStyle='small') self.textInput = EditText(editTextPosSize, str(parameter.value), callback=self.valueInput, continuous=False, sizeStyle='small') self.parameter.bind(self)
class Label(Group): def __init__(self, posSize, attachCallback, labelName=None): super(Label, self).__init__(posSize) self.labelName = labelName self.attachCallback = attachCallback self.edit = EditText((0, 0, NET_WIDTH * .7, vanillaControlsSize['EditTextRegularHeight']), text=self.labelName, continuous=True, callback=self.editCallback) self.button = SquareButton( (NET_WIDTH * .72, 0, NET_WIDTH * .28, vanillaControlsSize['EditTextRegularHeight']), 'attach!', callback=self.buttonCallback) def get(self): return self.labelName def setLabelName(self, labelName): self.labelName = labelName self.edit.set(self.labelName) def editCallback(self, sender): self.labelName = sender.get() def buttonCallback(self, sender): self.attachCallback(self)
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 __init__(self, parameter, posSize, text='', callback=None, continuous=False, showRelativeValue=False): super(ParameterTextInput, self).__init__(posSize) self.parameter = parameter rel = self._relValue() self.callback = callback self.textInput = EditText((0, 0, -40, -0), text=text, callback=self._valueInput, continuous=continuous) self.relInfo = TextBox((-35, 5, -0, -0), rel, alignment='left', sizeStyle='small') self.showRelativeValue(showRelativeValue) self.vanillaInputs = [self.textInput] self.parameter.bind(self)
def __init__(self, position, label, placeholder=""): super(TextField, self).__init__( (position[0], position[1], position[2], 22)) self.label = TextBox((0, 3, self.indent - 10, 22), "{0}:".format(label), alignment="right") self.text = EditText((self.indent, 0, 500 - 40 - self.indent, 22), placeholder=placeholder)
def __init__(self): self.font = Glyphs.font # Returns the current that is open in GlyphsApp self.currentGlyphName = 'H' self.glyph = self.font[self.currentGlyphName].layers[0] lsb = int(round(self.glyph.LSB)) rsb = int(round(self.glyph.RSB)) pad = 10 leading = 32 y = pad w = 300 h = 400 buttonWidth = 100 buttonHeight = 48 self.w = Window((100, 100, w, h), 'DemoWindowTool') self.w.doDraw = CheckBox((pad, y, 100, 24), 'Draw', callback=self.doDrawCallback) y += leading self.w.leftMarginLabel = TextBox((pad, y, -pad, 24), 'Left margin') y += leading / 2 self.w.leftMarginSlider = Slider( (pad, y, -pad - 60, 24), minValue=MIN_LSB, maxValue=MAX_LSB, value=lsb, tickMarkCount=10, callback=self.leftMarginSliderCallback) self.w.leftMarginBox = EditText((-pad - 60 + pad, y, -pad, 24), callback=self.leftMarginBoxCallback) self.w.leftMarginBox.set(str(lsb)) y += leading self.w.rightMarginLabel = TextBox((pad, y, -pad, 24), 'Right margin') y += leading / 2 self.w.rightMarginSlider = Slider( (pad, y, -pad - 60, 24), minValue=MIN_RSB, maxValue=MAX_RSB, value=rsb, tickMarkCount=10, callback=self.rightMarginSliderCallback) self.w.rightMarginBox = EditText((-pad - 60 + pad, y, -pad, 24), callback=self.rightMarginBoxCallback) self.w.rightMarginBox.set(str(rsb)) y = self.w.saveFont = Button((-buttonWidth - pad, -buttonHeight - pad, buttonWidth, buttonHeight), 'Save', callback=self.saveFontCallback) self.w.open()
def __init__(self, posSize, text, minValue, maxValue, value, callback): Group.__init__(self, posSize) self.text = TextBox((0, 0, -0, 20), text) self.slider = Slider((2, 20, -60, 17), minValue=minValue, maxValue=maxValue, value=value, sizeStyle="small", callback=self.sliderChanged) self.edit = EditText((-40, 15, -0, 22), text=str(value), placeholder=str(value), callback=self.editChanged) self.callback = callback
def show_subscriber_sheet(self, sender): self.window.sheet = Sheet((250, 107), self.window) self.window.sheet.name = EditText((15, 15, -15, 22), "", placeholder="Name") self.window.sheet.email_address = EditText((15, 43, -15, 22), "", placeholder="Email Address") self.window.sheet.cancel_button = Button((-190, 70, 80, 22), 'Cancel', callback=self.close_sheet) self.window.sheet.create_button = Button( (-95, 70, 80, 22), 'Add', callback=self.create_subscriber) self.window.sheet.setDefaultButton(self.window.sheet.create_button) self.window.sheet.open()
def __init__(self, posSize, index, callback): super(LabelCtrl, self).__init__(posSize) self.callback = callback self.index = index self.jumpingX = 0 self.attachButton = SquareButton((self.jumpingX, 0, self.attachButtonWidth, vanillaControlsSize['EditTextRegularHeight']), 'Attach', sizeStyle='small', callback=self.attachButtonCallback) self.jumpingX += MARGIN_COL + self.attachButtonWidth self.labelNameEdit = EditText((self.jumpingX, 0, self.labelNameEditWidth, vanillaControlsSize['EditTextRegularHeight']), callback=self.labelNameEditCallback) self.jumpingX += MARGIN_COL + self.labelNameEditWidth self.plusButton = SquareButton((self.jumpingX, 0, self.plusButtonWidth, vanillaControlsSize['EditTextRegularHeight']), '+', sizeStyle='small', callback=self.plusButtonCallback) self.jumpingX += MARGIN_COL + self.lessButtonWidth self.lessButton = SquareButton((self.jumpingX, 0, self.lessButtonWidth, vanillaControlsSize['EditTextRegularHeight']), '-', sizeStyle='small', callback=self.lessButtonCallback)
def __init__(self, posSize, attachCallback, labelName=None): super(Label, self).__init__(posSize) self.labelName = labelName self.attachCallback = attachCallback self.edit = EditText((0, 0, NET_WIDTH * .7, vanillaControlsSize['EditTextRegularHeight']), text=self.labelName, continuous=True, callback=self.editCallback) self.button = SquareButton( (NET_WIDTH * .72, 0, NET_WIDTH * .28, vanillaControlsSize['EditTextRegularHeight']), 'attach!', callback=self.buttonCallback)
def __init__( self ): # Window 'self.w': w = 300 h = 300 windowWidthResize = 200 # user can resize width by this value windowHeightResize = 500 # user can resize height by this value self.w = vanilla.FloatingWindow( (w, h ), # default window size "Dimensions", # window title minSize = ( w, h-100 ), # minimum size (for resizing) maxSize = ( w + windowWidthResize, h + windowHeightResize ), # maximum size (for resizing) autosaveName = "com.typetr.Dimensions.mainwindow" # stores last window position and size ) M = 10 y = 30 # UI elements we'll use later self.w.tabWidth = EditText( (M, y, w/4-M-M, 20), "650", sizeStyle='small' ) self.w.tabWidthLabel = TextBox( (w/4, y+4, w/2, 20), "Tab width", sizeStyle='small' ) y += 30 # Checkbox to flag if any drawing should be done by this tools self.w.doDraw = CheckBox((M, y, -M, 24), "Fix errors", value=False, sizeStyle='regular' ) # Open window and focus on it: self.w.bind('close', self.windowCloseCallback) # Make bind in case the window is closed self.w.open() self.w.makeKey() # Establish callbacks that we need for this tool Glyphs.addCallback( self.drawforeground, DRAWFOREGROUND ) Glyphs.addCallback( self.drawbackground, DRAWBACKGROUND )
def __init__(self, callback): super(JumpToLineWindow, self).__init__() self.callback = callback # init the window self.w = FloatingWindow((WINDOW_WIDTH, 0), 'Jump to line') # edit text caption jumpingY = MARGIN_TOP self.w.caption = TextBox((MARGIN_LFT, jumpingY + 3, NET_WIDTH * .6, vanillaControlsSize['TextBoxRegularHeight']), 'Jump to line:') self.w.lineEdit = EditText( (MARGIN_LFT + NET_WIDTH * .6, jumpingY, -MARGIN_RGT, vanillaControlsSize['EditTextRegularHeight']), continuous=False) jumpingY += vanillaControlsSize['EditTextRegularHeight'] + MARGIN_INT self.w.cancelButton = Button( (-(BUTTON_WIDTH * 2 + MARGIN_INT + MARGIN_RGT), jumpingY, BUTTON_WIDTH, vanillaControlsSize['ButtonRegularHeight']), 'Cancel', callback=self.cancelButtonCallback) self.w.okButton = Button( (-(BUTTON_WIDTH + MARGIN_RGT), jumpingY, BUTTON_WIDTH, vanillaControlsSize['ButtonRegularHeight']), 'Ok', callback=self.okButtonCallback) jumpingY += vanillaControlsSize['ButtonRegularHeight'] + MARGIN_BTM self.setUpBaseWindowBehavior() self.w.resize(WINDOW_WIDTH, jumpingY)
def __init__(self, parameter, posSize, title=None, callback=None): super(ParameterSliderTextInput, self).__init__(posSize) self.parameter = parameter self.callback = callback editTextPosSize = (-65, 0, 40, 22) if title is None: sliderPosSize = (5, 3, -80, 15) elif title is not None: if "point" in title: title = title.lstrip("point") title = "p. " + title title = title.capitalize() sliderPosSize = (70, 3, -80, 15) self.title = TextBox((0, 3, 65, 30), title, sizeStyle="small") if parameter.dissociable: editTextPosSize = (-65, 0, 40, 22) self.checkBox = CheckBox((-22, 5, 22, 25), u"∞", callback=self.setFree, value=True, sizeStyle="mini") self.parameter.bind(self.checkBox) self.slider = Slider( sliderPosSize, minValue=parameter.limits[0], maxValue=parameter.limits[1], value=parameter.value, callback=self.valueInput, sizeStyle="small", ) self.textInput = EditText( editTextPosSize, str(parameter.value), callback=self.valueInput, continuous=False, sizeStyle="small" ) self.parameter.bind(self) self.parameter.bind(self.slider) self.parameter.bind(self.textInput)
def __init__(self): self.searchResults = [] self.selectedChars = "" self.w = FloatingWindow((300, 400), "Unicode Picker", minSize=(250, 300), autosaveName="UnicodePicker") y = 15 self.w.searchField = EditText((20, y, -20, 25), placeholder="Search Unicode name or value", callback=self.searchTextChanged_) y += 40 columnDescriptions = [ dict(title="char", width=40, cell=makeTextCell(align="center", font=AppKit.NSFont.systemFontOfSize_(14))), dict(title="unicode", width=60, cell=makeTextCell(align="right")), dict(title="name"), ] self.w.unicodeList = List((0, y, 0, -100), [], columnDescriptions=columnDescriptions, rowHeight=18, selectionCallback=self.listSelectionChanged_, doubleClickCallback=self.listDoubleClickCallback_) y = -95 self.w.unicodeText = TextBox((20, y, -10, 55), "") self.w.unicodeText._nsObject.cell().setFont_(AppKit.NSFont.systemFontOfSize_(36)) self.w.unicodeText._nsObject.cell().setLineBreakMode_(AppKit.NSLineBreakByTruncatingMiddle) y += 55 self.w.copyButton = Button((20, y, 120, 25), "Copy", callback=self.copy_) self.w.copyButton.enable(False) self.w.open() self.w._window.setWindowController_(self) self.w._window.setBecomesKeyOnlyIfNeeded_(False) self.w._window.makeKeyWindow()
def __init__(self): self.w = Window((550, 140), "Replace named Layer") self.w.editText = EditText((10, 15, -10, 22), placeholder="Layer Name", text='{170}') self.w.correct_path_direction = CheckBox((10, 50, -10, 18), "Correct Path Direction", value=True, sizeStyle='small') self.w.sync_metrics = CheckBox((210, 50, -10, 18), "Sync Metrics", value=True, sizeStyle='small') self.w.add_if_missing = CheckBox((10, 70, -10, 18), "Add layer if missing", value=True, sizeStyle='small') self.w.copybutton = Button((10, 100, -10, 17), "Replace layer", callback=self.buttonCallback) self.w.open()
def __init__(self): '''Initialize the dialog.''' x = y = padding = 10 buttonHeight = 20 windowWidth = 400 rows = 4.5 self.w = FloatingWindow( (windowWidth, buttonHeight * rows + padding * (rows)), "Glyph Fax Machine") self.fonts = {} # self.w.textBox = TextBox((x, y, -padding, buttonHeight), "Glyphs to Copy") # y += buttonHeight self.w.editText = EditText( (x, y, -padding, buttonHeight * 2 + padding), placeholder="Space-separated list of glyphs to copy") y += buttonHeight * 2 + padding * 2 # self.w.overwriteGlyphsCheckBox = CheckBox((x, y, -padding, buttonHeight), "Overwrite Glyphs", value=False, callback=self.overwriteGlyphsOptions) # y += buttonHeight + padding self.w.overwriteNormalWidthGlyphsCheckBox = CheckBox( (x, y, -padding, buttonHeight), "Overwrite 600w Glyphs", value=False, sizeStyle="small") # self.w.overwriteNormalWidthGlyphsCheckBox.show(False) self.w.overwriteAdjustedWidthGlyphsCheckBox = CheckBox( (windowWidth * 0.4, y, -padding, buttonHeight), "Overwrite non-600w Glyphs", value=False, sizeStyle="small") # self.w.overwriteAdjustedWidthGlyphsCheckBox.show(False) self.w.colorWell = ColorWell( (windowWidth * 0.85, y, -padding, buttonHeight), color=NSColor.orangeColor()) y += buttonHeight + padding self.w.sans2mono = Button( (x, y, windowWidth / 3 - padding / 2, buttonHeight), "Sans → Mono", callback=self.sans2monoCallback) self.w.mono2sans = Button( (windowWidth / 3 + padding, y, -padding, buttonHeight), "Mono → Sans", callback=self.mono2SansCallback) self.w.open()
def __init__(self, position, label, placeholder=""): super(TextField, self).__init__((position[0], position[1], position[2], 22)) self.label = TextBox((0, 3, self.indent - 10, 22), "{0}:".format(label), alignment="right") self.text = EditText((self.indent, 0, 500 - 40 - self.indent, 22), placeholder=placeholder)
def __init__(self, posSize, sender=None, blenderMode=None, key=None, value=None, idx=0): super().__init__(posSize) self._setupView(self.nsViewClass, posSize) self.sender, self.key, self.value, self.idx = sender, key, value, idx if self.idx > 0: self.separator = HorizontalLine((0, 0, -0, 1)) self.help = HelpButton((0, 10, 21, 20), callback=self._helpCallback) try: docstring[self.key] except: self.help.enable(False) description = TextBox((60, 10, -0, 20), str(self.key)) if isinstance(value, dict): self.description = description # TODO: Recursive evaluation of nested dicts pass elif isinstance(self.value, str) or (isinstance(value, int) and not isinstance(value, bool)): self.description = description self.edit = EditText((10, 40, -0, 20), text=self.value, callback=self._dummyCallback) self.resize(self.getPosSize()[2], 80) elif isinstance(self.value, bool): self.check = CheckBox((60, 10, -0, 20), key, callback=self._dummyCallback, value=self.value) self.resize(self.getPosSize()[2], 40) elif isinstance(self.value, list): values = self.getValues(self.value) self.description = description self.list = List((10, 40, -0, 80), items=self.value, columnDescriptions=None, showColumnTitles=False, allowsEmptySelection=False, allowsMultipleSelection=False, autohidesScrollers=True, drawFocusRing=False) self.list._nsObject.setBorderType_(NSNoBorder) self.resize(self.getPosSize()[2], 120)
def __init__(self, posSize, index, isVertical, isHorizontal, step, gridColor, callback): Group.__init__(self, posSize) # from arguments to attributes self.ctrlX, self.ctrlY, self.ctrlWidth, self.ctrlHeight = posSize self.index = index self.isVertical = isVertical self.isHorizontal = isHorizontal self.step = step self.gridColor = gridColor self.callback = callback # ctrls jumpin_X = 12 self.indexText = TextBox( (jumpin_X, 0, 16, vanillaControlsSize['TextBoxRegularHeight']), '{:d})'.format(index)) jumpin_X += self.indexText.getPosSize()[2] self.stepCtrl = EditText( (jumpin_X, 0, 38, vanillaControlsSize['EditTextRegularHeight']), callback=self.stepCtrlCallback) jumpin_X += self.stepCtrl.getPosSize()[2] + 16 self.isHorizontalCheck = CheckBox( (jumpin_X, 0, 32, vanillaControlsSize['CheckBoxRegularHeight']), "H", value=self.isHorizontal, callback=self.isHorizontalCheckCallback) jumpin_X += self.isHorizontalCheck.getPosSize()[2] + 2 self.isVerticalCheck = CheckBox( (jumpin_X, 0, 32, vanillaControlsSize['CheckBoxRegularHeight']), "V", value=self.isVertical, callback=self.isVerticalCheckCallback) jumpin_X += self.isVerticalCheck.getPosSize()[2] + 10 self.whichColorWell = ColorWell( (jumpin_X, 0, 46, self.ctrlHeight), color=NSColor.colorWithCalibratedRed_green_blue_alpha_(*gridColor), callback=self.whichColorWellCallback)
class TextField(Group): indent = 90 def __init__(self, position, label, placeholder=""): super(TextField, self).__init__((position[0], position[1], position[2], 22)) self.label = TextBox((0, 3, self.indent - 10, 22), "{0}:".format(label), alignment="right") self.text = EditText((self.indent, 0, 500 - 40 - self.indent, 22), placeholder=placeholder) def set(self, *args): return self.text.set(*args) def get(self): return self.text.get()
def __init__(self, font, success_window): self.font = font self.success_window = success_window self.window.family_name_label = TextBox((15, 15, -15, 22), 'Family Name', sizeStyle='small') self.window.family_name = EditText((15, 40, -15, 22), font.info.familyName) self.window.designer_name_label = TextBox((15, 81, -15, 22), 'Designer', sizeStyle='small') self.window.designer_name = EditText((15, 106, -15, 22), font.info.openTypeNameDesigner) self.window.create_button = Button((175, -38, 110, 22), 'Add Font', callback=self.create)
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()
def enterAlternateNumber_(self, sender): self.popover = Popover((140, 80)) self.popover.open(parentView=self, preferredEdge='right') self.popover.label = TextBox((20, 10, -20, 20), "Enter an Alt nr.:") if self.state: value = str(int(self.state)) else: value = "" self.popover.altNumber = EditText((20, 35, -20, 25), value, continuous=False, callback=self.textEnteredCallback_) self.window().makeFirstResponder_(self.popover.altNumber._nsObject)
class TextField(Group): indent = 90 def __init__(self, position, label, placeholder=""): super(TextField, self).__init__( (position[0], position[1], position[2], 22)) self.label = TextBox((0, 3, self.indent - 10, 22), "{0}:".format(label), alignment="right") self.text = EditText((self.indent, 0, 500 - 40 - self.indent, 22), placeholder=placeholder) def set(self, *args): return self.text.set(*args) def get(self): return self.text.get()
def __init__(self, success_window): self.success_window = success_window self.window.introduction = TextBox((15, 15, -15, 22), 'Sign in with your Ghostlines account.', sizeStyle='small') self.window.email_label = TextBox((15, 44, -15, 22), 'Email:', sizeStyle='small') self.window.email_field = EditText((15, 61, -15, 22)) self.window.password_label = TextBox((15, 101, -15, 22), 'Password:'******'small') self.window.password_field = SecureEditText((15, 119, -15, 22)) self.window.need_account_button = Button((15, -35, 110, 17), 'Need Account?', callback=self.make_account, sizeStyle="small") self.window.sign_in_button = Button((175, -38, 110, 22), 'Sign In', callback=self.sign_in) self.window.setDefaultButton(self.window.sign_in_button)
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()
def __init__(self): self.glyph = None # Typical RoboFont function self.updating = False pad = 10 leading = 32 y = pad w = 500 h = 500 c1 = 150 c2 = 200 bh = 24 # Button height leading = bh + pad / 2 self.w = Window((100, 100, w, h), 'Final tool window', minSize=(w, h)) self.w.fontList = List((pad, pad, c2, -w / 2), [], doubleClickCallback=self.openFontCallback, selectionCallback=self.update) y = pad self.w.fixTabWidths = Button((-c1 - pad, y, c1, bh), 'Fix tab widths', callback=self.fixTabWidthsCallback) self.w.fixTabWidths.enable(False) y += leading self.w.fixNegativeWidths = Button( (-c1 - pad, y, c1, bh), 'Fix negative widths', callback=self.fixNegativeWidthsCallback) self.w.fixNegativeWidths.enable(False) y += leading self.w.fixMissingComponentsWidths = Button( (-c1 - pad, y, c1, bh), 'Fix missing components', callback=self.fixMissingComponentCallback) self.w.fixMissingComponentsWidths.enable(False) self.w.selectFolder = Button((-c1 - pad, -pad - bh, c1, bh), 'Select fonts', callback=self.selectFontFolder) self.w.canvas = Canvas((pad, -w / 2 - pad, -pad, -w / 4), delegate=self) self.w.report = EditText((pad, -w / 4 + pad, -pad, -pad), readOnly=False) self.w.bind('close', self.windowCloseCallback) self.w.open() self.dirPath = self.selectFontFolder()
def add_recipient(self, sender): self.window.sheet = Sheet((250, 89), self.window) self.window.sheet.recipient = EditText((15, 15, -15, 22), "", placeholder="Email Address") self.window.sheet.cancel_button = Button((-190, 52, 80, 22), 'Cancel', callback=self.close_sheet) self.window.sheet.create_button = Button( (-95, 52, 80, 22), 'Add', callback=self.create_recipient) self.window.sheet.setDefaultButton(self.window.sheet.create_button) self.window.sheet.open()
class SliderGroup(Group): def __init__(self, posSize, minValue, maxValue, value, callback): Group.__init__(self, posSize) self.slider = Slider( (2, 3, -55, 17), minValue=minValue, maxValue=maxValue, value=value, sizeStyle="regular", callback=self.sliderChanged) self.edit = EditText( (-40, 0, -0, 22), text=str(value), placeholder=str(value), callback=self.editChanged) self.callback = callback def sliderChanged(self, sender): self.edit.set(str(int(self.slider.get()))) self.callback(sender) def editChanged(self, sender): try: value = int(float(self.edit.get())) except ValueError: value = int(self.edit.getPlaceholder()) self.edit.set(value) self.slider.set(value) self.callback(sender)
def __init__(self, posSize, callbackAttrs, placeCallback, deleteCallback): super(AnchorsCtrls, self).__init__(posSize) self.callbackAttrs = callbackAttrs self.placeCallback = placeCallback self.deleteCallback = deleteCallback x, y, width, height = posSize jumpinY = 0 self.heightCaption = TextBox( (32, jumpinY, width / 2., vanillaControlsSize['TextBoxRegularHeight']), 'Height:') self.heightEdit = EditText( (width / 2., jumpinY, width / 2., vanillaControlsSize['EditTextRegularHeight']), continuous=False, callback=self.heightEditCallback) jumpinY += self.heightEdit.getPosSize()[3] + MARGIN_ROW self.nameCaption = TextBox( (32, jumpinY, width / 2., vanillaControlsSize['TextBoxRegularHeight']), 'Anchor:') self.nameCombo = ComboBox( (width / 2., jumpinY, width / 2., vanillaControlsSize['ComboBoxRegularHeight']), ['top', '_top', 'bottom', '_bottom'], callback=self.nameComboCallback) jumpinY += self.nameCombo.getPosSize()[3] + MARGIN_ROW * 2 self.placeButton = Button((0, jumpinY, width * .45, vanillaControlsSize['ButtonRegularHeight']), 'Place', callback=self.placeButtonCallback) self.deleteButton = Button( (width * .55, jumpinY, width * .45, vanillaControlsSize['ButtonRegularHeight']), 'Delete', callback=self.deleteButtonCallback)
def __init__(self): self.valuesPrefsKey = prefsKey + ".delta." + basename( Glyphs.font.filepath) # UI metrics spacing = 8 height = 22 # calculate window height minWinSize = (220, 120 + (len(Glyphs.font.masters) * (height + spacing))) # create UI window self.w = FloatingWindow(minWinSize, "Adjust sidebearings", minSize=minWinSize, maxSize=(500, 500), autosaveName=prefsKey + ".win") # layout UI controls y = 16 self.w.label = TextBox((16, y, -16, height), "Sidebearing delta adjustment:") y += height + spacing inputWidth = 64 for master in Glyphs.font.masters: setattr(self.w, "deltaLabel%s" % master.id, TextBox((16, y, -16 - inputWidth, height), master.name)) setattr(self.w, "deltaInput%s" % master.id, EditText((-16 - inputWidth, y, -16, height), "16")) # print("self.w.deltaInputs[master.id]", getattr(self.w, "deltaInput%s" % master.id)) y += height + spacing self.w.submitButton = Button((16, -16 - height, -16, height), "Adjust all sidebearings", callback=self.onSubmit) # finalize UI self.w.setDefaultButton(self.w.submitButton) self.loadPreferences() self.w.bind("close", self.savePreferences) # make sure window is large enough to show all masters x, y, w, h = self.w.getPosSize() if w < minWinSize[0] and h < minWinSize[1]: self.w.setPosSize((x, y, minWinSize[0], minWinSize[1]), animate=False) elif w < minWinSize[0]: self.w.setPosSize((x, y, minWinSize[0], h), animate=False) elif h < minWinSize[1]: self.w.setPosSize((x, y, w, minWinSize[1]), animate=False) self.w.open() self.w.makeKey()
class SliderGroup(Group): def __init__(self, posSize, text, minValue, maxValue, value, callback): Group.__init__(self, posSize) self.text = TextBox((0, 0, -0, 20), text) self.slider = Slider((2, 20, -60, 17), minValue=minValue, maxValue=maxValue, value=value, sizeStyle="small", callback=self.sliderChanged) self.edit = EditText((-40, 15, -0, 22), text=str(value), placeholder=str(value), callback=self.editChanged) self.callback = callback def sliderChanged(self, sender): self.edit.set(str(int(self.slider.get()))) self.callback(sender) def editChanged(self, sender): try: value = int(float(self.edit.get())) except ValueError: value = int(self.edit.getPlaceholder()) self.edit.set(value) self.slider.set(value) def enable(self): self.text.enable(True) self.slider.enable(True) self.edit.enable(True) def disable(self): self.text.enable(False) self.slider.enable(False) self.edit.enable(False)
def __init__(self, posSize, label, minValue, value, maxValue, continuous=True, callback=None): super().__init__(posSize) self._callback = callback self.label = TextBox((0, 0, 0, 20), label) self.slider = Slider((0, 18, -60, 20), value=minValue, minValue=minValue, maxValue=maxValue, continuous=continuous, callback=self._sliderCallback) self.editField = EditText((-50, 16, 0, 24), "", continuous=False, callback=self._editFieldCallback) self.editField._nsObject.setAlignment_(AppKit.NSRightTextAlignment) self._setSliderFromValue(value) self._setEditFieldFromValue(value)
def __init__(self, posSize, minValue, maxValue, value, callback): Group.__init__(self, posSize) self.slider = Slider( (2, 3, -55, 17), minValue=minValue, maxValue=maxValue, value=value, sizeStyle="regular", callback=self.sliderChanged) self.edit = EditText( (-40, 0, -0, 22), text=str(value), placeholder=str(value), callback=self.editChanged) self.callback = callback
def __init__(self): self.font_order = [] self.position = "left" L = 0 # left T = 0 # top W = 200 # width H = 300 # height p = 10 # padding buttonHeight = 20 title = "☎️ Hotline Glyph" self.w = Window((W, H), title, minSize=(W/3, H/3)) self.w.fileList = List( (L, T, -0, -(p * 3 + buttonHeight * 2)), self.font_order, columnDescriptions=[ {"title": "✓", "width":20}, {"title": "File name"}, ], # files showColumnTitles=False, allowsMultipleSelection=True, enableDelete=True, otherApplicationDropSettings = dict( type=NSFilenamesPboardType, operation=NSDragOperationCopy, callback=self.dropCallback), dragSettings=dict(type="RangeType", callback=self.font_list_drag_callback), selfDropSettings=dict(type="RangeType", operation=NSDragOperationMove, callback=self.font_list_drop_callback) ) self.w.editText = EditText((p, -(p * 2 + buttonHeight * 2), -p, buttonHeight)) self.w.draw = CheckBox((p, -(p + buttonHeight), -p, buttonHeight), 'show', value=True, callback=self.updateViewCallback) self.w.toLeftbutton = SquareButton((-p*6, -(p + buttonHeight), p*2, buttonHeight), "←", sizeStyle='small', callback=self.toLeft) self.w.toRightbutton = SquareButton((-p*3, -(p + buttonHeight), p*2, buttonHeight), "➝", sizeStyle='small', callback=self.toRight) addObserver(self, "drawPreviewRef", "drawBackground") addObserver(self, "drawRef", "drawPreview") self.setUpBaseWindowBehavior() # Needed for the windowCloseCallback self.w.open()
def __init__(self, parameter, posSize, title=None, callback=None): super(ParameterSliderTextInput, self).__init__(posSize) self.parameter = parameter self.callback = callback editTextPosSize = (-45, 0, 45, 22) if title is None: sliderPosSize = (5, 3, -80, 15) elif title is not None: if len(title) > 15: title = '{0}.'.format(title[:16]) title = title.capitalize() sliderPosSize = (120, 3, -55, 15) self.title = TextBox((0, 3, 115, 30), title, sizeStyle='small') if parameter.dissociable: editTextPosSize = (-65, 0, 40, 22) self.checkBox = CheckBox((-22, 5, 22, 25), u'∞', callback=self.setFree, value=True, sizeStyle='mini') self.slider = Slider(sliderPosSize, minValue=parameter.limits[0], maxValue=parameter.limits[1], value=parameter.value, callback=self.valueInput, sizeStyle='small') self.textInput = EditText(editTextPosSize, str(parameter.value), callback=self.valueInput, continuous=False, sizeStyle='small') self.parameter.bind(self)
class ParameterSliderTextInput(Group): """ Custom Vanilla object consisting mainly of a Slider & and text input linked together (through a parameter object) """ def __init__(self, parameter, posSize, title=None, callback=None): super(ParameterSliderTextInput, self).__init__(posSize) self.parameter = parameter self.callback = callback editTextPosSize = (-65, 0, 40, 22) if title is None: sliderPosSize = (5, 3, -80, 15) elif title is not None: if "point" in title: title = title.lstrip("point") title = "p. " + title title = title.capitalize() sliderPosSize = (70, 3, -80, 15) self.title = TextBox((0, 3, 65, 30), title, sizeStyle="small") if parameter.dissociable: editTextPosSize = (-65, 0, 40, 22) self.checkBox = CheckBox((-22, 5, 22, 25), u"∞", callback=self.setFree, value=True, sizeStyle="mini") self.parameter.bind(self.checkBox) self.slider = Slider( sliderPosSize, minValue=parameter.limits[0], maxValue=parameter.limits[1], value=parameter.value, callback=self.valueInput, sizeStyle="small", ) self.textInput = EditText( editTextPosSize, str(parameter.value), callback=self.valueInput, continuous=False, sizeStyle="small" ) self.parameter.bind(self) self.parameter.bind(self.slider) self.parameter.bind(self.textInput) def enable(self, b): self.slider.enable(b) self.textInput.enable(b) if hasattr(self, checkBox): self.checkBox.enable(b) def valueInput(self, sender): value = sender.get() parameter = self.parameter if value == "R": parameter.reset() parameter.update() if self.callback is not None: self.callback(self) return elif value != "*": parameter.setInput(value, sender=sender) parameter.update() if self.callback is not None: self.callback(self) def setFree(self, sender): value = bool(sender.get()) self.parameter.setFree(value)
class ParameterSliderTextInput(Group): ''' Custom Vanilla object consisting mainly of a Slider & and text input linked together (through a parameter object) ''' def __init__(self, parameter, posSize, title=None, callback=None): super(ParameterSliderTextInput, self).__init__(posSize) self.parameter = parameter self.callback = callback editTextPosSize = (-45, 0, 45, 22) if title is None: sliderPosSize = (5, 3, -80, 15) elif title is not None: if len(title) > 15: title = '{0}.'.format(title[:16]) title = title.capitalize() sliderPosSize = (120, 3, -55, 15) self.title = TextBox((0, 3, 115, 30), title, sizeStyle='small') if parameter.dissociable: editTextPosSize = (-65, 0, 40, 22) self.checkBox = CheckBox((-22, 5, 22, 25), u'∞', callback=self.setFree, value=True, sizeStyle='mini') self.slider = Slider(sliderPosSize, minValue=parameter.limits[0], maxValue=parameter.limits[1], value=parameter.value, callback=self.valueInput, sizeStyle='small') self.textInput = EditText(editTextPosSize, str(parameter.value), callback=self.valueInput, continuous=False, sizeStyle='small') self.parameter.bind(self) def get(self): return self.parameter.get() def enable(self, b): self.slider.enable(b) self.textInput.enable(b) if hasattr(self, checkBox): self.checkBox.enable(b) def valueInput(self, sender): value = sender.get() parameter = self.parameter if value == 'R': parameter.reset() parameter.update() if self.callback is not None: self.callback(self) return elif value != '*': parameter.setInput(value, sender=sender) parameter.update() if self.callback is not None: self.callback(self) def update(self, sender): value = self.parameter.get() self.textInput.set(str(value)) if (value != '*'): self.slider.set(value) if hasattr(self, 'checkBox'): free = self.parameter.hasMaster self.checkBox.set(free) def setFree(self, sender): value = not bool(sender.get()) self.parameter.setFree(value)
class ParameterTextInput(Group): def __init__(self, parameter, posSize, text='', callback=None, continuous=False, showRelativeValue=False): super(ParameterTextInput, self).__init__(posSize) self.parameter = parameter rel = self._relValue() self.callback = callback self.textInput = EditText((0, 0, -40, -0), text=text, callback=self._valueInput, continuous=continuous) self.relInfo = TextBox((-35, 5, -0, -0), rel, alignment='left', sizeStyle='small') self.showRelativeValue(showRelativeValue) self.vanillaInputs = [self.textInput] self.parameter.bind(self) def get(self): return self.parameter.get() def enable(self, value): for item in self.vanillaInputs: item.enable(value) def _valueInput(self, sender): value = sender.get() parameter = self.parameter if value == 'R' and parameter.hasMaster: parameter.reset() parameter.update() if self.callback is not None: self.callback(parameter) return elif value != '*': parameter.setInput(value, sender=sender) parameter.update() if self.callback is not None: self.callback(parameter) rel = self._relValue() self.relInfo.set(rel) def showRelativeValue(self, b): self.relInfo.show(b) def setFree(self, sender): value = bool(sender.get()) self.parameter.setFree(value) def update(self, sender): value = self.parameter.get() self.textInput.set(str(value)) self._updateRelValue() def _updateRelValue(self): rel = self._relValue() self.relInfo.set(rel) def _relValue(self): parameter = self.parameter rel = '-' if parameter.hasMaster: if parameter.mode == 'ratio': rel = '%s' % (parameter.getRatio()) elif parameter.mode == 'offset': offsetValue = int(parameter.getOffset()) sign = '+' if offsetValue >= 0 else '' rel = '%s%s' % (sign, offsetValue) return rel