def __init__(self): self.w = FloatingWindow((100, 100), "Tester") self.w.bind("close", self.closeCB) self.guideView = None addObserver(self, "glyphWindowOpenCB", "glyphWindowDidOpen")
def __init__(self, glyph): self.w = FloatingWindow((230, 300), "Contour Reorder", minSize=(200, 250)) columnDescriptions = [ dict(title="contour", width=170), dict(title="", key="color", cell=ColorCell.alloc().init(), width=60) ] self.w.contours = List((0, 0, -0, -0), [], columnDescriptions=columnDescriptions, allowsEmptySelection=False, allowsMultipleSelection=False, enableDelete=True, dragSettings=dict(type=contourReoderPboardType, callback=self.dragCallback), selfDropSettings=dict(type=contourReoderPboardType, operation=NSDragOperationMove, callback=self.dropListSelfCallback) ) addObserver(self, "drawBackground", "drawBackground") addObserver(self, "currentGlyphChanged", "currentGlyphChanged") self.setUpBaseWindowBehavior() self.setGlyph(glyph) UpdateCurrentGlyphView() self.w.open()
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.snapToCloseDistance = 4 if getExtensionDefault(scriptStateKey, fallback=False): addObserver(self, "mouseDownCallback", "mouseDown") addObserver(self, "mouseUpCallback", "mouseUp")
def __init__(self): self.glyph = CurrentGlyph() self.working_options = self.defaultLocal self.initUI() self.addObservers() addObserver(self, "inspectorWindowWillShowDescriptions", "inspectorWindowWillShowDescriptions")
def mouseDown(self, point): if self.isAtomic: return event = extractNSEvent(point) modifiers = getActiveEventTool().getModifiers() option = modifiers['optionDown'] command = modifiers['commandDown'] if not all([option, command]): if not event["shiftDown"]: self.currentGlyph.selectedElement = [] try: self.px, self.py = point['point'].x, point['point'].y except: return self.currentGlyph.pointIsInside((self.px, self.py), event["shiftDown"]) self.currentViewSliderList.deepComponentAxesList.set([]) self.currentViewSliderList.deepComponentName.set("") if self.currentGlyph.selectedElement: self.setListWithSelectedElement() if point[ 'clickCount'] == 2 and not self._currentSourceValidated( ): popover.EditPopoverAlignTool(self, point['point'], self.currentGlyph) else: self.currentGlyph.setTransformationCenterToSelectedElements( (point['point'].x, point['point'].y)) addObserver(self, 'mouseDragged', 'mouseDragged') if not self.isAtomic: self.glyphInspectorWindow.deepComponentListItem.setList() self.glyphInspectorWindow.transformationItem.setTransformationsField( )
def __init__(self): self.w = vanilla.Window((400, 400), minSize=(100, 100)) self.w.glyphLineView = GlyphLineView((0, 0, 0, 0), pointSize=None, autohideScrollers=False, showPointSizePlacard=True) events.addObserver(self, "glyphChanged", "currentGlyphChanged") self.glyphChanged(dict(glyph=CurrentGlyph())) self.setUpBaseWindowBehavior() self.w.open()
def __init__(self): self.get_font() # window self.title = 'layers' self.height = self.button_height + (self.padding_y*3) + (self.text_height*8) self.w = HUDFloatingWindow((self.width, self.height), self.title) x = self.padding_x y = self.padding_y self.w.layers = List( (x, y, -self.padding_x, self.text_height*8), self.layers) y += self.padding_y + self.text_height*8 self.w.button_apply = SquareButton( (x, y, -self.padding_x, self.button_height), "delete", sizeStyle=self.size_style, callback=self.apply_callback) # bind self.w.bind("became key", self.update_callback) self.w.bind("close", self.on_close_window) # observers addObserver(self, "update_callback", "fontBecameCurrent") # open self.w.open()
def startListening(self): if self.isListening(): self.stopListening() for event in self._events.keys(): addObserver(self, "eventCallback", event) self._isListening = True self._storeAudibleDefault()
def observer(self, remove = False): if not remove: addObserver(self, "draw", "draw") addObserver(self, "draw", "drawInactive") return removeObserver(self, "draw") removeObserver(self, "drawInactive")
def __init__(self): addObserver(self, "drawMetricsBox", "drawBackground") self.color = getDefault("glyphViewMarginColor") self.height = getDefault("glyphViewDefaultHeight") / 2 self.useItalicAngle = getDefault("glyphViewShouldUseItalicAngleForDisplay")
def _draw_space_callback(self, sender): # RF-specific: Draw in space center value = sender.get() if value: addObserver(self, "_previewFull", "spaceCenterDraw") else: removeObserver(self, "spaceCenterDraw")
def __init__(self): self.w = FloatingWindow((250, 530),minSize=(200, 400),title = 'Version Control') self.PreviewPanel = Group((0, 0, -0, -0)) self.PreviewPanel.Preview = GlyphPreview((0, 0, -15, 0)) self.PreviewPanel.GlyphInfo = TextBox((5, -13, 0, 12), '', alignment='left', selectable=False, sizeStyle='mini') self.PreviewPanel.hline = HorizontalLine((5, -1, -5, 1)) self.Control = Group((0, 0, -0, -0)) self.Control.VersionsList = List((0, 30, -0, -0), [], allowsMultipleSelection = False, selectionCallback=self.selectionVersionCallback, doubleClickCallback=self.selectionDoubleVersionCallback) self.Control.btnAdd = Button((5,5,30,20), '+', callback=self.btnAddCallback) self.Control.btnDel = Button((40,5,30,20), '-', callback=self.btnDelCallback) self.Control.btnSwap = Button((75,5,40,20), '<>', callback=self.btnSwapCallback) self.Control.btnShow = Button((120,5,40,20), 'Sc', callback=self.btnShowCallback) self.Note = TextEditor((5, 5, -5, -5)) descriptions = [ dict(label="Preview", view=self.PreviewPanel, size=320, collapsed=False, canResize=True), dict(label="Control", view=self.Control, minSize=100, size=140, collapsed=False, canResize=True), dict(label="Note", view=self.Note, minSize=100, size=140, collapsed=True, canResize=True), ] addObserver(self, "_currentGlyphChanged", "currentGlyphChanged") self.w.bind("close", self.windowClose) self.w.accordionView = AccordionView((0, 0, -0, -0), descriptions ) checkVersionNumbers() self.updateVersionsList() self.w.open()
def createUI(self): self.window = CurrentFontWindow() if self.window is None: return toolbarItems = self.window.getToolbarItems() self.newToolbarItems = list() newItem1 = dict(itemIdentifier="Search", label="Search", imageNamed=NSImageNameRevealFreestandingTemplate, callback=self.popSearchWindow); self.newToolbarItems.append(newItem1); newItem2_1 = dict(itemIdentifier="Rewind", label="Rewind", imageNamed=NSImageNameRefreshFreestandingTemplate, callback=self.restoreAttribute); self.newToolbarItems.append(newItem2_1); newItem2_2 = dict(itemIdentifier="Undo", label="Undo", imageNamed=NSImageNameInvalidDataFreestandingTemplate, callback=self.rollbackAttribute); self.newToolbarItems.append(newItem2_2); newItem3 = dict(itemIdentifier="Save", label="Save", imageNamed=NSImageNameComputer, callback=None); self.newToolbarItems.append(newItem3); newItem4 = dict(itemIdentifier="Exit", label="Exit", imageNamed=NSImageNameStopProgressFreestandingTemplate, callback=self.windowCloseCallback); self.newToolbarItems.append(newItem4); newItem5 = dict(itemIdentifier="Settings", label="Settings", imageNamed=NSImageNameAdvanced, callback=self.popSettingWindow); self.newToolbarItems.append(newItem5); newItem6 = dict(itemIdentifier="Attribute", label="Attribute", imageNamed=NSImageNameFontPanel, callback=self.popAttributeWindow); self.newToolbarItems.append(newItem6); newItem7 = dict(itemIdentifier="Help", label="Help", imageNamed=NSImageNameInfo, callback=self.popManualWindow); self.newToolbarItems.append(newItem7); newItem8 = dict(itemIdentifier="Except", label="Except", imageNamed=NSImageNameTrashFull, callback=self.handleRemoveGlyph); self.newToolbarItems.append(newItem8); #기존 툴바에 새로운 툴바 아이템 추가 for i in range(len(self.newToolbarItems)): toolbarItems.append(self.newToolbarItems[i]) # 현재 폰트 창에 toolbarItems를 추가 vanillaWindow = self.window.window() self.window.toolbar = vanillaWindow.addToolbar(toolbarIdentifier="myCustomToolbar", toolbarItems=toolbarItems, addStandardItems=False) addObserver(self, "drawBroadNibBackground", "drawBackground")
def __init__(self, f): addObserver(self, "mouseDown", "mouseDown") addObserver(self, "mouseUp", "mouseUp") #addObserver(self, "fontWillClose", "fontWillClose") #addObserver(self, "fontDidOpen", "fontDidOpen") self.f = f self.italAngle = None
def __init__(self): self.draw = False self.swap = True self.radius = getExtensionDefault( "%s.%s" % (WurstSchreiberDefaultKey, "radius"), 60) color = NSColor.colorWithCalibratedRed_green_blue_alpha_(1, 0, 0, .5) colorValue = getExtensionDefaultColor( "%s.%s" % (WurstSchreiberDefaultKey, "color"), color) self.w = FloatingWindow((150, 170), "WurstSchreiber") x = 15 y = 15 self.w.preview = CheckBox( (x, y, -x, 20), "Preview", callback=self.previewChanged, value=True) y+=30 self.w.slider = SliderGroup( (x, y, -x, 22), 0, 100, self.radius, callback=self.sliderChanged) y+=35 self.w.color = ColorWell( (x, y, -x, 40), callback=self.colorChanged, color=colorValue) y+=55 self.w.button = Button( (x, y, -x, 20), "Trace!", callback=self.traceButton) addObserver(self, "drawWurst", "drawBackground") self.w.bind("close", self.closing) self.w.open()
def __init__(self): self.settings =[] addObserver(self, "buttonToolBar", "glyphWindowWillShowToolbarItems") self.settingsWindow = SettingsWindow(self) self.drawer = GlyphWindowDrawer(self) self.observers = False self.activ = False
def __init__(self): # debug windowname = 'Debug Glyph Metrics UI' windows = [w for w in NSApp().orderedWindows() if w.isVisible()] for window in windows: print(window.title()) if window.title() == windowname: window.close() if debug == True: self.debug = Window((333, 33), windowname) self.debug.bind('close', self.windowSideuiClose) self.debug.open() # setup self.showButtons = False self.sbui = None # add interface addObserver(self, 'addInterface', 'glyphWindowWillOpen') addObserver(self, 'updateSelfWindow', 'currentGlyphChanged') # toggle visibility of tool ui addObserver(self, 'showSideUIonDraw', 'draw') addObserver(self, 'hideSideUIonPreview', 'drawPreview') # remove UI and window manager when glyph window closes # addObserver(self, "observerGlyphWindowWillClose", "glyphWindowWillClose") # subscribe to glyph changes addObserver(self, "viewDidChangeGlyph", "viewDidChangeGlyph")
def setup(self): """ Set up some defaults and watch for event posted by ToleranceWindow() """ self.glyph = CurrentGlyph() addObserver(self, "_applyTolerance", "com.ToleranceSettingChanged")
def __init__(self): # subscribe to the moment when an inspector will be shown addObserver(self, "inspectorWindowWillShowDescriptions", "inspectorWindowWillShowDescriptions") # keep a reference of the view inserted in the inspector self.editor = Group((0, 0, -0, -0)) self.editor.markingToolButton = Button((10,10,-10,20), 'Marking Tool', callback=self.markingToolCallback) self.editor.outlineToolButton = Button((10,40,-10,20), 'Outline Tool', callback=self.outlineToolCallback)
def __init__(self): self.filters = PenBallFiltersManager() # self.filters.loadFiltersFromJSON('/'.join([LOCALPATH, JSONFILE])) filtersList = getExtensionDefault('{0}.filtersList'.format(PENBALLWIZARD_EXTENSIONKEY), []) self.filters.loadFiltersList(filtersList) self.glyphNames = [] self.observedGlyphs = [] self.currentFont = CurrentFont() self.initCachedFont() filtersList = self.filters.keys() if len(filtersList) > 0: self.currentFilterName = filtersList[0] else: self.currentFilterName = None self.fill = True self.observers = [ ('fontChanged', 'fontBecameCurrent'), ('fontChanged', 'fontDidOpen'), ('fontChanged', 'fontDidClose'), ] self.displaySettingsRecord = { 1: (u'✓ Fill', True), 2: (u'Stroke', False), 3: (u'Inverse', False), } self.w = Window((100, 100, 800, 500), 'PenBall Wizard v{0}'.format(__version__), minSize=(500, 400)) self.w.filtersPanel = Group((0, 0, 300, -0)) self.w.filtersPanel.filtersList = List((0, 0, -0, -80), filtersList, selectionCallback=self.filterSelectionChanged, doubleClickCallback=self.filterEdit, allowsMultipleSelection=False, allowsEmptySelection=False, rowHeight=22) self.w.filtersPanel.controls = Group((0, -80, -0, 0)) self.w.filtersPanel.addFilter = SquareButton((0, -80, 100, 40), 'Add filter', sizeStyle='small', callback=self.addFilter) self.w.filtersPanel.addFilterChain = SquareButton((100, -80, 100, 40), 'Add operations', sizeStyle='small', callback=self.addFilterChain) self.w.filtersPanel.removeFilter = SquareButton((-100, -80, 100, 40), 'Remove filter', sizeStyle='small', callback=self.removeFilter) self.w.textInput = EditText((300, 0, -75, 22), '', callback=self.stringInput) self.w.generate = SquareButton((0, -40, 300, -0), 'Generate', callback=self.buildGenerationSheet, sizeStyle='small') self.w.displaySettings = PopUpButton( (-70, 3, -10, 15), self.makeDisplaySettingsMenuItems(), sizeStyle='mini', callback=self.changeDisplaySettings) self.w.displaySettings.getNSPopUpButton().setPullsDown_(True) self.w.displaySettings.getNSPopUpButton().setBordered_(False) self.w.preview = MultiLineView((300, 22, -0, -0)) displayStates = self.w.preview.getDisplayStates() for key in ['Show Metrics','Upside Down','Stroke','Beam','Inverse','Water Fall','Multi Line']: displayStates[key] = False for key in ['Fill','Single Line']: displayStates[key] = True self.w.preview.setDisplayStates(displayStates) for callback, event in self.observers: addObserver(self, callback, event) self.updateControls() self.w.bind('close', self.end) self.launchWindow() 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 __init__(self): self._states = [] self._lastState = None # place for the last state before we start interpolating self._lastName = "" self._currentGlyph = None height = 32 self.w = vanilla.FloatingWindow( (250,height), "Interpolated State %s"%__version__, maxSize=(500, height+16), minSize=(150, height+16) ) self.w.clearButton = vanilla.Button( (-30, 5, -5, 20), u"✕", callback=self.callbackClearButton) self.w.interpolateSlider = vanilla.Slider( (5, 5, -35, 20), 0, 100, 100, callback=self.callbackInterpolateSlider) self.w.interpolateSlider.enable(False) self.w.bind("close", self.bindingWindowClosed) self.reportStatus("Add a glyph.") addObserver(self, "currentGlyphChanged", "currentGlyphChanged") addObserver(self, "keyDown", "keyDown") self.subscribeGlyph() self.w.open()
def listLaunch(self): addObserver(self, 'updateFontInfo', 'fontDidSave') print('adding Observer') self.w.myList = List((0, 0, -0, -0), self.makeColumns(), columnDescriptions=[{ "title": "Glyph Name" }, { "title": self.f1.info.styleName }, { "title": "LSB" }, { "title": "RSB" }, { "title": self.f2.info.styleName }, { "title": "LSB" }, { "title": "RSB" }, { "title": "Match" }], selectionCallback=self.selectionCallback)
def __init__(self): self.leftMargin = None self.rightMargin = None self.status = 1 self.updateGlyph() addObserver(self, "keyWasPressed", "keyDown") addObserver(self, "glyphWindowOpened", "glyphWindowDidOpen")
def __init__(self): # Save zoom posSize and offset for each open font # font object as key, dict of "rectPos", "rectSize", "offset" and "glyph" as value self.prevZoom = {} addObserver(self, "getZoom", "viewWillChangeGlyph") addObserver(self, "setZoom", "viewDidChangeGlyph")
def __init__(self, delegate): self.delegate = delegate self.guideStatus = GuideStatusView() self.displayGuides = False addObserver(self, "keyDownCB", "keyDown") addObserver(self, "glyphWindowOpenCB", "glyphWindowDidOpen")
def __init__(self): self._get_fonts() # create window self.title = 'anchors' self.column_1 = 130 self.width = 123 self.height = (self.text_height * 4) + (self.button_height) + (self.padding_y * 4)# - 2 self.w = FloatingWindow((self.width, self.height), self.title) x = self.padding_x y = self.padding_y - 1 # source font label self.w._source_label = TextBox( (x, y, -self.padding_x, self.text_height), "source font", sizeStyle=self.size_style) y += self.text_height # source font value self.w._source_value = PopUpButton( (x, y, -self.padding_x, self.text_height), self.all_fonts_names, sizeStyle=self.size_style) y += (self.text_height + self.padding_y) # target font label self.w._target_label = TextBox( (x, y, -self.padding_x, self.text_height), "target font", sizeStyle=self.size_style) y += self.text_height # target font value self.w._target_value = PopUpButton( (x, y, -self.padding_x, self.text_height), self.all_fonts_names, sizeStyle=self.size_style) # buttons y += (self.text_height + self.padding_y) self.w.button_apply = SquareButton( (x, y, -self.padding_x, self.button_height), "copy", callback=self.apply_callback, sizeStyle=self.size_style) # bind self.w.bind("became key", self.update_callback) self.w.bind("close", self.on_close_window) # observers addObserver(self, "update_callback", "fontDidOpen") addObserver(self, "update_callback", "fontDidClose") # open window self.w.open()
def __init__(self, parent_view, *args, **kwargs): super(ShowDistTextBox, self).__init__(*args, **kwargs) self.notifications = [ "mouseUp", "mouseDragged", "keyUp", "selectAll", "viewDidChangeGlyph" ] for notification_name in self.notifications: addObserver(self, "update_info_callback", notification_name) self.parent_view = parent_view
def start(self): super(GlyphNameHUDControl, self).start() events.addObserver(self, "currentGlyphChangedCallback", "currentGlyphChanged") self.view.textBox = vanilla.TextBox((0, 0, 0, 0), "") textField = self.view.textBox.getNSTextField() font = NSFont.systemFontOfSize_(20) textField.setFont_(font) textField.setTextColor_(RoboHUDController().getForegroundColor())
def mouseDown(self, info): x, y = info['point'] for i, font in enumerate(self.settings): if font.pointInside((x, y)): self.deltax, self.deltay = x - font.x, y - font.y addObserver(self, "mouseDragged", "mouseDragged") self.settingsSelectedIndex = i self.settingsWindow.w.settingsList.setSelection([i]) return
def __init__(self): self._get_fonts() # window self.title = 'layers' self.width = 123 self.height = (self.text_height * 4) + (self.button_height * 1) + (self.padding_y * 4) #- 2 self.w = FloatingWindow((self.width, self.height), self.title) # source label x = self.padding_x y = self.padding_y - 1 self.w._source_label = TextBox( (x, y, -self.padding_x, self.text_height), "foreground", sizeStyle=self.size_style) y += self.text_height # source value self.w._source_value = PopUpButton( (x, y, -self.padding_x, self.text_height), self.all_fonts_names, sizeStyle=self.size_style) y += (self.text_height + self.padding_y) # target label self.w._target_label = TextBox( (x, y, -self.padding_x, self.text_height), "background", sizeStyle=self.size_style) y += self.text_height # target value self.w._target_value = PopUpButton( (x, y, -self.padding_x, self.text_height), self.all_fonts_names, sizeStyle=self.size_style) # apply button y += (self.text_height + self.padding_y) self.w.button_apply = SquareButton( (x, y, -self.padding_x, self.button_height), "copy", sizeStyle=self.size_style, callback=self.apply_callback) # bind self.w.bind("became key", self.update_callback) self.w.bind("close", self.on_close_window) # observers addObserver(self, "update_callback", "fontDidOpen") addObserver(self, "update_callback", "fontDidClose") # open window self.w.open()
def __init__(self, menuTitle, menuItems, width=50): col = getDefaultColor("spaceCenterBeamStrokeColor") self.sel_color = (col.redComponent(), col.greenComponent(), col.blueComponent(), col.alphaComponent()) self.title = menuTitle self.items = menuItems self.width = width addObserver(self, "glyphWindowDidOpenObserver", "glyphWindowDidOpen")
def __init__(self, board, pinList, name): self.board = board self.name = name self.pin = pinList[0] # BreakfastSerial component object: self.component = BSer.Led(self.board, self.pin) # Subscribe to all ControlBoardOutput notifications addObserver(self, "outputCallback", "ControlBoardOutput")
def __init__(self): #if getExtensionDefault(scriptStateKey, fallback=False): addObserver(self, "keyDown", "keyDown") self.arrowKeyChars = { 63232: "up", 63233: "down", 63234: "left", 63235: "right" }
def updateGlyph(self): if CurrentGlyph(): self.glyph = CurrentGlyph() self.leftMargin = self.glyph.leftMargin if self.status == 1: removeObserver(self, "draw") self.updateGlyphView() if self.status == 0: addObserver(self, "drawText", "draw") self.updateGlyphView()
def mouseDown(self, info): self.f = CurrentFont() self.x = info["point"].x self.y = info["point"].y self.italAngle = getItalAngle(self.f) addObserver(self, "draw", "draw") addObserver(self, "mouseDragged", "mouseDragged") if getExtensionDefault(defaultKeyObserverVisibility) == False: removeObserver(self, "mouseDragged") removeObserver(self, "draw")
def __init__(self): self.title = 'vmetrics' self.column_1 = 103 self.width = self.column_1 + (self.padding_x * 2) self.height = (self.text_height * 4) + self.button_height + (self.padding_y * 4) self.w = FloatingWindow((self.width, self.height), self.title) # source font x = self.padding_x y = self.padding_y self.w.source_label = TextBox( (x, y, -self.padding_x, self.text_height), "source", sizeStyle=self.size_style) y += self.text_height self.w.source_value = PopUpButton( (x, y, -self.padding_x, self.text_height), self.all_fonts_names, sizeStyle=self.size_style) # target font y += self.text_height + self.padding_y self.w.target_label = TextBox( (x, y, -self.padding_x, self.text_height), "target", sizeStyle=self.size_style) y += self.text_height self.w.target_value = PopUpButton( (x, y, -self.padding_x, self.text_height), self.all_fonts_names, sizeStyle=self.size_style) # buttons y += self.text_height + self.padding_y self.w.button_apply = SquareButton( (x, y, -self.padding_x, self.button_height), "copy", sizeStyle=self.size_style, callback=self.apply_callback) # bind self.w.bind("became key", self.update_callback) self.w.bind("close", self.on_close_window) # observers addObserver(self, "update_callback", "fontDidOpen") addObserver(self, "update_callback", "fontDidClose") # open window self.w.open() self.get_fonts()
class ShowMouseCoordinatesTextBox(TextBox): """ A vanilla text box with some goodies about the mouse. """ def __init__(self, *args, **kwargs): self.observers = {"mouseMoved", "mouseDragged", "mouseUp"} # initialize the parent object, and add all of the observers super(ShowMouseCoordinatesTextBox, self).__init__(*args, **kwargs) addObserver(self, "mouseMoved", "mouseMoved") addObserver(self, "mouseDragged", "mouseDragged") addObserver(self, "mouseUp", "mouseUp")
def __init__(self): self.glyph = CurrentGlyph() # create a window self.w = FloatingWindow((400, 400), "Stencil Preview", minSize=(200, 200)) # add the preview to the window self.w.preview = GlyphPreview((0, 0, -0, -0)) # add an observer to get callbacks when a glyph changes in the glyph view addObserver(self, "viewDidChangeGlyph", "viewDidChangeGlyph") # open the window self.updateGlyph() self.w.open()
def __init__(self): self.w = vanilla.Window((100, 100), "Previous/Next Glyph") self.w.bind("close", self.windowClosed) self.w.open() # When the state of any component on your board changes (button pressed, knob turned), a "ControlBoardInput" # notification will be made. Start observing for these notifications and give a method name in this script # to be called when the notification comes in, in this case self.controlChanged addObserver(self, "controlChanged", "ControlBoardInput") self.controlName = "Rotary"
def __init__(self): self.ledName = "Status Light" self.glyph = None self.w = vanilla.Window((200, 100), "Mark Color") self.w.bind("close", self.windowClosed) self.w.open() addObserver(self, "updateMark", "drawInactive") addObserver(self, "glyphChanged", "currentGlyphChanged")
def __init__(self, board, pinList, name): self.board = board self.name = name self.pin = pinList[0] self.type = "Servo" # BreakfastSerial component object: self.component = BSer.Servo(self.board, self.pin) self.component.set_position(90) # Subscribe to all ControlBoardOutput notifications addObserver(self, "outputCallback", "ControlBoardOutput")
def __init__(self): self.get_fonts() self.title = 'interpol check' self.height = self.text_height*4 + self.padding_y*3 + self.button_height self.w = HUDFloatingWindow((self.width, self.height), self.title) # font 1 x = self.padding_x y = self.padding_y - 6 self.w.f1_label = TextBox( (x, y + 3, -self.padding_x, self.text_height), "font 1", sizeStyle=self.size_style) y += self.text_height self.w.f1_font = PopUpButton( (x, y, -self.padding_x, self.text_height), self.all_fonts_names, sizeStyle=self.size_style) y += self.text_height + 4 # font 2 self.w.f2_label = TextBox( (x, y + 3, -self.padding_x, self.text_height), "font 2", sizeStyle=self.size_style) y += self.text_height self.w.f2_font = PopUpButton( (x, y, -self.padding_x, self.text_height), self.all_fonts_names, sizeStyle=self.size_style) y += self.text_height + self.padding_y + 1 # apply button self.w.apply_button = SquareButton( (x, y, -self.padding_x, self.button_height), 'apply', callback=self.apply_callback, sizeStyle=self.size_style) # bind self.w.bind("became key", self.update_callback) self.w.bind("close", self.on_close_window) # observers addObserver(self, "update_callback", "fontDidOpen") addObserver(self, "update_callback", "fontDidClose") # open window self.w.open()
def __init__(self): self.currentGlyph = None self.w = vanilla.Window((500, 500), "Plist Viewer", minSize=(100, 100)) self.w.xml = CodeEditor((0, 0, -0, -30), "", lexer="xml") self.w.applyButton = vanilla.Button((-70, -25, -20, 22), "Apply", callback=self.applyCallback, sizeStyle="small") addObserver(self, "currentGlyphChanged", "currentGlyphChanged") self.setUpBaseWindowBehavior() self.currentGlyphChanged({}) self.w.open()
def startStopButtonCallback(self, sender): # button callback, check the title if sender.getTitle() == "Start": # set "Stop" as title for the button sender.setTitle("Stop") # add an observer addObserver(self, "draw", "draw") else: # set "Start" as title for the button sender.setTitle("Start") # remove the observser removeObserver(self, "draw")
def __init__(self): self.w = FloatingWindow((300, 40), "Coldtype Serializer", minSize=(123, 200)) self.w.globalToggle = CheckBox((10, 10, -10, 20), 'serialize?', value=True) self.output = Path("~/robofont-coldtype.json").expanduser().absolute() addObserver(self, "shouldDraw", "draw") self.setUpBaseWindowBehavior() self.w.open()
def __init__(self): self.w = vanilla.Window((200, 150), "Button/Switch") self.w.titleState = vanilla.TextBox((20, 20, -10, 25), "Button is: ...") self.w.titleName = vanilla.TextBox((20, 70, -20, 25), "Button/Switch Name:") self.w.componentName = vanilla.EditText((20, 100, -20, 25), "My Component") self.w.open() # When the state of any component on your board changes (button pressed, knob turned), a "ControlBoardInput" # notification will be made. Start observing for these notifications and give a method name in this script # to be called when the notification comes in, in this case self.controlChanged addObserver(self, "controlChanged", "ControlBoardInput")
def __init__(self): # The name of the sensor (the potentiometer) and the servo: self.sensorName = "Knob" self.servoName = "Servo" self.w = vanilla.Window((200, 100), "Servo Demo") self.w.titleValue = vanilla.TextBox((20, 20, -10, 25), "Current value and angle:") self.w.knobValue = vanilla.TextBox((20, 40, -10, 25), "0.0, 0" + chr(176)) self.w.bind("close", self.windowClosed) self.w.open() addObserver(self, "controlChanged", "ControlBoardInput")
def __init__(self, board, pinList, name): self.board = board self.name = name self.pinRed = pinList[0] self.pinGreen = pinList[1] self.pinBlue = pinList[2] # BreakfastSerial component object: self._red = ComponentLED(self.board, [self.pinRed], self.name + "-Red") self._green = ComponentLED(self.board, [self.pinGreen], self.name + "-Green") self._blue = ComponentLED(self.board, [self.pinBlue], self.name + "-Blue") # Subscribe to all ControlBoardOutput notifications addObserver(self, "outputCallback", "ControlBoardOutput")
def __init__(self, parent_view, *args, **kwargs): super(ShowDistTextBox, self).__init__(*args, **kwargs) self.notifications = [ 'mouseUp', 'mouseDragged', 'keyUp', 'selectAll', 'viewDidChangeGlyph' ] for notification_name in self.notifications: addObserver( self, 'update_info_callback', notification_name) addObserver(self, 'kill_observers', 'glyphWindowWillClose') self.parent_view = parent_view
def __init__(self): bgColor = NSColor.colorWithCalibratedRed_green_blue_alpha_(255, 255, 255, 255) buttonColor = NSColor.colorWithCalibratedRed_green_blue_alpha_(0, 0, 0, 255) self.w = Window((1000, 400), 'Interpolation Matrix', minSize=(470, 300)) self.w.getNSWindow().setBackgroundColor_(bgColor) self.w.glyphTitle = Box((10, 10, 200, 30)) self.w.glyphTitle.name = EditText((5, 0, -5, 20), 'No current glyph', self.changeGlyph, continuous=False) glyphEdit = self.w.glyphTitle.name.getNSTextField() glyphEdit.setBordered_(False) glyphEdit.setBackgroundColor_(Transparent) glyphEdit.setFocusRingType_(NSFocusRingTypeNone) self.axesGrid = {'horizontal': 3, 'vertical': 1} self.masters = [] self.instanceSpots = [] self.mutator = None self.currentGlyph = None self.errorGlyph = errorGlyph() self.buildMatrix((self.axesGrid['horizontal'], self.axesGrid['vertical'])) self.w.addColumn = SquareButton((-80, 10, 30, 30), u'+', callback=self.addColumn) self.w.removeColumn = SquareButton((-115, 10, 30, 30), u'-', callback=self.removeColumn) self.w.addLine = SquareButton((-40, -40, 30, 30), u'+', callback=self.addLine) self.w.removeLine = SquareButton((-40, -70, 30, 30), u'-', callback=self.removeLine) for button in [self.w.addColumn, self.w.removeColumn, self.w.addLine, self.w.removeLine]: button.getNSButton().setBezelStyle_(10) self.w.clearMatrix = Button((220, 15, 70, 20), 'Clear', callback=self.clearMatrix) self.w.generate = Button((300, 15, 100, 20), 'Generate', callback=self.instanceGeneration) # self.w.saveMatrix = Button((300, 15, 70, 20), 'Save', callback=self.saveMatrix) # self.w.loadMatrix = Button((380, 15, 70, 20), 'Load', callback=self.loadMatrix) addObserver(self, 'updateMatrix', 'currentGlyphChanged') addObserver(self, 'updateMatrix', 'fontDidClose') addObserver(self, 'updateMatrix', 'mouseUp') addObserver(self, 'updateMatrix', 'keyUp') self.w.bind('close', self.windowClose) self.w.bind('resize', self.windowResize) self.w.open()
def __init__(self): # subscribe to the draw event addObserver(self, "draw", "draw") addObserver(self, "draw", "drawBackground") # create a background color self.backgroundColor = NSColor.redColor() # create a background stroke color self.backgroundStrokeColor = NSColor.whiteColor() # create a stroke color self.strokeColor = NSColor.redColor() # setting text attributes self.attributes = attributes = { NSFontAttributeName : NSFont.boldSystemFontOfSize_(9), NSForegroundColorAttributeName : NSColor.whiteColor(), }
def __init__(self): self.w = Window((400, 400), "mojo.event observer", minSize=(200, 200)) self.w.list = List((10, 10, 200, -40), [], selectionCallback=self.listSelection) self.w.info = TextEditor((220, 10, -10, -40), readOnly=True) self.w.ignoreText = TextBox((10, -30, 100, 22), "Ignore:") self.w.ignore = EditText((70, -30, -100, 22), "mouseMoved") self.w.clear = Button((-70, -30, 60, 22), "Clear", self.clearListCallback) addObserver(self, "notification", None) self.setUpBaseWindowBehavior() self.w.open()
def __init__(self): self.enableGroupSpacing = False self.popupOpen = False addObserver(self, 'glyphEditCallback', 'spaceCenterKeyDown') addObserver(self, 'glyphEditedCallback', 'spaceCenterKeyUp') addObserver(self, 'spaceCenterOpenCallback', 'spaceCenterDidOpen') addObserver(self, 'fontOpenCallback', 'fontDidOpen') self.previousMargins = {'left': 0, 'right': 0}
def __init__(self): BaseWindowController.__init__(self) self.w = FloatingWindow((340, 220), 'Quadratic Converter') # --------------------------- top = 10 self.w.maxDistanceTitle = TextBox((10, top, 100, 20), "Max Distance: ") minMaxDist = 0.01 maxMaxDist = 10.0 self.initMaxDist = 1.0 self.maxDistanceValue = self.initMaxDist self.w.maxDistanceValueText = TextBox((110, top, -90, 22), str(self.initMaxDist)) self.w.maxDistanceResetButton = Button((-80, top, -10, 22), "Reset", callback=self.maxDistanceResetCallback) self.w.maxDistanceSlider = Slider( (10, top+20, -10, 20), minValue=log(minMaxDist), maxValue=log(maxMaxDist), value=log(self.initMaxDist), callback=self.maxDistanceSliderCallback ) # --------------------------- top = 60 self.w.minLengthTitle = TextBox((10, top, 150, 20), "Min Segment Length: ") minMinLen = 0 maxMinLen = 100 initMinLen = 30 self.minLengthValue = initMinLen self.w.minLengthValueText = TextBox((160, top, -10, 22), str(initMinLen)) self.w.minLengthSlider = Slider( (10, top+20, -10, 20), minValue=minMinLen, maxValue=maxMinLen, value=initMinLen, callback=self.minLengthSliderCallback ) # --------------------------- top = 110 self.useArcLength = True #self.w.arclencheckbox = CheckBox((10, top, 90, 20), "Arc length", callback=self.arcLengthCheckBoxCallback, value=self.useArcLength) self.calculatePreview = True self.w.previewCheckBox = CheckBox((10, top, 70, 20), "Preview", callback=self.previewCheckBoxCallback, value=self.calculatePreview) self.w.closeButton = Button((120, top, 70, 20), "Close", callback=self.closeCallBack) self.w.convertCurrentFont = Button((210, top, 120, 20), "Convert Font", callback=self.convertCurrentFontCallback) # --------------------------- top = 150 self.layers = ["foreground"]+CurrentFont().layerOrder self.w.layerText = TextBox((10, top, 120, 20), "Layer (per-glyph): ") self.w.layerPopup = PopUpButton((130, top, 90, 20), self.layers)#, callback=self.arcLengthCheckBoxCallback) self.w.convertCurrentGlyph = Button((225, top, 105, 20), "Convert Glyph", callback=self.convertCurrentGlyphCallback) # --------------------------- self.w.infoText = TextBox((10, -38, -10, 34), "WARNING. Un-saved modifications in a UFO will not be converted.") # --------------------------- self.w.open() self.w.bind("close", self.windowClosed) addObserver(self, "draw", "draw") UpdateCurrentGlyphView()
def __init__(self): self.filters = PenBallFiltersManager() self.filters.loadFiltersFromJSON('/'.join([LOCALPATH, JSONFILE])) self.glyphNames = [] self.observedGlyphs = [] self.cachedFont = RFont(showUI=False) self.currentFont = CurrentFont() filtersList = self.filters.keys() if len(filtersList) > 0: self.currentFilterName = filtersList[0] else: self.currentFilterName = None self.fill = True self.observers = [ ('fontChanged', 'fontBecameCurrent'), ('fontChanged', 'fontDidOpen'), ('fontChanged', 'fontDidClose'), ] self.w = Window((100, 100, 800, 500), 'PenBall Wizard v{0}'.format(__version__), minSize=(500, 400)) self.w.filtersPanel = Group((0, 0, 300, -0)) self.w.filtersPanel.filtersList = List((0, 0, -0, -40), filtersList, selectionCallback=self.filterSelectionChanged, doubleClickCallback=self.filterEdit, allowsMultipleSelection=False, allowsEmptySelection=False, rowHeight=22) self.w.filtersPanel.controls = Group((0, -40, -0, 0)) self.w.filtersPanel.addFilter = SquareButton((0, -40, 100, 40), 'Add filter', sizeStyle='small', callback=self.addFilter) self.w.filtersPanel.addFilterChain = SquareButton((100, -40, 100, 40), 'Add operations', sizeStyle='small', callback=self.addFilterChain) self.w.filtersPanel.removeFilter = SquareButton((-100, -40, 100, 40), 'Remove filter', sizeStyle='small', callback=self.removeFilter) self.w.textInput = EditText((300, 0, -90, 22), '', callback=self.stringInput) self.w.generate = SquareButton((-90, 0, 90, 22), 'Generate', callback=self.generateGlyphsToFont, sizeStyle='small') self.w.preview = MultiLineView((300, 22, -0, -0)) self.w.switchFillStroke = SquareButton((-75, -40, 60, 25), 'Stroke', callback=self.switchFillStroke, sizeStyle='small') displayStates = self.w.preview.getDisplayStates() for key in ['Show Metrics','Upside Down','Stroke','Beam','Inverse','Water Fall','Multi Line']: displayStates[key] = False for key in ['Fill','Single Line']: displayStates[key] = True self.w.preview.setDisplayStates(displayStates) for callback, event in self.observers: addObserver(self, callback, event) self.updateControls() self.w.bind('close', self.end) self.launchWindow() self.w.open()
def __init__(self): self.w = Window((400, 400), "Layer Preview", minSize=(400, 300)) self.w.preview = GlyphLayerPreview((0, 0, -0, -30)) self.currentGlyphChanged() self.w.useColor = CheckBox((10, -30, 100, 22), "Use Color:", callback=self.useColorCallback) self.w.color = ColorWell((120, -35, 40, 30), color=NSColor.blackColor(), callback=self.colorCallback) self.w.testInstall = Button((-170, -30, -10, 22), "Test Install Layers", callback=self.testInstallCallback) addObserver(self, "currentGlyphChanged", "currentGlyphChanged") self.setUpBaseWindowBehavior() self.w.open()