def __init__(self): self.f = CurrentFont() self.letters = "" self.facet = 5 self.w = FloatingWindow((1500, 600), "Preview Facet") self.w.inputText = EditText((10, 10, 500, 24), text=self.letters, callback=self.inputTextCallback) self.w.facetSlider = Slider((520, 10, 500, 24), minValue=2, maxValue=9, value=self.facet, tickMarkCount=10, stopOnTickMarks=True, callback=self.facetSliderCallback) self.w.canvas = DrawView((10, 50, -10, -10)) addObserver(self, "updateFont", "fontBecameCurrent") self.setUpBaseWindowBehavior() self.updateCanvas() self.w.open()
def __init__(self): self.f = CurrentFont() self.letters = "" self.widthValue = 55 self.scale = 0.25 self.w = FloatingWindow((1200, 800), "Preview Width") self.w.inputText = GlyphSequenceEditText( (10, 10, 500, 24), self.f.naked(), callback=self.inputTextCallback) self.w.widthSlider = Slider((520, 10, 325, 24), minValue=10, maxValue=MAXWIDTH, value=self.widthValue, callback=self.widthSliderCallback) self.w.scaleSlider = Slider((865, 10, 325, 24), minValue=0, maxValue=0.5, value=self.scale, callback=self.scaleSliderCallback) self.w.canvas = DrawView((10, 50, -10, -10)) addObserver(self, "updateFont", "fontBecameCurrent") self.setUpBaseWindowBehavior() self.updateCanvas() self.w.open()
def buildUI(self): self.w = Window((960, 590), minSize=(830, 500), title="Etch-A-Sketch: " + fontName) self.w.canvas = DrawView((220, 10, -10, -10))
def buildUI(self): self.w = Window((960, 590), minSize=(830, 500), title="Etch-A-Sketch: " + fontName) if f is not None: self.w.inputText = GlyphSequenceEditText( (10, 10, 200, 22), f.naked(), callback=self.inputTextCallback) else: self.w.inputText = EditText((10, 10, 200, 22), "No open font") self.w.inputText.enable(False) self.w.xHeightText = TextBox((10, 48, 200, 17), "x-Height") self.w.xHeightSlider = Slider((15, 70, 190, 23), minValue=0.5, maxValue=2, value=xHeightTarget / ppi, tickMarkCount=7, stopOnTickMarks=True, callback=self.xHeightSliderCallback) self.w.xHeightMinVal = TextBox((10, 95, 50, 17), "0.5") self.w.xHeightMidVal = TextBox((95, 95, 50, 17), "1.25") self.w.xHeightMaxVal = TextBox((185, 95, 50, 17), "2.0") self.w.ascenderCheckbox = CheckBox( (10, 150, 100, 22), "Ascender", callback=self.ascenderCheckboxCallback) self.w.descenderCheckbox = CheckBox( (10, 172, 100, 22), "Descender", callback=self.descenderCheckboxCallback) self.w.printButton = SquareButton((10, 265, 200, 125), "Print!\n(cmd + p)", callback=self.printButtonCallback) self.w.printButton.bind('p', ["command"]) self.w.saveButton = SquareButton((10, 400, 200, 50), "Save PDF!", callback=self.saveButtonCallback) if f is None: self.w.saveButton.show(False) self.w.blueLinesCheckbox = CheckBox( (10, -30, 150, 22), "Non-photo blue lines", callback=self.blueLinesCheckboxCallback) self.w.canvas = DrawView((220, 10, -10, -10))
def __init__(self): # create a window self.w = Window((400, 400), minSize=(200, 200)) # add a slider self.w.slider = Slider((10, 10, -10, 22), callback=self.sliderCallback) # add a drawBox view self.w.drawBotCanvas = DrawView((0, 40, -0, -0)) # draw something self.drawIt() # open the window self.w.open()
def __init__(self): """ Connects main window and output window for errors. """ self.outputWindow = Window((400, 300), minSize=(1, 1), closable=True) self.outputWindow.outputView = OutPutEditor((0, 0, -0, -0), readOnly=True) self.window = Window((800, 600), minSize=(1, 1), closable=True) self.window.drawView = DrawView((0, 32, -0, -0)) self.scriptPath = None self.scriptFileName = None self.scriptName = None self.initialize() self.window.open() self.outputWindow.open()
def __init__(self): """Connects main window and output window for errors.""" for path in getFontPaths(): name = path.split('/')[-1] self.FONTS.append(name) self.font = findFont(self.FONTS[0]) self.context = getContext() self.window = Window((800, 600), minSize=(1, 1), closable=True) self.window.drawView = DrawView((0, 32, -0, -0)) self.outputWindow = Window((400, 300), minSize=(1, 1), closable=True) self.outputWindow.outputView = OutPutEditor((0, 0, -0, -0), readOnly=True) self.initialize() self.window.open() self.outputWindow.open()
def __init__(self): self.f = CurrentFont() self.letters = "" self.progress = 0 self.scale = 0.25 self.w = FloatingWindow((1200, 400), "Preview Progress") self.w.inputText = GlyphSequenceEditText( (10, 10, 500, 24), self.f.naked(), callback=self.inputTextCallback) self.w.facetSlider = Slider((520, 10, 325, 24), minValue=0, maxValue=SEGMENTS, value=self.progress, tickMarkCount=SEGMENTS, stopOnTickMarks=True, callback=self.progressSliderCallback) self.w.scaleSlider = Slider((865, 10, 325, 24), minValue=0, maxValue=0.5, value=self.scale, callback=self.scaleSliderCallback) # self.w.canvas = Canvas((10, 50, -10, -10), # canvasSize=(1200, 350), # hasHorizontalScroller=False, # hasVerticalScroller=False, # delegate=self) self.w.canvas = DrawView((10, 50, -10, -10)) self.breakGlyphCopies() addObserver(self, "updateFont", "fontBecameCurrent") self.setUpBaseWindowBehavior() self.updateCanvas() self.w.open()
def __init__(self): self.text = "" self.targetXheight = 1.25 * dpi self.w = Window((500, 500), minSize=(500, 500), title="Tester") self.w.editText = EditText((10, 10, -10, 24), "", callback=self.editTextCallback) self.w.xHeightSlider = Slider((10, 40, -10, 24), value=1.25, minValue=0.5, maxValue=2, callback=self.xHeightSliderCallback) self.w.canvas = DrawView((10, 70, -10, -10)) self.draw() self.w.open()
def __init__(self, fontPath): base, ext = os.path.splitext(fontPath) ext = ext.lower() # TODO: the axisInfo extraction below is a bit messy because the various # objects don't agree what's in obj.axes: user axes or all axes? Also: # does obj.drawGlyph() take a normalized location or not? if ext == ".designspace": from rcjktools.varco import VarCoFont self.varcoFont = VarCoFont(fontPath) axisInfo = [(axisTag, minValue, defaultValue, maxValue) for axisTag, ( minValue, defaultValue, maxValue, ) in self.varcoFont.axes.items()] elif ext == ".ttf": if fontFileHasTable(fontPath, "COLR"): self.varcoFont = COLRFont(fontPath) axisInfo = self.varcoFont.getAxisInfo() else: from rcjktools.ttVarCFont import TTVarCFont self.varcoFont = TTVarCFont(fontPath) axisInfo = getAxisInfo(self.varcoFont.ttFont) elif ext == ".rcjk": from rcjktools.project import RoboCJKProject self.varcoFont = RoboCJKProject(fontPath, decomposeClassicComponents=True) axisInfo = [ (axisTag, 0, 0, 1 ) # self.varcoFont.drawGlyph() takes normalized coords for axisTag, ( minValue, defaultValue, maxValue, ) in self.varcoFont.axes.items() ] else: assert 0, "unsupported file type" self.glyphList = sorted(self.varcoFont.keys()) self.w = Window( (1000, 400), f"VarCo Previewer — {fontPath}", minSize=(600, 400), autosaveName="VarCoPreviewer", ) self.w.findGlyphField = EditText((10, 10, 180, 20), callback=self.findGlyphFieldCallback) y = 8 self.axisSliderMapping = [] for axisIndex, (axisTag, minValue, defaultValue, maxValue) in enumerate(axisInfo): axisSliderAttrName = f"axisSlider{axisIndex}" axisLabelAttrName = f"axisLabel{axisIndex}" label = TextBox((-210, y, 200, 20), f"{axisTag}") y += 20 slider = Slider( (-210, y, 200, 20), value=defaultValue, minValue=minValue, maxValue=maxValue, callback=self.axisSliderCallback, ) y += 30 setattr(self.w, axisLabelAttrName, label) setattr(self.w, axisSliderAttrName, slider) self.axisSliderMapping.append((axisSliderAttrName, axisTag)) top = 40 self.w.characterGlyphList = List( (0, top, 200, 0), self.glyphList, allowsMultipleSelection=False, allowsSorting=False, showColumnTitles=False, drawFocusRing=False, selectionCallback=self.characterGlyphListSelectionChangedCallback, ) self.w.dbView = DrawView((200, 0, -220, 0)) # The DrawBot PDF view self.w.characterGlyphList.setSelection([]) self.w.open()
def __init__(self): # make a window self.w = Window((400, 400), "DrawBot", minSize=(200, 200), textured=False) # setting previously stored frames, if any self.w.getNSWindow().setFrameUsingName_(self.windowAutoSaveName) try: # on 10.7+ full screen support self.w.getNSWindow().setCollectionBehavior_( 128) #NSWindowCollectionBehaviorFullScreenPrimary except: pass toolbarItems = [ dict( itemIdentifier="run", label="Run", imageNamed="toolbarRun", callback=self.toolbarRun, ), dict( itemIdentifier="comment", label="Comment", imageNamed="toolbarComment", callback=self.toolbarComment, ), dict( itemIdentifier="uncomment", label="Uncomment", imageNamed="toolbarUncomment", callback=self.toolbarUncomment, ), dict( itemIdentifier="indent", label="Indent", imageNamed="toolbarIndent", callback=self.toolbarIndent, ), dict( itemIdentifier="dedent", label="Dedent", imageNamed="toolbarDedent", callback=self.toolbarDedent, ), dict(itemIdentifier=NSToolbarFlexibleSpaceItemIdentifier), dict( itemIdentifier="save", label="Save", imageNamed="toolbarScriptSave", callback=self.toolbarSave, ), dict( itemIdentifier="savePDF", label="Save PDF", imageObject=createSavePDFImage(), callback=self.toolbarSavePDF, ), dict(itemIdentifier=NSToolbarSpaceItemIdentifier), dict( itemIdentifier="reload", label="Reload", imageNamed="toolbarScriptReload", callback=self.toolbarReload, ), dict( itemIdentifier="new", label="New", imageNamed="toolbarScriptNew", callback=self.toolbarNewScript, ), dict( itemIdentifier="open", label="Open", imageNamed="toolbarScriptOpen", callback=self.toolbarOpen, ), dict(itemIdentifier=NSToolbarFlexibleSpaceItemIdentifier), ] toolbar = self.w.addToolbar( toolbarIdentifier="tinyDrawBotScriptingToolbar", toolbarItems=toolbarItems, addStandardItems=False) # the code editor self.codeView = CodeEditor((0, 0, -0, -0)) self.codeView.setCallback(self.runCode) # the output view (will catch all stdout and stderr) self.outPutView = OutPutEditor((0, 0, -0, -0), readOnly=True) # the view to draw in self.drawView = DrawView((0, 0, -0, -0)) # the view with all thumbnails self.thumbnails = ThumbnailView((0, 0, -0, -0)) # connect the thumbnail view with the draw view self.thumbnails.setDrawView(self.drawView) # collect all code text view in a splitview paneDescriptors = [ dict(view=self.codeView, identifier="codeView", minSize=50, canCollapse=False), dict(view=self.outPutView, identifier="outPutView", size=100, minSize=50, canCollapse=False), ] self.codeSplit = SplitView((0, 0, -0, -0), paneDescriptors, isVertical=False) # collect the draw scroll view and the code split view in a splitview paneDescriptors = [ dict(view=self.thumbnails, identifier="thumbnails", minSize=100, size=100, maxSize=100), dict(view=self.drawView, identifier="drawView", minSize=50), dict(view=self.codeSplit, identifier="codeSplit", minSize=50, canCollapse=False), ] self.w.split = SplitView((0, 0, -0, -0), paneDescriptors) # setup BaseWindowController base behavoir self.setUpBaseWindowBehavior() # get the real size of the window windowX, windowY, windowWidth, windowHeight = self.w.getPosSize() # set the split view dividers at a specific position based on the window size self.w.split.setDividerPosition(0, 0) self.w.split.setDividerPosition(1, windowWidth * .6) self.codeSplit.setDividerPosition(0, windowHeight * .7)
_drawBotDrawingTool._addToNamespace(namespace) # Creates a new standard output, catching all print statements and tracebacks. output = [] stdout = StdOutput(output, outputView=outputWindow.outputView) stderr = StdOutput(output, isError=True, outputView=outputWindow.outputView) # Calls DrawBot's ScriptRunner with above parameters. ScriptRunner(script, None, namespace=namespace, stdout=stdout, stderr=stderr) context = getContextForFileExt('pdf') _drawBotDrawingTool._drawInContext(context) pdfDocument = _drawBotDrawingTool.pdfImage() w.drawView.setPDFDocument(pdfDocument) if __name__ == '__main__': w = Window((10, 10, 400, 480), 'Window') w.button = Button((20, 20, 100, 30), 'Hit', callback=hitCallback) w.drawView = DrawView((0, 64, -0, -0)) w.open() outputWindow = Window((500, 10, 400, 300), minSize=(1, 1), closable=True) outputWindow.outputView = OutPutEditor((0, 0, -0, -0), readOnly=True) outputWindow.open() #hitCallback(None)
def __init__(self, rcjkProjectPath): self.project = RoboCJKProject(rcjkProjectPath, decomposeClassicComponents=True) self.glyphList = [ dict(glyphName=glyphName, unicode=unicodes) for glyphName, unicodes in self.project.getGlyphNamesAndUnicodes().items() ] self.glyphList.sort(key=lambda item: (item["unicode"], item["glyphName"])) self.w = Window( (1000, 400), f"RoboCJK Previewer — {rcjkProjectPath}", minSize=(1000, 400), autosaveName="RoboCJKPreviewer", ) self.w.findGlyphField = EditText( (10, 10, 180, 20), callback=self.findGlyphFieldCallback ) self.w.axisSlider = Slider( (210, 8, 180, 20), value=0, minValue=0, maxValue=1, callback=self.axisSliderCallback, ) top = 40 columnDescriptions = [ dict(title="glyph name", key="glyphName"), dict( title="unicode", key="unicode", formatter=UnicodesFormatter.alloc().init(), ), ] self.w.characterGlyphList = List( (0, top, 200, 0), self.glyphList, columnDescriptions=columnDescriptions, allowsMultipleSelection=False, allowsSorting=False, showColumnTitles=False, drawFocusRing=False, selectionCallback=self.characterGlyphListSelectionChangedCallback, ) self.w.deepComponentList = List( (200, top, 200, 0), [], allowsMultipleSelection=False, drawFocusRing=False, selectionCallback=self.deepComponentListSelectionChangedCallback, ) self.w.atomicElementList = List( (400, top, 200, 0), [], allowsMultipleSelection=False, drawFocusRing=False, selectionCallback=self.atomicElementListSelectionChangedCallback, ) self.w.dbView = DrawView((600, 0, 0, 0)) # The DrawBot PDF view self.w.characterGlyphList.setSelection([]) self.w.open()
def init(self): self = super(GlyphsDrawBotController, self).init() document = None # make a window self.w = Window((400, 400), "DrawBot", minSize=(200, 200), textured=False) # setting previously stored frames, if any self.w.getNSWindow().setFrameUsingName_(self.windowAutoSaveName) _NSWindow = self.w.getNSWindow() self.setWindow_(_NSWindow) _NSWindow.setDelegate_(self) _NSWindow.setContentBorderThickness_forEdge_(27, 1) try: # on 10.7+ full screen support self.w.getNSWindow().setCollectionBehavior_(128) # NSWindowCollectionBehaviorFullScreenPrimary except: pass # the code editor self.codeView = CodeEditor((0, 0, -0, -0)) self.codeView.getNSTextView().bind_toObject_withKeyPath_options_("value", self, "document.text", {NSContinuouslyUpdatesValueBindingOption:True}) scrollview = self.codeView.getNSTextView().enclosingScrollView() scrollview.setBorderType_(0) # the output view (will catch all stdout and stderr) self.outPutView = OutPutEditor((0, 0, -0, -0), readOnly=True) scrollview = self.outPutView.getNSTextView().enclosingScrollView() scrollview.setBorderType_(0) # the view to draw in self.drawView = DrawView((0, 0, -0, -0)) pdfView = self.drawView.getNSView() view = pdfView.documentView() # the view with all thumbnails self.thumbnails = ThumbnailView((0, 0, -0, -0)) # connect the thumbnail view with the draw view self.thumbnails.setDrawView(self.drawView) # collect all code text view in a splitview paneDescriptors = [ dict(view=self.codeView, identifier="codeView", minSize=50, canCollapse=False), dict(view=self.outPutView, identifier="outPutView", size=100, minSize=50, canCollapse=False), ] self.codeSplit = SplitView((0, 0, -0, -0), paneDescriptors, isVertical=False) # collect the draw scroll view and the code split view in a splitview paneDescriptors = [ dict(view=self.thumbnails, identifier="thumbnails", minSize=100, size=100, maxSize=100), dict(view=self.drawView, identifier="drawView", minSize=50), dict(view=self.codeSplit, identifier="codeSplit", minSize=50, canCollapse=False), ] self.w.split = SplitView((0, 0, -0, -27), paneDescriptors) self.w.runButton = Button((-67, -24, 50, 20), "Run", callback=self.runButtonAction_) self.w.runButton.bind("\r", ["command"]) self.w.runButton._nsObject.setToolTip_(u"Run the script (cmd+\u23CE)") self.w.clearButton = Button((-135, -24, 58, 20), "Clear", callback=self.clearButtonAction_) self.w.clearButton.bind("k", ["command"]) self.w.clearButton._nsObject.setToolTip_(u"Clear Log (cmd+K)") # get the real size of the window windowX, windowY, windowWidth, windowHeight = self.w.getPosSize() # set the split view dividers at a specific position based on the window size self.w.split.setDividerPosition(0, 0) self.w.split.setDividerPosition(1, windowWidth * .6) self.w.split.setDividerPosition(1, windowWidth * .6) self.codeSplit.setDividerPosition(0, windowHeight * .7) return self
def buildUI(self, uiWidth): dy = pad = pt(6) negPad = pt(-6) y = pad + dy uiWidth = pt(230) uiH = pt(24) negUiH = pt(-24) uiL = uiH + 6 uiLS = pt(18) uiLS2 = pt(23) if ADD_MENU: menuHeight = 18 + 2 * pad menuX = pad self.window.menu = Group((0, 0, -0, menuHeight)) for menuTitle, menuW, menuCallbackName, menuAttributes in MENUS: menuItems = [menuTitle] for menuItemTitle, menuItemCallback in menuAttributes: self.menuCallbacks[menuItemTitle] = getattr( self, menuItemCallback) menuItems.append(menuItemTitle) setattr( self.window.menu, menuTitle, PopUpButton((menuX, pad, menuW, menuHeight - 2 * pad), menuItems, callback=getattr(self, menuCallbackName), sizeStyle='small')) menuX += menuW + pad else: menuHeight = 0 self.window.uiGroup = Group((0, menuHeight, uiWidth, -0)) self.window.uiGroup.tabs = Tabs((0, pad, -0, negUiH - pad), ["Document", "Content", "Hints"], sizeStyle='mini') # D E S I G N U I tab = self.uiDesign = self.window.uiGroup.tabs[0] tab.documentNameLabel = TextBox((pad, y - 12, negPad, uiLS), 'Document name', sizeStyle='mini') tab.documentName = TextEditor((pad, y, negPad, uiLS), self.publication.name) y += uiL - 2 tab.publicationLabel = TextBox((pad, y - 8, (uiWidth - pad) / 2, uiLS), 'Publication category', sizeStyle='mini') tab.templateLabel = TextBox( ((uiWidth - pad) / 2 + pad, y - 8, negPad, uiLS), 'Publication type', sizeStyle='mini') publicationCategories = sorted(PublicationCategories.keys()) tab.publication = PopUpButton((pad, y, (uiWidth - pad) / 2 - pad, uiH), publicationCategories, callback=self.selectCategory, sizeStyle='small') tab.publication.set(publicationCategories.index('Magazine')) templateTypes = sorted( PublicationCategories[tab.publication.getItem()]) tab.templateType = PopUpButton( ((uiWidth - pad) / 2 + pad, y, negPad, uiH), templateTypes, callback=self.makeSample, sizeStyle='small') tab.templateType.set(0) y += uiL tab.themeLabel = TextBox((pad, y - 8, (uiWidth - pad) * 2 / 3, uiLS), 'Theme', sizeStyle='mini') themeNames = sorted(ThemeClasses.keys()) tab.theme = PopUpButton( (pad, y, (uiWidth - pad * 2) * 2 / 3 - pad, uiH), themeNames, callback=self.makeSample, sizeStyle='small') tab.theme.set(themeNames.index(DEFAULT_THEME_CLASS.NAME)) tab.themeMoodLabel = TextBox( ((uiWidth - pad) * 2 / 3, y - 8, negPad, uiLS), 'Mood', sizeStyle='mini') themeMoods = BaseTheme.MOOD_NAMES tab.themeMood = PopUpButton(((uiWidth - pad) * 2 / 3, y, negPad, uiH), themeMoods, callback=self.makeSample, sizeStyle='small') tab.themeMood.set(themeMoods.index(BaseTheme.DEFAULT_MOOD_NAME)) y += uiL tab.pageSizeLabel = TextBox((pad, y - 8, negPad, uiLS), 'Page size', sizeStyle='mini') options = sorted(self.publication.PAGE_SIZES.keys()) tab.pageSize = PopUpButton((pad, y, negPad, uiH), options, callback=self.makeSample, sizeStyle='small') tab.pageSize.set(2) y += uiL - 4 orientation = ('Portrait', 'Landscape') tab.orientation = RadioGroup((pad, y, negPad, 32), orientation, callback=self.makeSample, sizeStyle='small', isVertical=True) tab.orientation.set(0) tab.spread = CheckBox((uiWidth / 2, y - 4, negPad, uiH), 'Spread', callback=self.makeSample, sizeStyle='small') tab.spread.set(0) y += uiLS - 6 tab.symmetric = CheckBox((uiWidth / 2, y, negPad, uiH), 'Symmetry', callback=self.makeSample, sizeStyle='small') tab.symmetric.set(0) y += uiL + 8 tbW = 40 # Padding text box width tw = 10 x = pad tab.paddingLabel = TextBox((pad, y - 14, negPad, uiLS), 'Padding', sizeStyle='mini') tab.paddingTopLabel = TextBox((x, y, tw, uiLS), 'T', sizeStyle='small') tab.paddingTop = TextEditor( (x + tw, y, tbW, uiLS), '48', callback=self.makeSample, ) x += tw + tbW + 2 tab.paddingRightLabel = TextBox((x, y, 12, uiLS), 'R', sizeStyle='small') tab.paddingRight = TextEditor( (x + tw, y, tbW, uiLS), '48', callback=self.makeSample, ) x += tw + tbW + 2 tab.paddingBottomLabel = TextBox((x, y, 12, uiLS), 'B', sizeStyle='small') tab.paddingBottom = TextEditor( (x + tw, y, tbW, uiLS), '60', callback=self.makeSample, ) x += tw + tbW + 2 tab.paddingLeftLabel = TextBox((x, y, 12, uiLS), 'L', sizeStyle='small') tab.paddingLeft = TextEditor( (x + tw, y, tbW, uiLS), '72', callback=self.makeSample, ) y += uiL tab.gridLabel = TextBox((pad, y - 8, negPad, uiLS), 'Grid', sizeStyle='mini') columnOptions = [] for columns in range(1, 17): columnOptions.append(str(columns)) tab.columnsLabel = TextBox((pad, y + 5, 36, uiLS), 'Cols', sizeStyle='small') tab.columns = PopUpButton((pad + 36, y, uiWidth / 5, uiH), columnOptions, callback=self.makeSample, sizeStyle='small') tab.columns.set(3) # 4 columns tab.hGutterLabel = TextBox((uiWidth / 2, y + 5, 60, uiLS), 'HGutter', sizeStyle='small') tab.hGutter = PopUpButton((negPad - uiWidth / 5, y, uiWidth / 5, uiH), columnOptions, callback=self.makeSample, sizeStyle='small') tab.hGutter.set(11) # pt(12) y += uiLS rowsOptions = [] for rows in range(1, 25): rowsOptions.append(str(rows)) tab.rowssLabel = TextBox((pad, y + 5, 36, uiLS), 'Rows', sizeStyle='small') tab.rows = PopUpButton((pad + 36, y, uiWidth / 5, uiH), columnOptions, callback=self.makeSample, sizeStyle='small') tab.rows.set(0) # 1 row tab.vGutterLabel = TextBox((uiWidth / 2, y + 5, 60, uiLS), 'VGutter', sizeStyle='small') tab.vGutter = PopUpButton((negPad - uiWidth / 5, y, uiWidth / 5, uiH), columnOptions, callback=self.makeSample, sizeStyle='small') tab.vGutter.set(11) # pt(12) y += uiL tab.showBaselineGrid = CheckBox((pad, y, uiWidth / 2, uiH), 'Baselines', callback=self.makeSample, sizeStyle='small') tab.showBaselineGrid.set(True) tab.showColorBars = CheckBox((uiWidth / 2, y, negPad, uiH), 'Color bars', callback=self.makeSample, sizeStyle='small') tab.showColorBars.set(1) y += uiLS tab.showGrid = CheckBox((pad, y, uiWidth / 2, uiH), 'Grid', callback=self.makeSample, sizeStyle='small') tab.showGrid.set(1) tab.showPagePadding = CheckBox((uiWidth / 2, y, negPad, uiH), 'Page padding', callback=self.makeSample, sizeStyle='small') tab.showPagePadding.set(True) y += uiLS tab.showPageFrame = CheckBox((pad, y, uiWidth / 2, uiH), 'Page frame', callback=self.makeSample, sizeStyle='small') tab.showPageFrame.set(True) tab.showCropMarks = CheckBox((uiWidth / 2, y, negPad, uiH), 'Cropmarks', callback=self.makeSample, sizeStyle='small') tab.showCropMarks.set(True) tab.errors = EditText((pad, -50, negPad, negPad)) # C O N T E N T U I y = pad + dy tab = self.uiContent = self.window.uiGroup.tabs[1] tab.contentSelectionLabel = TextBox((pad, y - 8, negPad, uiLS), 'Content selection', sizeStyle='mini') options = sorted(('Random content', 'Open...')) tab.contentSelection = PopUpButton((pad, y, negPad, uiH), options, callback=self.makeSample, sizeStyle='small') tab.contentSelection.set(0) y += uiL self.window.canvas = DrawView((uiWidth, menuHeight, -0, -0))
def buildUI(self): x = 10 xText = 8 row1 = 10 row2 = 78 row3 = 165 row4 = 250 self.w = Window((960, 590), minSize=(830, 500), title="Etch-A-Sketch: " + fontName) self.w.fontNameText = EditText((x, row1, 150, 22), fontName, callback=self.fontNameTextCallback) self.w.newFontNameText = EditText( (x, row1, 150, 22), self.newFontName, callback=self.newFontNameTextCallback) self.w.newFontNameText.show(False) self.w.fontRef = CheckBox((x + 160, row1, 40, 22), "Ref", callback=self.fontRefCallback) self.w.xHeightText = TextBox((xText, row2, 200, 17), "x-Height (in.)") self.w.xHeightSlider = Slider((x + 2, row2 + 22, 194, 23), minValue=0.5, maxValue=2, value=self.xHeightDrawing / ppi, tickMarkCount=7, stopOnTickMarks=True, callback=self.xHeightSliderCallback, sizeStyle='small') self.w.xHeightSlider.getNSSlider().setVertical_( False) # Set this explicitly self.w.xHeightMinVal = TextBox((xText, row2 + 48, 50, 17), "0.5") self.w.xHeightMidVal = TextBox((xText + 85, row2 + 48, 50, 17), "1.25") self.w.xHeightMaxVal = TextBox((xText + 177, row2 + 48, 50, 17), "2.0") self.w.guidesText = TextBox((xText, row3, 100, 17), "Guides") self.w.ascenderCheckbox = CheckBox( (x, row3 + 20, 100, 22), "Ascender", callback=self.ascenderCheckboxCallback) self.w.ascenderText = EditText((x + 100, row3 + 20, 50, 22), ascender, callback=self.ascenderTextCallback) self.w.descenderCheckbox = CheckBox( (x, row3 + 45, 100, 22), "Descender", callback=self.descenderCheckboxCallback) self.w.descenderText = EditText((x + 100, row3 + 45, 50, 22), descender, callback=self.descenderTextCallback) self.w.extrasText = TextBox((xText, row4, 100, 17), "Extras") self.w.blueLinesCheckbox = CheckBox( (x, row4 + 20, 150, 22), "Non-photo blue lines", callback=self.blueLinesCheckboxCallback) self.w.grayLettersCheckbox = CheckBox( (x, row4 + 42, 150, 22), "Gray letters", callback=self.grayLettersCheckboxCallback) self.w.printButton = SquareButton((x, 430, 200, -10), "Print!\n(cmd + p)", callback=self.printButtonCallback) self.w.printButton.bind('p', ["command"]) self.w.canvas = DrawView((220, 10, -10, -10)) if f is not None: self.w.fontNameText.enable(False) self.w.inputText = GlyphSequenceEditText( (x, row1 + 30, 200, 22), f.naked(), callback=self.inputTextCallback) self.w.ascenderText.enable(False) self.w.descenderText.enable(False) self.w.saveButton = SquareButton((x, 370, 200, 50), "Save PDF!", callback=self.saveButtonCallback) else: self.w.fontRef.enable(False) self.w.inputText = EditText((x, 40, 200, 22), "No open font") self.w.inputText.enable(False) self.w.grayLettersCheckbox.enable(False)
def __init__(self, pdf): self.pdf = pdf self.w = Window((600, 200), "PDF Proofer", minSize=(200, 200)) self.w.mainsegmentedButton = SegmentedButton( (10, 10, -10, 20), [dict(title="overlay"), dict(title="custom")], callback=self.mainsegmentedButtonCallback) self.w.mainsegmentedButton.set(0) self.w.overlay = Group((10, 30, -10, -0)) self.w.overlay.inputText = TextEditor((0, 0, -0, -20), '') self.w.overlay.generatePDFButton = Button( (0, -20, -0, -0), "Generate PDF", callback=self.generatePDFButtonCallback) self.w.customPages = Group((0, 30, -0, -0)) self.w.customPages.show(0) self.w.customPages.canvas = DrawView((400, 0, -0, -0)) self.w.customPages.pageTitle = TextBox((10, 10, 100, 20), "Pages", sizeStyle='small') self.w.customPages.pagesList = List( (10, 30, 80, 180), self.pdf.pages, selectionCallback=self.pagesListSelectionCallback, drawFocusRing=False) self.w.customPages.newPage = Button((10, 210, 40, 20), '+', callback=self.newPageCallback, sizeStyle="small") self.w.customPages.delPage = Button((50, 210, 40, 20), '-', callback=self.delPageCallback, sizeStyle="small") self.w.customPages.page = Group((95, 0, 305, 300)) self.w.customPages.page.show(False) self.w.customPages.page.widthTitle = TextBox((0, 30, 45, 20), "Width", sizeStyle='small') self.w.customPages.page.pageWidth = EditText( (40, 30, 50, 20), 841, sizeStyle='small', formatter=numberFormatter, callback=self.pageSizeCallback, continuous=False) self.w.customPages.page.heightTitle = TextBox((98, 30, 45, 20), "Height", sizeStyle='small') self.w.customPages.page.pageHeight = EditText( (145, 30, 50, 20), 595, sizeStyle='small', formatter=numberFormatter, callback=self.pageSizeCallback, continuous=False) self.w.customPages.page.columnsTitle = TextBox((0, 60, 100, 20), "Columns", sizeStyle='small') self.w.customPages.page.columsSlider = Slider( (0, 80, 195, 20), minValue=1, maxValue=10, value=1, tickMarkCount=9, stopOnTickMarks=True, callback=self.columsSliderCallback) self.w.customPages.page.linesTitle = TextBox((0, 110, 100, 20), "Lines", sizeStyle='small') self.w.customPages.page.linesSlider = Slider( (0, 130, 195, 20), minValue=1, maxValue=10, value=1, tickMarkCount=9, stopOnTickMarks=True, callback=self.linesSliderCallback) self.w.customPages.page.marginTitle = TextBox((0, 160, 100, 20), "Margin", sizeStyle='small') self.w.customPages.page.marginSlider = Slider( (0, 180, 195, 20), minValue=10, maxValue=100, value=10, callback=self.marginSliderCallback) self.w.customPages.page.backgrounColorTitle = TextBox( (0, 210, 150, 20), "Background color", sizeStyle='small') self.w.customPages.page.backgrounColorWell = ColorWell( (105, 210, 90, 20), callback=self.backgroundcolorBoxCallback, color=NSColor.colorWithCalibratedRed_green_blue_alpha_(1, 1, 1, 1)) self.w.customPages.page.textBoxTitle = TextBox((205, 10, 80, 150), "Box", sizeStyle='small') self.w.customPages.page.textBoxList = List( (205, 30, 80, 200), [], selectionCallback=self.textBoxListSelectionCallback, drawFocusRing=False) self.w.customPages.text = Group((0, 250, 400, 400)) self.w.customPages.text.show(False) self.w.customPages.text.horizontalLine = HorizontalLine( (10, 0, -10, 10)) y = 30 self.w.customPages.text.fontSizeTitle = TextBox((210, y, 80, 20), 'FontSize', sizeStyle="small") self.w.customPages.text.fontSize = EditText( (280, y, 100, 20), 10, sizeStyle="small", formatter=numberFormatter, callback=self.fontSizeCallback, continuous=False) y += 30 self.w.customPages.text.colorTitle = TextBox((210, y, 80, 20), 'Color', sizeStyle="small") self.w.customPages.text.color = ColorWell( (280, y, 100, 20), callback=self.textcolorBoxCallback) y += 30 self.w.customPages.text.trackingTitle = TextBox((210, y, 80, 20), 'Tracking', sizeStyle="small") self.w.customPages.text.tracking = Slider( (280, y, 100, 20), minValue=0, maxValue=100, value=0, callback=self.trackingBoxCallback) y += 30 self.w.customPages.text.lineHeightTitle = TextBox((210, y, 80, 20), 'LineHeight', sizeStyle="small") self.w.customPages.text.lineHeight = Slider( (280, y, 100, 20), minValue=500, maxValue=2500, value=1200, callback=self.lineHeightBoxCallback) y += 30 self.w.customPages.text.alignTitle = TextBox((210, y, 80, 20), 'Align', sizeStyle="small") self.w.customPages.text.align = PopUpButton( (280, y, 100, 20), ["left", "center", "right"], callback=self.alignBoxCallback) self.w.customPages.text.segmentedButton = SegmentedButton( (10, 30, 190, 20), segmentDescriptions=[dict(title="UFO"), dict(title="FontBook")], callback=self.segmentedButtonCallback, sizeStyle='small') self.w.customPages.text.segmentedButton.set(0) self.w.customPages.text.ufo = Group((10, 60, 190, 110)) self.fontAxis = [] if self.pdf.RCJKI.currentFont.fontVariations: self.fontAxis = [ dict(Axis=x, PreviewValue=0) for x in self.pdf.RCJKI.currentFont.fontVariations ] slider = SliderListCell(minValue=0, maxValue=1) self.w.customPages.text.ufo.axis = List( (0, 0, -0, -0), self.fontAxis, columnDescriptions=[{ "title": "Axis", "editable": False, "width": 60 }, { "title": "PreviewValue", "cell": slider }], showColumnTitles=False, editCallback=self.ufoAxisListEditCallback, allowsMultipleSelection=False, drawFocusRing=False) self.w.customPages.text.fontManager = PopUpButton( (10, 60, 190, 20), FontsList.get(), callback=self.fontManagerCallback, sizeStyle="small") self.w.customPages.text.fontManager.show(0) self.w.customPages.text.textEditorTitle = TextBox((10, 180, -10, -0), "Text", sizeStyle="small") self.w.customPages.text.textEditor = TextEditor( (10, 200, -10, -20), "", callback=self.textEditorCallback) self.w.customPages.text.setAllGlyphsDone = PopUpButton( (10, -20, -10, -0), [ "", "Set all character glyphs with deep components or contours", "Set all character glyphs with deep components and contours", "Set all character glyphs with deep components", "Set all character glyphs with contours", ], # "Set all character glyphs not empty", callback=self.setAllGlyphsDoneCallback) self.w.customPages.exportPDF = Button((0, -20, 400, -0), "Export PDF", callback=self.exportPDFCallback)