本文整理汇总了Python中mojo.events.addObserver函数的典型用法代码示例。如果您正苦于以下问题:Python addObserver函数的具体用法?Python addObserver怎么用?Python addObserver使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了addObserver函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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()
示例2: __init__
def __init__(self):
addObserver(self, "drawMetricsBox", "drawBackground")
self.color = getDefault("glyphViewMarginColor")
self.height = getDefault("glyphViewDefaultHeight") / 2
self.useItalicAngle = getDefault("glyphViewShouldUseItalicAngleForDisplay")
示例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()
示例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()
示例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()
示例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()
示例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()
示例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()
示例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()
示例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")
示例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()
示例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()
示例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")
示例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()
示例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"