def __init__(self): """Initialize word-o-mat UI, open the window.""" # load stuff self.loadPrefs() self.loadDictionaries() # Observers for font events addObserver(self, lambda: self.g1.base.enable(True), "fontDidOpen") addObserver(self, "fontClosed", "fontWillClose") # The rest of this method is just building the window / interface self.w = Window((250, 414), 'word-o-mat', minSize=(250, 111), maxSize=(250, 436)) padd, bPadd = 12, 3 groupW = 250 - 2 * padd # Panel 1 - Basic Settings self.g1 = Group((padd, 8, groupW, 104)) topLineFields = { "wordCount": [0, self.wordCount, 20], "minLength": [108, self.minLength, 3], "maxLength": [145, self.maxLength, 10], } topLineLabels = { "wcText": [31, 78, 'words with', 'left'], "lenTextTwo": [133, 10, u'–', 'center'], "lenTextThree": [176, -0, 'letters', 'left'], } for label, values in topLineFields.iteritems(): setattr( self.g1, label, EditText((values[0], 0, 28, 22), text=values[1], placeholder=str(values[2]))) for label, values in topLineLabels.iteritems(): setattr( self.g1, label, TextBox((values[0], 3, values[1], 22), text=values[2], alignment=values[3])) # language selection languageOptions = list(self.languageNames) languageOptions.extend( ["OSX Dictionary", "Any language", "Custom wordlist..."]) self.g1.source = PopUpButton((0, 32, 85, 20), [], sizeStyle="small", callback=self.changeSourceCallback) self.g1.source.setItems(languageOptions) self.g1.source.set(int(self.source)) # case selection caseList = [ u"don’t change case", "make lowercase", "Capitalize", "ALL CAPS" ] self.g1.case = PopUpButton((87, 32, -0, 20), caseList, sizeStyle="small") self.g1.case.set(self.case) # character set charsetList = [ "Use any characters", "Use characters in current font", "Use only selected glyphs", "Use only glyphs with mark color:" ] self.g1.base = PopUpButton((0, 61, -0, 20), charsetList, callback=self.baseChangeCallback, sizeStyle="small") if not CurrentFont(): self.g1.base.set(0) # Use any self.g1.base.enable(False) # Disable selection else: if self.limitToCharset == False: self.g1.base.set(0) # Use any else: self.g1.base.set(1) # Use current font # mark color selection self.g1.colorWell = NoneTypeColorWell((-22, 61, -0, 22)) self.g1.colorWell.set(None) # populate from prefs if self.reqMarkColor is not "None": # initial pref try: r, g, b, a = self.reqMarkColor savedColor = NSColor.colorWithCalibratedRed_green_blue_alpha_( r, g, b, a) self.g1.colorWell.set(savedColor) except TypeError: pass if self.g1.base.get() != 3: self.g1.colorWell.show(0) # Panel 2 - Match letters self.g2 = Group((0, 2, 250, 172)) # Match mode selection matchBtnItems = [ dict(width=40, title="Text", enabled=True), dict(width=120, title="GREP pattern match", enabled=True) ] self.g2.matchMode = SegmentedButton( (50, 5, -0, 20), matchBtnItems, callback=self.switchMatchModeCallback, sizeStyle="small") rePanelOn = 1 if self.matchMode == "grep" else 0 self.g2.matchMode.set(rePanelOn) # Text/List match mode self.g2.textMode = Box((padd, 29, -padd, 133)) labelY = [2, 42] labelText = [ "Require these letters in each word:", "Require one per group in each word:" ] for i in range(2): setattr( self.g2.textMode, "reqLabel%s" % i, TextBox((bPadd, labelY[i], -bPadd, 22), labelText[i], sizeStyle="small")) self.g2.textMode.mustLettersBox = EditText( (bPadd + 2, 18, -bPadd, 19), text=", ".join(self.requiredLetters), sizeStyle="small") ### consider using a subclass that allows copy-pasting of glyphs to glyphnames y2 = 37 attrNameTemplate = "group%sbox" for i in range(3): j = i + 1 y2 += 20 optionsList = [ "%s: %s" % (key, ", ".join(value)) for key, value in self.groupPresets ] if len(self.requiredGroups[i] ) > 0 and self.requiredGroups[i][0] != "": optionsList.insert( 0, "Recent: " + ", ".join(self.requiredGroups[i])) attrName = attrNameTemplate % j setattr( self.g2.textMode, attrName, ComboBox((bPadd + 2, y2, -bPadd, 19), optionsList, sizeStyle="small")) groupBoxes = [ self.g2.textMode.group1box, self.g2.textMode.group2box, self.g2.textMode.group3box ] for i in range(3): if len(self.requiredGroups[i] ) > 0 and self.requiredGroups[i][0] != "": groupBoxes[i].set(", ".join(self.requiredGroups[i])) # RE match mode self.g2.grepMode = Box((padd, 29, -padd, 133)) self.g2.grepMode.label = TextBox((bPadd, 2, -bPadd, 22), "Regular expression to match:", sizeStyle="small") self.g2.grepMode.grepBox = EditText((bPadd + 2, 18, -bPadd, 19), text=self.matchPattern, sizeStyle="small") splainstring = u"This uses Python’s internal re parser.\nExamples:\nf[bhkl] = words with f followed by b, h, k, or l\n.+p.+ = words with p inside them\n^t.*n{2}$ = words starting with t, ending in nn" self.g2.grepMode.explainer = TextBox((bPadd, 42, -bPadd, 80), splainstring, sizeStyle="mini") self.g2.grepMode.refButton = Button((bPadd, 108, -bPadd, 14), "go to syntax reference", sizeStyle="mini", callback=self.loadREReference) self.g2.grepMode.show(0) self.toggleMatchModeFields() # switch to text or grep panel depending # Panel 3 - Options self.g3 = Group((padd, 5, groupW, 48)) self.g3.checkbox0 = CheckBox((bPadd, 2, 18, 18), "", sizeStyle="small", value=self.banRepetitions) self.g3.checkLabel = TextBox((18, 4, -bPadd, 18), "No repeating characters per word", sizeStyle="small") self.g3.listOutput = CheckBox((bPadd, 18, 18, 18), "", sizeStyle="small") self.g3.listLabel = TextBox((18, 20, -bPadd, 18), "Output as list sorted by width", sizeStyle="small") # Display Accordion View accItems = [ dict(label="Basic settings", view=self.g1, size=104, collapsed=False, canResize=False), dict(label="Specify required letters", view=self.g2, size=173, collapsed=False, canResize=False), dict(label="Options", view=self.g3, size=48, collapsed=False, canResize=False) ] self.w.panel1 = Group((0, 0, 250, -35)) self.w.panel1.accView = AccordionView((0, 0, -0, -0), accItems) self.w.submit = Button((padd, -30, -padd, 22), 'make words!', callback=self.makeWords) self.w.bind("close", self.windowClose) self.w.setDefaultButton(self.w.submit) self.w.open()
def __init__(self): self.windowWidth, self.windowHeight = 1000,600 self.w = Window((self.windowWidth, self.windowHeight), "Robo CJK", minSize = (300,300), maxSize = (2500,2000)) self.font = CurrentFont() self.glyph = CurrentGlyph() self.glyphset = list() self.font2Storage = dict() self.layerList = list() self.glyphsSetDict = dict() self.newDeepComponent_active = False self.temp_DeepCompo_slidersValuesList = [] self.temp_DeepComponents = {} self.activeMaster = True self.deepCompoWillDrag = False self.currentGlyph_DeepComponents = { 'CurrentDeepComponents':{}, 'Existing':{}, 'NewDeepComponents':{}, } self.deepCompo_DeltaX, self.deepCompo_DeltaY = 0, 0 self.current_DeepComponent_selection = None self.selectedCompositionGlyphName = "" self.selectedVariantName = "" toolbarItems = [ { 'itemIdentifier': "saveUFO(s)", 'label': 'Save UFO(s)', 'callback': self._saveUFOs_callback, 'imagePath': SavePDF }, { 'itemIdentifier': "testInstall", 'label': 'Test Install', 'callback': self._testInstall_callback, 'imagePath': TestInstallPDF }, { 'itemIdentifier': NSToolbarFlexibleSpaceItemIdentifier, }, { 'itemIdentifier': "textCenter", 'label': 'Text Center', 'callback': self._textCenter_callback, 'imagePath': TextCenterPDF }, { 'itemIdentifier': "mastersOverview", 'label': 'Masters Overview', 'callback': self._textCenter_callback, 'imagePath': MastersOverviewPDF }, { 'itemIdentifier': NSToolbarFlexibleSpaceItemIdentifier, }, { 'itemIdentifier': "projectEditor", 'label': 'Projects Editor', 'callback': self._projectsSettings_callback, 'imagePath': ProjectEditorPDF }, { 'itemIdentifier': "preference", 'label': 'Preference', 'callback': self._preference_callback, 'imagePath': PreferencesPDF, }, ] self.w.addToolbar("DesignSpaceToolbar", toolbarItems) self.project_popUpButton_list = ["Load a project..."] self.w.projects_popUpButton = PopUpButton((10,10,-10,20), self.project_popUpButton_list, callback = self._projects_popUpButton_callback) segmentedElements = ["Active Master", "Deep Components Editor"] self.w.main_segmentedButton = SegmentedButton((10,40,-180,20), [dict(title=e, width = (self.windowWidth-224)/len(segmentedElements)) for e in segmentedElements], callback = self._main_segmentedButton_callback, sizeStyle='regular') self.w.main_segmentedButton.set(0) self.getCompositionGlyph() self.w.activeMasterGroup = Group((10,70,-205,-20)) self.w.deepComponentsEditorGroup = Group((10,70,-205,-20)) self.w.deepComponentsEditorGroup.show(0) ####### GLYPHSET ####### self.w.activeMasterGroup.glyphSet = GlyphSet((225,0,-0,-200), self) ####### GLYPHSET ####### self.w.activeMasterGroup.glyphData = GlyphData((0,180,215,-0), self) self.w.activeMasterGroup.DeepComponentsInstantiator = DeepComponentsInstantiator((225,-190,-0,-0), self) # self.w.deepComponentsEditorGroup.fontsGroup = Fonts((0,0,215,170), self) self.w.deepComponentsEditorGroup.Layers = Layers((0,150,215,-0), self) self.w.deepComponentsEditorGroup.GlyphLayers = GlyphLayers((225,0,-0,-0), self) ####### MINIFONT GROUP ####### # self.minifonts = MiniFonts((0,0,-0,-0), self) ####### REFERENCE VIEWER ####### self.referenceViewer = ReferenceViewer((0,0,-0,-0), self) ###### DESIGN FRAMES ###### self.designFrame = DesignFrame((0,0,-0,-0), self) ####### FONT GROUP ####### self.w.fontsGroup = Fonts((10,70,215,170), self) ###### ACCORDION VIEW ###### self.accordionViewDescriptions = [ dict(label="Reference Viewer", view=self.referenceViewer, size=55, collapsed=True, canResize=0), dict(label="Design Frame", view=self.designFrame, size=173, collapsed=False, canResize=0), ] self.w.accordionView = AccordionView((-200, 40, -0, -20), self.accordionViewDescriptions, backgroundColor=NSColor.colorWithCalibratedRed_green_blue_alpha_(1, 1, 1, 1)) ###### DARK MODE ###### self.darkMode = 1 Helpers.setDarkMode(self.w, self.darkMode) self.w.darkMode_checkBox = CheckBox((10,-20,-10,-0), "Dark Mode", sizeStyle = "small", value = self.darkMode, callback = self._darkMode_checkBox_checkBox) ###### OFF TOOLS ###### PowerRuler.Ruler(self) BalanceHandles.BalanceHandles(self) OpenSelectedComponent.OpenSelectedComponent(self) self.smartSelector = SmartSelector(self) installTool(self.smartSelector) ###### OBSERVER ###### self.observer() self.w.bind('close', self.windowWillClose) self.w.bind('resize', self.windowDidResize) ###### LAUNCH WINDOW ###### self.w.open()
def __init__(self): h = 530 self.w = Window((300, h), "Batch", minSize=(300, 400)) toolbarItems = [ dict( itemIdentifier="open", label="Open", imageNamed="toolbarScriptOpen", callback=self.toolbarOpen, ), dict( itemIdentifier="addOpenFonts", label="Add Open Fonts", imageNamed="toolbarScriptNew", callback=self.toolbarAddOpenFonts, ), dict(itemIdentifier=NSToolbarFlexibleSpaceItemIdentifier), dict( itemIdentifier="Help", label="Help", imageNamed="toolbarDefaultPythonAppUnknow", callback=self.toolbarHelp, ), dict( itemIdentifier="settings", label="Settings", imageNamed="prefToolbarMisc", callback=self.toolbarSettings, ), ] self.w.addToolbar(toolbarIdentifier="ToolBoxToolbar", toolbarItems=toolbarItems, addStandardItems=False) y = 10 columnDescriptions = [ dict(title="path", key="path", formatter=PathFormatter.alloc().init()), ] self.paths = List( (0, 0, -0, -0), [], columnDescriptions=columnDescriptions, showColumnTitles=False, allowsMultipleSelection=True, enableDelete=True, dragSettings=dict(type=genericListPboardType, callback=self.dragCallback), selfDropSettings=dict(type=genericListPboardType, operation=NSDragOperationMove, callback=self.selfDropCallback), selfApplicationDropSettings=dict(type=NSFilenamesPboardType, operation=NSDragOperationCopy, callback=self.dropPathCallback), otherApplicationDropSettings=dict(type=NSFilenamesPboardType, operation=NSDragOperationCopy, callback=self.dropPathCallback), ) y += 200 self.webFormats = WebFormats((0, 0, -0, -0), self) self.batchGenerate = BatchGenerate((0, 0, -0, -0), self) self.binaryMerger = BinaryMerger((0, 0, -0, -0), self, self.batchGenerate.run) self.batchVariableFontGenerate = BatchVariableFontGenerate( (0, 0, -0, -0), self) descriptions = [ dict(label="Fonts", view=self.paths, minSize=50, size=200, canResize=True, collapsed=False), dict(label="Web Fonts", view=self.webFormats, size=self.webFormats.height, canResize=False, collapsed=False), dict(label="Batch Generate", view=self.batchGenerate, size=self.batchGenerate.height, canResize=False, collapsed=False), dict(label="Variable Fonts", view=self.batchVariableFontGenerate, size=self.batchVariableFontGenerate.height, canResize=False, collapsed=False), dict(label="Binary Merge", view=self.binaryMerger, size=240, canResize=self.binaryMerger.height, collapsed=False), ] self.w.accordionView = AccordionView((0, 0, -0, -0), descriptions) self.setUpBaseWindowBehavior() self.w.open()
def __init__(self): super(DrawingAssistant, self).__init__() # collect currentGlyph (if available) self.currentGlyph = CurrentGlyph() # collect opened fonts if AllFonts(): self.collectOpenedFontPaths() # init fonts if self.openedFontPaths: self._initFontsAndGlyphs() # init views self.bcpController = BcpController( (MARGIN_HOR, 0, NET_WIDTH, vanillaControlsSize['CheckBoxRegularHeight'] * 2.5), sqrActive=self.sqrActive, bcpLengthActive=self.bcpLengthActive, callback=self.bcpControllerCallback) self.gridController = MultipleGridController( (MARGIN_HOR, 0, NET_WIDTH, 220), gridActive=self.gridActive, ctrlsAmount=5, activeCtrls=0, offgridActive=self.offgridActive, callback=self.gridControllerCallback) self.distancesController = DistancesController( (MARGIN_HOR, 0, NET_WIDTH, 160), stemActive=self.stemActive, diagonalActive=self.diagonalActive, currentGlyph=self.currentGlyph, callback=self.distancesControllerCallback) self.neighborsController = NeighborsController( (MARGIN_HOR, 0, NET_WIDTH, 94), openedFontPaths=self.openedFontPaths, lftNeighborActive=self.lftNeighborActive, lftFontPath=self.lftFontPath, lftGlyphName=self.lftGlyphName, cntNeighborActive=self.cntNeighborActive, cntFontPath=self.cntFontPath, cntGlyphName=self.cntGlyphName, rgtNeighborActive=self.rgtNeighborActive, rgtFontPath=self.rgtFontPath, rgtGlyphName=self.rgtGlyphName, callback=self.neighborsControllerCallback) # collect views accordionItems = [ { 'label': 'bcp controller', 'view': self.bcpController, 'size': self.bcpController.ctrlHeight, 'collapsed': False, 'canResize': False }, { 'label': 'grid controller', 'view': self.gridController, 'size': self.gridController.ctrlHeight, 'collapsed': False, 'canResize': False }, { 'label': 'distances controller', 'view': self.distancesController, 'size': self.distancesController.ctrlHeight, 'collapsed': False, 'canResize': False }, { 'label': 'neighbors controller', 'view': self.neighborsController, 'size': self.neighborsController.ctrlHeight, 'collapsed': False, 'canResize': False }, ] # init window with accordion obj totalHeight = self.bcpController.ctrlHeight + self.gridController.ctrlHeight + self.distancesController.ctrlHeight + self.neighborsController.ctrlHeight + 18 * 4 self.w = FloatingWindow((0, 0, PLUGIN_WIDTH, totalHeight), PLUGIN_TITLE, minSize=(PLUGIN_WIDTH, 200), maxSize=(PLUGIN_WIDTH, totalHeight + 10)) self.w.accordionView = AccordionView((0, 0, -0, -0), accordionItems) # add observers addObserver(self, "_draw", "draw") addObserver(self, "_draw", "drawInactive") addObserver(self, "_drawPreview", "drawPreview") addObserver(self, "_mouseDown", "mouseDown") addObserver(self, "_drawBackground", "drawBackground") addObserver(self, "_updateCurrentFont", "fontBecameCurrent") addObserver(self, '_updateCurrentGlyph', 'viewDidChangeGlyph') addObserver(self, "aFontIsOpening", "newFontDidOpen") addObserver(self, "aFontIsOpening", "fontDidOpen") addObserver(self, "aFontIsClosing", "fontWillClose") self.setUpBaseWindowBehavior() # open window self.w.open()
def __init__(self, RCJKI): self.RCJKI = RCJKI self.w = Window((800, 300), "Text Center", minSize = (400, 320)) self.w.leftInput = EditText( (0, 0, 60, 20), "", callback = self.inputCallback ) self.w.input = EditText( (60, 0, -60, 20), "", callback = self.inputCallback ) self.pointsSize = [9, 10, 11, 12, 14, 16, 18, 20, 24, 30, 36, 48, 60, 72, 96, 144, 256, 512, 1024], self.w.pointSize = ComboBox( (-60, 0, -0, 20), *self.pointsSize, callback = self.pointSizeCallback ) self.w.pointSize.set(72) self.displayOptions = { 'displayMode': 'Multi Line', # 'Show Kerning': True, 'Multi Line': True, # 'xHeight Cut': False, 'Water Fall': False, # 'Single Line': True, # 'Inverse': False, 'Show Metrics': False, 'Left to Right': True, 'Right to Left': False, 'Center': False, # 'Upside Down': False, 'Stroke': False, 'Fill': False, 'Beam': False, 'Guides': False, 'Blues': False, 'Family Blues': False, 'Show Control glyphs': True, 'Show Space Matrix': True, 'Show Template Glyphs': True, 'showLayers': [] } self.w.multiLineView = MultiLineView( (200, 20, -0, -0), pointSize=72, displayOptions = self.displayOptions ) self.w.multiLineView.setFont(self.RCJKI.currentFont._fullRFont) self.w.multiLineView.setLineHeight(200) self.sourcesList = [] if self.RCJKI.currentFont.fontVariations: self.sourcesList = [dict(Axis = x, PreviewValue = 0) for x in self.RCJKI.currentFont.fontVariations] slider = SliderListCell(minValue = 0, maxValue = 1) self.w.sourcesList = List( (0, 20, 200, 90), self.sourcesList, columnDescriptions = [ {"title": "Axis", "editable": False, "width": 60}, {"title": "PreviewValue", "cell": slider}], showColumnTitles = False, editCallback = self.sourcesListEditCallback, allowsMultipleSelection = False ) self.accordionViewDescriptions = [ dict(label="Display options", view=displayModeGroup((0, 0, -0, -0), self), size=100, collapsed=True, canResize=0), dict(label="Glyphs that use:", view=GlyphUsingDC((0, 0, -0, -0), self), size=180, collapsed=True, canResize=1), dict(label="Deep components that use:", view=DCUsingAE((0, 0, -0, -0), self), size=180, collapsed=True, canResize=1), ] self.w.accordionView = AccordionView((0, 120, 200, -0), self.accordionViewDescriptions, ) self.observer() self.w.open() self.w.bind("close", self.windowWillClose)
def __init__(self): self.w = FloatingWindow( (self.width, self.height), title='tempEdit', minSize=(self.width*0.9, self.width*0.5)) self.designspaces = Group((0, 0, -0, -0)) x = y = p = self.padding self.designspaces.list = List( (x, y, -p, -p), [], allowsMultipleSelection=False, allowsEmptySelection=False, # editCallback=self.selectDesignspaceCallback, selectionCallback=self.selectDesignspaceCallback, enableDelete=True, otherApplicationDropSettings=dict( type=NSFilenamesPboardType, operation=NSDragOperationCopy, callback=self.dropCallback)) self.sources = Group((0, 0, -0, -0)) x = y = p = self.padding self.sources.list = List((x, y, -p, -p), []) self.glyphs = Group((0, 0, -0, -0)) x = y = p = self.padding textBoxHeight = -(self.lineHeight * 5) - (p * 3) self.glyphs.names = EditText( (x, y, -p, textBoxHeight), 'a b c A B C one two three') y = -(p + self.lineHeight) * 4 self.glyphs.importButton = Button( (x, y, -p, self.lineHeight), 'import glyphs', callback=self.importButtonCallback) y = -(p + self.lineHeight) * 3 self.glyphs.importMode = RadioGroup( (x, y, -p, self.lineHeight), ['fonts → fonts', 'fonts → glyphs', 'fonts → layers'], sizeStyle='small', isVertical=False) self.glyphs.importMode.set(2) y = -(p + self.lineHeight) * 2 self.glyphs.exportButton = Button( (x, y, -p, self.lineHeight), 'export selected glyphs', callback=self.exportButtonCallback) y = -(p + self.lineHeight) self.glyphs.progress = ProgressBar((x, y, -p, self.lineHeight)) descriptions = [ dict(label="designspaces", view=self.designspaces, size=self.lineHeight*5, minSize=self.lineHeight*3, collapsed=False, canResize=True), dict(label="sources", view=self.sources, size=self.lineHeight*8, minSize=self.lineHeight*6, collapsed=False, canResize=True), dict(label="glyphs", view=self.glyphs, size=self.lineHeight*10, minSize=self.lineHeight*8, collapsed=False, canResize=True), ] self.w.accordionView = AccordionView((0, 0, -0, -0), descriptions) self.w.getNSWindow().setTitlebarAppearsTransparent_(True) self.w.open()