Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def receive_data(self, data):
global perf_counter
t = perf_counter() - self._start_times.pop(0)
mib = data.byteLength / 1024 / 1024
text = 'Received %i MiB in %s seconds.' % (mib, str(t)[:5])
self.status.set_html(self.status.html + ' ' + text)
self.progress.set_value(self.progress.value + 1)
if len(self._start_times) == 0:
t = perf_counter() - self._start_time
text = 'Total time %s.' % str(t)[:5]
self.status.set_html(self.status.html + ' ' + text)
if __name__ == '__main__':
m = app.launch(SpeedTest, 'firefox-browser')
app.run()
self.w5 = MyWidget(text='min-size: 50',
style='min-width:50px; min-height:50px')
self.w6 = MyWidget(text='min-size: 100',
style='min-width:100px; min-height:100px')
self.w7 = MyWidget(text='min-size: 150',
style='min-width:150px; min-height:150px')
with ui.Widget(flex=1):
with MyLayout('h'):
self.w8 = MyWidget()
self.w9 = MyWidget(style='min-width:250px;')
self.w8 = MyWidget()
if __name__ == '__main__':
m = app.launch(TestApp)
app.run()
with ui.HFix(flex=1):
SyncedSlidersWrong(flex=1)
SyncedSlidersRight(flex=1)
ui.Widget(flex=1) # spacer
@event.reaction('reset.pointer_click')
def _reset(self):
# You probably don't want to ever do this in a normal app.
# Do via a timeout because reactions get handled by the event system,
# so the reset will not work correctly.
global window
window.setTimeout(event.loop.reset, 0)
m = app.launch(Tricky, 'app')
app.run()
class Dock(ui.DockPanel):
def init(self):
ui.Widget(style='background:#f00', title='red')
ui.Widget(style='background:#0f0', title='green')
ui.Widget(style='background:#00f', title='blue')
ui.Widget(style='background:#ff0', title='yellow')
ui.Widget(style='background:#f0f', title='purple')
ui.Widget(style='background:#0ff', title='cyan')
if __name__ == '__main__':
m = app.launch(Dock)
app.run()
print(t)
class JS:
def _init(this):
that = this
def _set_time():
that.time._set(time.perf_counter())
window.setInterval(_set_time, 200)
@react.source
def time(t):
return float(t)
clock = app.launch(Clock, 'nodejs')
app.run()
print('A: foo changed from %s to %s' % (ev.old_value,
ev.new_value))
@event.connect('foo')
def react_to_bar_b(self, *events):
print('B: foo changed from %s to %s' % (events[0].old_value,
events[-1].new_value))
class JS:
@event.prop
def foo(self, v=0.0):
return float(v)
m = app.launch(MyModel1, 'browser') # Change to MyModel2 to test reverse case
m.foo = 3
m.foo = 7
app.run()
html.h1(text='List 2')
html.Div(text="""<ul>
<li>Foo</li>
<li>Bar</li>
<li>Spam</li>
</ul>""")
class JS:
@event.connect('text.mouse_down')
def on_text_clicked(self, *events):
self.thelist.children[-1].text = window.Date.now()
if __name__ == '__main__':
m = app.launch(Example, 'browser')
app.run()
def inner(simulation):
database = dataset.connect('sqlite:///parameter.db')
abcEconomics.parameter_database = database['parameter']
Form = form(parameter_mask, names) # pylint: disable=C0103
if serve:
flexx.config.hostname = hostname
flexx.config.port = port
app.serve(basiclayout(Form, simulation, title, header,
truncate_rounds,
texts=texts, pages=pages,
histograms=histograms))
app.start()
else:
app.launch(basiclayout(Form, simulation, title, header,
truncate_rounds,
texts=texts, pages=pages,
histograms=histograms),
windowmode='maximized', runtime=runtime)
app.run()
return lambda _: None
return inner