Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def init(self):
self.t = time()
with flx.HFix():
self.label1 = flx.Label(flex=2, style='overflow-y:scroll; font-size:60%;')
flx.Widget(flex=1)
with flx.VFix(flex=2):
flx.Widget(flex=1)
test_widget1 = flx.Widget(flex=2, style='background: #afa;')
flx.Widget(flex=1)
test_widget2 = flx.Widget(flex=2, style='background: #faa;')
flx.Widget(flex=1)
flx.Widget(flex=1)
self.label2 = flx.Label(flex=1, style='overflow-y:scroll; font-size:60%;')
for name in ['pointerdown', 'pointermove', 'pointerup', 'pointercancel',
'mousedown', 'mousemove', 'mouseup', 'click', 'dblclick',
'touchstart', 'touchmove', 'touchend', 'touchcancel'
]:
test_widget1.node.addEventListener(name,
lambda e: self.show_event1(e.type))
def init(self, topic):
self.server_name = topic.split("/")[1]
self.service_name = "/" + self.server_name + "/start_stop"
self.nodes = {}
self.subscribe(topic, "rosmon_msgs/State", self.callback)
self.list_container = flx.VBox(flex=1)
with self.list_container:
with flx.HBox(flex=1):
self.expand = flx.Button(flex=0, text=">")
self.label = flx.Label(flex=0, text=self.server_name + ":")
self.launch_state = flx.Label(flex=0, text="IDLE", style='color: #F00;')
#self.expand = flx.Button(text="Expand")
flx.Widget(flex=1)
self.start_stop = flx.Button(flex=0, text="Stop")
self.base_layout = flx.VBox(flex=1, style='border:1px solid #777;')
with self.base_layout:
with flx.HFix():
flx.Label(text="Name")
flx.Label(text="State")
flx.Label(text="CPU")
flx.Label(text="Memory")
flx.Label(text="Restarts")
flx.Label(text="Action")
self.base_layout.set_parent(None)
def init(self):
super().init()
self.ctx = self.node.getContext('2d')
self._last_pos = {}
# Set mouse capturing mode
self.set_capture_mouse(1)
# Label to show info about the event
self.label = flx.Label()
def init(self):
with flx.VBox():
self.b1 = flx.Button(text='apple')
self.b2 = flx.Button(text='banana')
self.b3 = flx.Button(text='pear')
self.buttonlabel= flx.Label(text='...')
with flx.VBox():
self.r1 = flx.RadioButton(text='apple')
self.r2 = flx.RadioButton(text='banana')
self.r3 = flx.RadioButton(text='pear')
self.radiolabel = flx.Label(text='...')
with flx.VBox():
self.c1 = flx.ToggleButton(text='apple')
self.c2 = flx.ToggleButton(text='banana')
self.c3 = flx.ToggleButton(text='pear')
self.checklabel = flx.Label(text='...')
def init(self):
with flx.HSplit():
self.label = flx.Label(flex=1, style='overflow-y: scroll;')
with flx.TreeWidget(flex=1, max_selected=1) as self.tree:
for t in ['foo', 'bar', 'spam', 'eggs']:
with flx.TreeItem(text=t, checked=None):
for i in range(4):
item2 = flx.TreeItem(text=t + ' %i' % i, checked=False)
if i == 2:
with item2:
flx.TreeItem(title='A', text='more info on A')
flx.TreeItem(title='B', text='more info on B')
def init(self):
self.label = flx.Label()
self.apply_style('overflow-y: scroll;') # enable scrolling
# doc-export: Boxes
"""
Example that puts box and fix mode HVLayout's side-by-side. You can see how
box mode takes the natural size of content into account, making it
more suited for low-level layout. For higher level layout (e.g. the two
main panels in this example) the fix or split mode is more appropriate.
"""
from flexx import flx
class Panel(flx.Label):
CSS = '.flx-Panel {background: #66dd88; color: #FFF; padding: 1px;}'
class Boxes(flx.Widget):
def init(self):
with flx.HSplit():
with flx.VBox(flex=1):
flx.Label(html='<b>Box mode</b> (aware of natural size)')
flx.Label(text='flex: 1, sub-flexes: 0, 0, 0')
with flx.HBox(flex=1):
Panel(text='A', flex=0)
Panel(text='B', flex=0)
def init(self):
with flx.Widget():
flx.Label(text='Refreshing the page should '
'maintain the value of the line edit.')
self.edit = flx.LineEdit(placeholder_text='username',
text=self.session.get_cookie('username', ''))
self.b1 = flx.RadioButton(text='Linear')
self.b2 = flx.RadioButton(text='Basis')
self.b3 = flx.RadioButton(text='Cardinal', checked=True)
self.b4 = flx.RadioButton(text='Catmull Rom')
self.b5 = flx.RadioButton(text='Lagrange')
self.b6 = flx.RadioButton(text='Lanczos')
flx.Widget(minsize=10)
closed = flx.CheckBox(text='Closed')
flx.Widget(minsize=10)
self.tension = flx.Slider(min=-0.5, max=1, value=0.5,
text='Tension: {value}')
flx.Widget(flex=1)
with flx.VBox(flex=1):
flx.Label(text=GENERAL_TEXT, wrap=True, style='font-size: 12px;')
self.explanation = flx.Label(text=CARDINAL_TEXT, wrap=True,
style='font-size: 12px;')
self.spline = SplineWidget(flex=1,
closed=lambda: closed.checked,
tension=lambda: self.tension.value)
with flx.VBox(flex=0, minsize=150):
self.b1 = flx.RadioButton(text='Linear')
self.b2 = flx.RadioButton(text='Basis')
self.b3 = flx.RadioButton(text='Cardinal', checked=True)
self.b4 = flx.RadioButton(text='Catmull Rom')
self.b5 = flx.RadioButton(text='Lagrange')
self.b6 = flx.RadioButton(text='Lanczos')
flx.Widget(minsize=10)
closed = flx.CheckBox(text='Closed')
flx.Widget(minsize=10)
self.tension = flx.Slider(min=-0.5, max=1, value=0.5,
text='Tension: {value}')
flx.Widget(flex=1)
with flx.VBox(flex=1):
flx.Label(text=GENERAL_TEXT, wrap=True, style='font-size: 12px;')
self.explanation = flx.Label(text=CARDINAL_TEXT, wrap=True,
style='font-size: 12px;')
self.spline = SplineWidget(flex=1,
closed=lambda: closed.checked,
tension=lambda: self.tension.value)