def init(self): flx.Widget(flex=1) with flx.VBox(): with flx.HBox(): self.b1 = flx.Button(text='Hello', css_class="border-red", flex=1) self.b2 = flx.Button(text='World', css_class="border-green", flex=1) flx.Widget(flex=1)
def init(self): with flx.HBox(): 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=lambda: '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)
def init(self): self.main_container = flx.VSplit( style='font-family: "Helvetica Neue";') with self.main_container: with flx.VSplit(flex=2): self.image = flx.Widget(flex=4, style='background: black;') self.title_w = flx.Widget(flex=1) with self.title_w: self.title = ui.Label(wrap=True) self.overview_w = flx.Widget(flex=1, style='height: 10vh;') with self.overview_w: self.overview = ui.Label(wrap=True) with flx.HBox(flex=1): # self.h_button = flx.Button(text='Horrible', flex=1) self.m_button = flx.Button(text='Meh', flex=1) self.n_button = flx.Button(text='Neutral', flex=1) self.g_button = flx.Button(text='Yeah!', flex=1) # self.a_button = flx.Button(text='Amazing', flex=1) with flx.HBox(flex=0): self.slider = ui.Slider(text='Exploration/Exploitation', flex=3, min=0, max=1, step=0.01, value=sliderValue) # self.label = ui.Label(flex=1) # self.label = flx.Label(flex=1) # class JS: # @react.connect('slider.value') # def _change_label(self, value): # self.label.text('x'.repeat(value)) self.set_movie()
def init(self): super().init() with flx.VBox(): flx.Label(text='You should see 5 pairs of buttons') with flx.HFix(): # Use minsize in CSS of button widget with flx.GroupWidget(title='asdas'): with flx.HFix(): flx.Button(text='foo') flx.Button(text='bar') with flx.HFix(minsize=50): # Set minsize prop on container flx.Button(text='foo') flx.Button(text='bar') with flx.HFix(): # Set minsize prop on widget flx.Button(text='foo', minsize=50) flx.Button(text='bar') with flx.HFix(): # Old school setting of style flx.Button(text='foo', style='min-height:50px;') flx.Button(text='bar', ) with flx.Widget(): # Singleton widgets (e.g. custom classes) with flx.HFix(): flx.Button(text='foo') flx.Button(text='bar') flx.Widget(flex=1, style='background:#f99;') # spacer
def init(self): self.set_title("MODEL PARAMTERS") with flx.FormLayout() as self.model_params_form: flx.Widget(flex=1) self.exterior_wall = flx.LineEdit( title='Exterior Wall', text='{}'.format(tuple(self.root.exterior_wall_tuple))) self.exterior_roof = flx.LineEdit( title='Exterior Roof', text='{}'.format(tuple(self.root.exterior_roof_tuple))) self.exterior_window = flx.LineEdit(title='Exterior Window', text='{}'.format( tuple(self.root.exterior_window_tuple))) self.eastrate = flx.LineEdit( title='East winwall ratio', text='{}'.format(tuple(self.root.eastrate_tuple))) self.westrate = flx.LineEdit( title='West winwall ratio', text='{}'.format(tuple(self.root.westrate_tuple))) self.southrate = flx.LineEdit( title='South winwall ratio', text='{}'.format(tuple(self.root.southrate_tuple))) self.northrate = flx.LineEdit( title='North winwall ratio', text='{}'.format(tuple(self.root.northrate_tuple))) self.direction = flx.LineEdit( title='direction(deg)', text='{}'.format(tuple(self.root.direction_tuple))) self.airchange = flx.LineEdit( title='airchange', text='{}'.format(tuple(self.root.airchange_tuple))) self.cop = flx.LineEdit( title='cop', text='{}'.format(tuple(self.root.cop_tuple))) self.east_shading = flx.LineEdit( title='east shading', text='{}'.format(tuple(self.root.east_shading_tuple))) self.west_shading = flx.LineEdit( title='west shading', text='{}'.format(tuple(self.root.west_shading_tuple))) self.south_shading = flx.LineEdit( title='south shading', text='{}'.format(tuple(self.root.south_shading_tuple))) self.north_shading = flx.LineEdit( title='north shading', text='{}'.format(self.root.north_shading_tuple)) self.infiltration_airchange = flx.LineEdit( title='infiltration airchange', text='{}'.format(self.root.infiltration_airchange_tuple)) flx.Widget(flex=1)
def init(self, retico_widget, mpane, module_list, file_list): self.retico_widget = retico_widget self.mpane = mpane with flx.VBox(css_class="stupid-vbox") as stupid_vbox: stupid_vbox.set_padding("20px") with flx.TreeWidget(max_selected=1, style="height: 300px;", flex=1) as self.module_tree: for k in module_list.keys(): with flx.TreeItem(text=k, checked=None): for m in module_list[k]: flx.TreeItem(text=m, checked=None) self.add_module_button = flx.Button(text="Add Module") flx.Widget(style="min-height:50px;") self.run_button = flx.Button(text="Run", css_class="menu-button") self.stop_button = flx.Button(text="Stop", css_class="menu-button") self.stop_button.set_disabled(True) flx.Widget(style="min-height:50px;") self.file_tree = flx.TreeWidget(max_selected=1, style="height:300px;", flex=1) self.update_file_tree(file_list) self.load_button = flx.Button(text="Load") self.filename_edit = flx.LineEdit() self.save_button = flx.Button(text="Save") self.clear_button = flx.Button(text="Clear") flx.Widget(flex=1)
def init(self): with flx.VFix(): flx.Widget(flex=1) with flx.HFix(flex=2): flx.Widget(flex=1) Drawing(flex=2) flx.Widget(flex=1) flx.Widget(flex=1)
def init(self): with flx.HBox(flex=1, style="background: #e6e6df;"): with flx.FormLayout(flex=1): flx.Widget(minsize=20) self.heading = flx.LineEdit(title="Heading", text="") self.pitch = flx.LineEdit(title="Pitch", text="") self.roll = flx.LineEdit(title="Roll", text="") flx.Widget(minsize=40) with flx.FormLayout(flex=1): flx.Widget(minsize=20) self.depth = flx.LineEdit(title="Depth", text="") self.xpos = flx.LineEdit(title="X", text="") self.ypos = flx.LineEdit(title="Y", text="") flx.Widget(minsize=40) with flx.FormLayout(flex=1): flx.Widget(minsize=20) self.xvel = flx.LineEdit(title="X vel", text="") self.yvel = flx.LineEdit(title="Y vel", text="") self.zvel = flx.LineEdit(title="Z vel", text="") flx.Widget(minsize=40) with flx.FormLayout(flex=1): flx.Widget(minsize=20) self.gps_status = flx.LineEdit(title="GPS Status", text="") self.dvl_status = flx.LineEdit(title="DVL Status", text="") self.battery_status = flx.LineEdit(title="Battery level", text="") flx.Widget(minsize=40) with flx.FormLayout(flex=1): flx.Widget(minsize=20) self.vbs_fb = flx.LineEdit(title="VBS fb", text="") self.lcg_fb = flx.LineEdit(title="LCG fb", text="") self.rpm_fb = flx.LineEdit(title="RPM fb", text="") flx.Widget(minsize=40) # We subscribe to these topics at full frquency (no extra arg) self.subscribe("/sam/core/gps", "sensor_msgs/NavSatFix", self.gps_callback) self.subscribe("/sam/core/battery_fb", "sensor_msgs/BatteryState", self.battery_callback) # We only subscribe to these topics at 1hz self.subscribe("/sam/dr/odom", "nav_msgs/Odometry", self.odom_callback, 1.) self.subscribe("/sam/core/vbs_fb", "sam_msgs/PercentStamped", self.vbs_callback, 1.) self.subscribe("/sam/core/lcg_fb", "sam_msgs/PercentStamped", self.lcg_callback, 1.) self.subscribe("/sam/ctrl/depth_feedback", "std_msgs/Float64", self.depth_callback, 1.) self.subscribe("/sam/ctrl/pitch_feedback", "std_msgs/Float64", self.pitch_callback, 1.) self.subscribe("/sam/ctrl/roll_feedback", "std_msgs/Float64", self.roll_callback, 1.) self.subscribe("/sam/ctrl/yaw_feedback", "std_msgs/Float64", self.yaw_callback, 1.)
def init(self): with MyHBox(): with MyVBox(flex=2): with MyVBox(flex=4, spacing=30): flx.Widget(flex=1, css_class='white') flx.Widget(flex=1, css_class='white') with MyVBox(flex=2, css_class='blue'): flx.Widget(flex=1, css_class='edge') flx.Widget(flex=1, css_class='edge') with MyVBox(flex=6): with MyVBox(flex=4, spacing=30, css_class='red'): flx.Widget(flex=1, css_class='edge') flx.Widget(flex=1, css_class='edge') with MyHBox(flex=2): flx.Widget(flex=6, css_class='white') with MyVBox(flex=1): flx.Widget(flex=1, css_class='white') flx.Widget(flex=1, css_class='yellow')
def init(self): with flx.VBox(): with flx.HBox(): self.buta = flx.Button(text='red') self.butb = flx.Button(text='green') self.butc = flx.Button(text='blue') flx.Widget(flex=1) # space filler with flx.StackLayout(flex=1) as self.stack: self.buta.w = flx.Widget(style='background:#a00;') self.butb.w = flx.Widget(style='background:#0a0;') self.butc.w = flx.Widget(style='background:#00a;')
def init(self, model, module_list, file_list): self.model = model self.connection_list = [] self.running = False with flx.HSplit(): with flx.Widget(flex=3): self.mpane = ModulePane(self) with flx.Widget(flex=1): self.menu = MenuPane(self, self.mpane, module_list, file_list, style="height:100%;")
def init(self): with flx.HBox(title='Flexx chatroom demo'): flx.Widget(flex=1) with flx.VBox(): self.name_edit = flx.LineEdit(placeholder_text='your name') self.people_label = flx.Label(flex=1, minsize=250) with flx.VBox(minsize=450): self.messages = MessageBox(flex=1) with flx.HBox(): self.msg_edit = flx.LineEdit( flex=1, placeholder_text='enter message') self.ok = flx.Button(text='Send') flx.Widget(flex=1) self._update_participants()
def init(self): self.nsamples = 200 self.start_time = time() self.status = flx.Label(text='...') self.plot_num = 3 self.plot = [] self.plot_combobox = [] self.plot_label = [] self.plot_latest_val = [] self.latest_params_names = {} self.latest_params_values = {} with flx.HSplit(flex=1): with flx.GroupWidget(flex=1, title="Plot options", minsize=(270,0)): with flx.VBox(): self.buttons = {} button_list = list(SolarData.commands.keys()) for button_name in button_list: with flx.HBox(): self.buttons[button_name] = flx.Button(text=button_name) setattr(self.buttons[button_name],'button_action', button_name) self.buttons[button_name].reaction(self._on_button_pressed, 'pointer_click') self.buttons[button_name].reaction(self._on_button_down, 'pointer_down') self.buttons[button_name].reaction(self._on_button_up, 'pointer_up') flx.Widget(flex=1) for i in range(0, self.plot_num): with flx.HBox(): self.plot_combobox[i] = flx.ComboBox(options=list(SolarData.params.keys()), editable=False, selected_index=i) self.plot_combobox[i].reaction(self.combobox_changed, 'user_selected') self.plot_label[i] = flx.Label(text='Value:') self.plot_latest_val[i] = flx.Label(text='') flx.Widget(flex=1) for i in range(0, len(SolarData.params.keys())): with flx.HBox(): name = list(SolarData.params.keys())[i] self.latest_params_names[name] = flx.Label(text='{0}:'.format(name)) self.latest_params_values[name] = flx.Label(text='NaN') flx.Widget(flex=1) flx.Widget(flex=1) with flx.VBox(flex=4): for i in range(0, self.plot_num): self.plot[i] = flx.PlotWidget(flex=1, minsize=(270,0), style='width: 640px; height: 320px;',xdata=[], yrange=(0, 100),ylabel='Plot ' + str(i+1)) self.update_plot_range(i)
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', ''))
def init(self, model): super().init() self.model = model # App layout with flx.VBox(): flx.Label(flex=0, text=lambda: model.status) flx.Widget(flex=1) with flx.HBox(flex=2): flx.Widget(flex=1) self.canvas = flx.CanvasWidget(flex=0, minsize=400, maxsize=400) flx.Widget(flex=1) flx.Widget(flex=1) # Init context to draw to self._ctx = self.canvas.node.getContext('2d')
def init(self): with flx.FormLayout() as self.form: self.update_button = flx.Button(text='Update JAR', flex=1) flx.Widget(flex=1) self.name = flx.LineEdit(title='Display Name') self.rotation = flx.ComboBox(title='Rotation:', options=rotations, selected_index=0) self.new_screen = flx.Button(text='Create New Display', flex=1)
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): with flx.HSplit(minsize=300) as self.widget: self.plot1 = flx.BokehWidget.from_plot(p1, title='Scatter') with flx.VFix(title='Sine'): Controls() with flx.Widget(style='overflow-y:auto;', flex=1): self.plot2 = flx.BokehWidget.from_plot(p2) self.plot3 = flx.BokehWidget.from_plot(p3)
def init(self): with flx.VBox(): with flx.HBox(): self.first_edit = flx.LineEdit(placeholder_text='first name', text='Jane') self.last_edit = flx.LineEdit(placeholder_text='last name', text='Doe') flx.Widget(flex=1) # spacer with flx.HBox(): flx.Label(text=lambda: self.root.first_name, style='border:1px solid red') flx.Label(text=lambda: self.root.last_name, style='border:1px solid red') flx.Widget(flex=1) # spacer MyPersonLabel(style='border:1px solid blue') flx.Widget(flex=1) # spacer
def init(self): self.json = None with flx.FormLayout() as self.form: self.name = flx.ComboBox(title='Display Name:', options=screens) self.rotation = flx.ComboBox(title='Rotation:', options=rotations) flx.Widget(flex=1) with flx.TreeWidget(flex=2, title='Defaults:', max_selected = 1) as self.default_box: self.defaults = [] for i in range(max_scheduled): self.defaults[i] = flx.TreeItem(title=str(i), checked=False) self.defaults[i].set_visible(False) with flx.TreeWidget(flex=2, title='Events:', max_selected = 1) as self.event_box: self.events = [] for i in range(max_scheduled): self.events[i] = flx.TreeItem(title=str(i), checked=False) self.events[i].set_visible(False) self.delete = flx.Button(text='Delete Selected Entries') self.revert = flx.Button(text='Revert Changes') self.upload = flx.Button(text='Save and Upload') flx.Widget(flex=5)
def init(self): # Create our store instance self._mutate_store(Store()) # Imagine this being a large application with many sub-widgets, # and the UserInput and SomeInfoWidget being used somewhere inside it. with flx.HSplit(): UserInput() flx.Widget(style='background:#eee;') SomeInfoWidget()
def init(self): self.set_title("Openlayers example") with flx.VBox(): with flx.HBox(): self.map = Ol(flex=1) self.btn = flx.Button(text="", disabled=True) with flx.VBox(): self.btnosm = flx.Button(text='Load Openstreetmap') self.btna = flx.Button(text='Load GEOJSON') self.btnr = flx.Button(text='Remove GEOJSON') self.btndraw = flx.Button(text='Draw Points') self.btn_stop_draw = flx.Button(text='Stop Drawing') flx.Widget(flex=1) self.coords = flx.Label(flex=1)
def init(self): with flx.HFix(): with flx.FormLayout() as self.form: self.b1 = flx.LineEdit(title='Name:', text='Hola') self.b2 = flx.LineEdit(title='Age:', text='Hello world') self.b3 = flx.LineEdit(title='Favorite color:', text='Foo bar') flx.Button(text='Submit') with flx.FormLayout() as self.form: self.b4 = flx.LineEdit(title='Name:', text='Hola') self.b5 = flx.LineEdit(title='Age:', text='Hello world') self.b6 = flx.LineEdit(title='Favorite color:', text='Foo bar') flx.Button(text='Submit') flx.Widget(flex=1) # Add a spacer
def init(self): with flx.HFix(): flx.Widget(flex=1) with flx.VBox(flex=0, style='min-width:200px'): with flx.GroupWidget(title='Plot options'): flx.Label(text='Month') self.month = flx.ComboBox(options=months, selected_index=12, style='width: 100%') self.smoothing_label = flx.Label(text='Smoothing') self.smoothing = flx.Slider(max=20, step=2, text='{value} samples') flx.Widget(flex=3) with flx.VBox(flex=4): self.plot = flx.PlotWidget(flex=1, xdata=years, yrange=(-5, 20), title='Average monthly temperature', xlabel='year', ylabel=u'temperature (°C)') flx.Widget(flex=1)
def init(self): with flx.FormLayout(): with flx.TreeWidget(flex=2, title='Defaults:'): self.defaults = [] for i in range(max_scheduled): self.defaults[i] = flx.TreeItem(checked=False) self.defaults[i].set_visible(False) flx.Widget(flex=1) with flx.TreeWidget(title='Screens', max_selected=0) as self.screens: self.screens = [] for i in range(screen_num): self.screens[i] = flx.TreeItem(checked=False) self.screens[i].set_visible(False) self.update_screens() self.add_button = flx.Button(text='Add New Default')
def init(self): with ui.VSplit(): with ui.HFix(flex=0): self.previous = ui.Button(text="<-", disabled=True, flex=1) self.content = ui.Label(flex=0) self.next = ui.Button(text="->", disabled=True, flex=1) with ui.HSplit(flex=1, spacing=20): self.configure = flx.Widget(css_class="configure", flex=0) with ui.HFix(flex=1): self.visjs = VisJS( style="background-color: #dddddd;", flex=1, ) self.refresh()
def init(self, server_name, server_type): self.is_init = False self.server_name = server_name with flx.GroupWidget(title=server_name, flex=1): with flx.FormLayout(flex=1): self.arguments = flx.LineEdit(title="Args", text="") self.feedback = flx.LineEdit(title="Feedback", text="") self.result = flx.LineEdit(title="Result", text="") self.send_goal = flx.Button(text="Send goal") flx.Widget(minsize=40) self.reaction(self._prototype_callback, "!root." + server_name.replace("/", "_") + "_prototype") self.announce_action_client(server_name, server_type)
def init(self): with flx.VBox(): flx.Label(style="text-align:center", text="Networking") with flx.HBox(): with flx.VBox(): flx.Label(style="text-align:right", text="AP Name:") flx.Label(style="text-align:right", text="Password:"******"background-color:#BBBBBB;text-align:center", placeholder_text="ssid") self.fieldPassword = flx.LineEdit( style="background-color:#BBBBBB;text-align:center", placeholder_text="psk") self.submitButton = flx.Button(text='Submit') flx.Widget(flex=1)
def init(self, name, actuator_type, setpoint_topic, feedback_topic, cont_enable_topic, cont_setpoint_topic, cont_min, cont_max, is_angles=False): self.setpoint_topic = setpoint_topic self.cont_setpoint_topic = cont_setpoint_topic self.cont_enable_topic = cont_enable_topic self.is_angles = is_angles with flx.GroupWidget(title=name, flex=1): with flx.FormLayout(flex=1): flx.Label(text="Actuator setpoint") if is_angles: self.set_slider = flx.Slider(title="0", min=-1.6, max=1.6) self.set_slider2 = flx.Slider(title="0", min=-1.6, max=1.6) else: self.set_slider = flx.Slider(title="50", min=0, max=100, value=50) flx.Label(text="Controller setpoint") self.enable_cont = flx.CheckBox(title="Enabled") self.enable_cont.set_checked(True) self.cont_slider = flx.Slider(title="0", min=cont_min, max=cont_max, value=0) flx.Widget(minsize=20) self.announce_publish(setpoint_topic, actuator_type) self.announce_publish(cont_setpoint_topic, "std_msgs/Float64") self.announce_publish(cont_enable_topic, "std_msgs/Bool") self.subscribe(setpoint_topic, actuator_type, self._setpoint_callback) self.subscribe(cont_setpoint_topic, "std_msgs/Float64", self._cont_callback) self.subscribe(cont_enable_topic, "std_msgs/Bool", self._enable_callback) if is_angles: self.reaction(self._setpoint_slider, "set_slider2.user_done")
def init(self): combo_options = ['Paris', 'New York', 'Enschede', 'Tokio'] with flx.HBox(): self.tree = TreeWithControls(flex=1, max_selected=1) with flx.VBox(flex=1): self.combo = flx.ComboBox(options=combo_options, editable=True) flx.Widget( flex=1) # combobox needs space below it to show dropdown with self.tree: for cat in ('foo', 'bar', 'spam'): with flx.TreeItem(text=cat): for name in ('Martin', 'Kees', 'Hans'): item = flx.TreeItem(title=name) item.set_checked(cat == 'foo' or None)