Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@event.connect('save.mouse_click')
def _save(self, events):
parameter = self.parse_parameter()
parameter['name'] = self.name.text
parameter['description'] = self.description.text
abcEconomics.parameter_database.upsert(parameter, keys=['name'])
self.emit('update_parameter_database', parameter)
@event.connect('size', 'font_size')
def update(self, *events):
ctx = self.ctx
w, h = self.size
# Enable hidpi
ratio = self.dpratio / self.bsratio
self.node.width = w * ratio
self.node.height = h * ratio
ctx.clearRect(0, 0, w, h)
ctx.font = "%ipx DejaVu Sans Mono" % self.font_size
cw = ctx.measureText('x').width
ch = self._measure_text_height()
@event.connect('text')
def __on_inner_html(self, *events):
self.node.innerHTML = events[-1].new_value
@event.connect('parent')
def on_parent(self, *events):
parent = events[-1].new_value
parent_id = 'None' if parent is None else parent._id
print('parent of %s changed to %s in JS' % (self._id, parent_id))
@event.connect('result')
def show_result(self, *events):
""" handler to show result. Can be called at any time. """
if self.result:
print('The result is', self.result)
@event.connect('children', 'children*.pos',
'children*.flex', 'children*.base_size')
def __update_positions(self, *events):
self._child_limits_changed()
@event.connect('first_name', 'last_name')
def greet1(self, *events):
print('Hello %s %s' % (self.first_name, self.last_name))
@event.connect('_plot_components')
def __set_plot_components(self, *events):
ev = events[-1]
self.node.innerHTML = ev.div
el = window.document.createElement('script')
el.innerHTML = ev.script
self.node.appendChild(el)
def getplot():
# Get plot from id in next event-loop iter
self.plot = Bokeh.index[ev.id]
canvas = self.plot.plot_canvas_view
canvas.reset_dimensions()
window.setTimeout(getplot, 100)
@event.connect('size')
def __resize_plot(self, *events):
if self.plot and self.parent:
self.plot.resize()
@event.connect('foo')
def on_foo(self, *events):
for ev in events:
print('Py: handling %s event' % ev.type, self.foo + self.spam)