• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python events.addObserver函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中mojo.events.addObserver函数的典型用法代码示例。如果您正苦于以下问题:Python addObserver函数的具体用法?Python addObserver怎么用?Python addObserver使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了addObserver函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: __init__

 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()
开发者ID:gferreira,项目名称:hTools2,代码行数:28,代码来源:layer_delete.py


示例2: __init__

 def __init__(self):
     
     addObserver(self, "drawMetricsBox", "drawBackground")
     
     self.color = getDefault("glyphViewMarginColor")
     self.height = getDefault("glyphViewDefaultHeight") / 2
     self.useItalicAngle = getDefault("glyphViewShouldUseItalicAngleForDisplay")
开发者ID:davelab6,项目名称:RoboFontExamples,代码行数:7,代码来源:drawVerticalMetricsBox.py


示例3: __init__

    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()
开发者ID:asaumierdemers,项目名称:WurstSchreiber,代码行数:32,代码来源:WurstSchreiber.py


示例4: __init__

 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()
开发者ID:aaronmoodie,项目名称:RoboFont,代码行数:7,代码来源:MultiFontPreview_ordered.py


示例5: __init__

	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()
开发者ID:Grigory-Koposov,项目名称:RoboFont,代码行数:35,代码来源:VersionControl.py


示例6: __init__

 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()
开发者ID:davelab6,项目名称:RoboFontExamples,代码行数:26,代码来源:contourReorderer.py


示例7: __init__

    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()
开发者ID:LettError,项目名称:tools,代码行数:25,代码来源:interpolatedStatesTool.py


示例8: __init__

    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()
开发者ID:bghryct,项目名称:Robofont-scripts,代码行数:60,代码来源:penBallWizardController.py


示例9: __init__

 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()
开发者ID:hblackett,项目名称:hTools2,代码行数:58,代码来源:transfer_anchors.py


示例10: __init__

 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")
开发者ID:sannorozco,项目名称:ControlBoard,代码行数:9,代码来源:components.py


示例11: __init__

 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()
开发者ID:gferreira,项目名称:hTools2_extension,代码行数:57,代码来源:mask_copy.py


示例12: __init__

 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()
开发者ID:jackjennings,项目名称:hTools2_extension,代码行数:55,代码来源:vmetrics_transfer.py


示例13: __init__

 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")
开发者ID:sannorozco,项目名称:ControlBoard,代码行数:11,代码来源:Glyph+Mark+to+LED.py


示例14: __init__

 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()
开发者ID:davelab6,项目名称:RoboFontExamples,代码行数:11,代码来源:stencilPreview.py


示例15: __init__

 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"
开发者ID:sannorozco,项目名称:ControlBoard,代码行数:11,代码来源:PrevNextGlyph.py


示例16: startStopButtonCallback

 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")            
开发者ID:davelab6,项目名称:RoboFontExamples,代码行数:12,代码来源:simpleWindowObserver.py


示例17: __init__

 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()
开发者ID:gferreira,项目名称:hTools2,代码行数:53,代码来源:interpolate_check.py


示例18: __init__

    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")
开发者ID:sannorozco,项目名称:ControlBoard,代码行数:12,代码来源:Button.py


示例19: __init__

 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()
开发者ID:Hofstede,项目名称:RoboFontExtensions,代码行数:12,代码来源:glifViewer.py


示例20: __init__

 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")
开发者ID:sannorozco,项目名称:ControlBoard,代码行数:13,代码来源:ServoMotor.py



注:本文中的mojo.events.addObserver函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python events.removeObserver函数代码示例发布时间:2022-05-27
下一篇:
Python moire.parse函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap