def init(self): with ui.VBox(): ui.Label(text=self.TITLE) self.slider1 = ui.Slider() self.slider2 = ui.Slider() ui.Widget(flex=1)
def init(self): with ui.SplitPanel(): self.plot1 = ui.BokehWidget(plot=p1, title='Scatter') with ui.VBox(title='Sine'): with ui.FormLayout(): self.amp = ui.Slider(title='Amplitude', max=2, value=1) self.freq = ui.Slider(title='Frequency', max=10, value=5) self.phase = ui.Slider(title='Phase', max=3, value=1) with ui.Widget(style='overflow-y:auto;', flex=1): self.plot2 = ui.BokehWidget(plot=p2) self.plot3 = ui.BokehWidget(plot=p3)
def init(self): self.layout = ui.PlotLayout() self.slider1 = ui.Slider(min=1, max=2, value=1) self.slider2 = ui.Slider(min=3, max=10, value=3) self.progress = ui.ProgressBar(max=100, value=0) self.layout.add_tools( 'Edit plot', ui.Label(text='exponent'), self.slider1, ui.Label(text='numel'), self.slider2, ) self.layout.add_tools('Plot info', ui.Label(text='Maximum'), self.progress)
def init(self): with ui.DockPanel(): self.plot1 = ui.BokehWidget(plot=p1, title='Scatter') with ui.VBox(title='Sine'): with ui.FormLayout(): self.amp = ui.Slider(title='Amplitude', max=2, value=1) self.freq = ui.Slider(title='Frequency', max=10, value=5) self.phase = ui.Slider(title='Phase', max=3, value=1) with ui.Widget(style='overflow-y:auto;', flex=1): self.plot2 = ui.BokehWidget(plot=p2) self.plot3 = ui.BokehWidget(plot=p3) # Add some colorful panels just for fun ui.Label(title='Info', text='Source is <a href="%s">%s</a>' % (src, src)) ui.Widget(style='background:#0a0;', title='green') ui.Widget(style='background:#00a;', title='blue')
def init(self): with ui.HBox(): with ui.VBox(flex=0): self.b1 = ui.RadioButton(text='Linear') self.b2 = ui.RadioButton(text='Basis') self.b3 = ui.RadioButton(text='Cardinal', checked=True) self.b4 = ui.RadioButton(text='Catmull Rom') self.b5 = ui.RadioButton(text='Lagrange') self.b6 = ui.RadioButton(text='Lanczos') ui.Widget(style='min-height:10px') self.closed = ui.CheckBox(text='Closed') ui.Widget(style='min-height:10px') self.tension_label = ui.Label(text='Tension: 0.5') self.tension = ui.Slider(min=-0.5, max=1, value=0.5) ui.Widget(flex=1) with ui.VBox(flex=1): ui.Label(text=GENERAL_TEXT, wrap=True, style='font-size: 12px;') self.explanation = ui.Label(text=CARDINAL_TEXT, wrap=True, style='font-size: 12px;') self.spline = SplineWidget(flex=1)
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): # Put a label and some sliders deep in the hierarchy with ui.HBox(): with ui.VBox(flex=1) as self.box: self.label = ui.Label() for i in range(5): ui.Slider(value=i / 5)
def init(self): with ui.HBox(): ui.Widget(flex=1) with ui.VBox(flex=0): with ui.GroupWidget(title='Plot options'): with ui.VBox(): self.month_label = ui.Label(text='Month') self.month = ui.Slider(max=12, step=1) self.smoothing_label = ui.Label(text='Smoothing') self.smoothing = ui.Slider(max=20, step=2) ui.Widget(flex=1) with ui.VBox(flex=4): self.plot = ui.PlotWidget(flex=1, xdata=years, yrange=(-5, 20), title='Average monthly temperature', xlabel='year', ylabel=u'temperature (°C)') ui.Widget(flex=0, style='height:30px') ui.Widget(flex=1)
def init(self): with ui.HFix(): ui.Widget(flex=1) with ui.VBox(flex=0, style='min-width:200px'): with ui.GroupWidget(title='Plot options'): ui.Label(text='Month') self.month = ui.ComboBox(options=months, selected_index=12, style='width: 100%') self.smoothing_label = ui.Label(text='Smoothing') self.smoothing = ui.Slider(max=20, step=2, text='{value} samples') ui.Widget(flex=3) with ui.VBox(flex=4): self.plot = ui.PlotWidget(flex=1, xdata=years, yrange=(-5, 20), title='Average monthly temperature', xlabel='year', ylabel=u'temperature (°C)') ui.Widget(flex=1)
def init(self): with ui.HBox(style='width: 480px'): with ui.VBox(style='height: 200px'): with ui.HBox(): self.temps = [ ui.Label( text='??°', style='font-weight: bold; font-size: xx-large'), ui.Label( text='??°', style='font-weight: bold; font-size: xx-large') ] with ui.HBox(): ui.Label(text="{} <= ".format(self.min_duty)) self.duty_edit = ui.LineEdit(text=self.init_duty) ui.Label(text=" <= {}".format(self.max_duty)) with ui.HBox(): self.duty_slider = ui.Slider(flex=1, min=self.min_duty, max=self.max_duty, step=10) # Relay global info into this app relay.connect(self.push_info, 'system_info:' + self.id)
def init(self): self.fields = {} self.radio_buttons = {} self.result_property = {} self.slider_to_textfield = {} self.textfield_to_slider = {} self.int_sliders = set() self.sliders = [] with ui.GroupWidget(title="Simulation parameter"): ui.Label(text="scroll down to start", style="float: right; color: steelblue", wrap=True) for parameter, value in list(parameter_mask.items()): try: title = names[parameter] except KeyError: title = parameter if isinstance(value, bool): self.fields[parameter] = ui.CheckBox(text=title) self.result_property[parameter] = 'checked' elif isinstance(value, list): self.radio_buttons[parameter] = {} with ui.GroupWidget(title=title, style="width:fit-content;"): for option in value: self.radio_buttons[parameter][option] = \ ui.RadioButton(text=option) self.radio_buttons[parameter][value[0]].checked = True else: if isinstance(value, tuple): min_value, default, max_value = sorted(value) elif isinstance(value, (int, float)): min_value, default, max_value = 0, value, value * 2 is_integer = False if isinstance(value, (int, float, tuple)): if (isinstance(default, int) and isinstance(max_value, int)): step = 1 is_integer = True # if default is float, type is float if isinstance(default, float): step = (max_value - min_value) / 100 else: step = (max_value - min_value) / 100 with ui.Widget(): ui.Label(text=title, wrap=True) slider = ui.Slider(min=min_value, max=max_value, value=default, step=step) lineeditor = ui.LineEdit(title=title, text=default) self.sliders.append((slider, lineeditor)) self.fields[parameter] = slider self.result_property[parameter] = 'value' slider.connect('value', self.stt) lineeditor.connect('submit', self.tts) self.slider_to_textfield[slider] = lineeditor self.textfield_to_slider[lineeditor] = slider if is_integer: self.int_sliders.add(slider) elif isinstance(value, str): with ui.Widget(): ui.Label(text=title, wrap=True, style="width: 80%") self.fields[parameter] = \ ui.LineEdit(title=title, text=value, style='width: 95%;') self.result_property[parameter] = 'text' elif value is None: ui.Label(text=title, wrap=True) else: # field print(str(value) + "not recognized") with ui.VBox(): self.btn = ui.Button(text="start simulation") with ui.GroupWidget(title="Save"): with ui.HBox(): self.name = ui.LineEdit(title="Name:", placeholder_text='name') self.save = ui.Button(text="Save Parameters") self.description = ui.LineEdit( title="Description", text='', style='width: 95%;', placeholder_text='description')
def init(self): #self.b0 = ui.Button(self, 'This is behind the box layout') TEST = 11 if TEST == 0: ui.Button(text='Hola', flex=1) if TEST == 1: with ui.BoxPanel(flex=1) as self.hbox1: # self.b1 = ui.Widget(flex=1, style='background: #a22;', min_size=(100, 100), max_size=(500,0)) # self.b2 = ui.Widget(flex=0, style='background: #2a2;', min_size=(100, 0), max_size=(500,0)) # self.b3 = ui.Widget(flex=0, style='background: #22a;', min_size=(100, 0), max_size=(500,0)) # self.b4 = ui.Widget(flex=1, style='background: #aaa;', min_size=(100, 0), max_size=(500,0)) self.b1 = ui.Widget(flex=1, style='background: #a22; min-width:100px; max-width:500px') self.b2 = ui.Widget(flex=0, style='background: #2a2; min-width:100px; max-width:500px') self.b3 = ui.Widget(flex=0, style='background: #22a; min-width:100px; max-width:500px') self.b4 = ui.Widget(flex=1, style='background: #aaa; min-width:100px; max-width:500px') if TEST == 2: with self: with ui.HBox(): ui.Widget(flex=1) with ui.VBox(flex=1) as self.vbox: ui.Label(text='Flex 0 0 0', flex=0) with ui.HBox(flex=0) as self.hbox1: self.b1 = ui.Button(text='Hola', flex=0) self.b2 = ui.Button(text='Hello world', flex=0) self.b3 = ui.Button(text='Foo bar', flex=0) ui.Label(text='Flex 1 0 3', flex=0) with ui.HBox(flex=0) as self.hbox2: self.b1 = ui.Button(text='Hola', flex=1) self.b2 = ui.Button(text='Hello world', flex=0) self.b3 = ui.Button(text='Foo bar', flex=3) ui.Label(text='margin 20 (around layout)', flex=0) with ui.HBox(flex=0, margin=20) as self.hbox3: self.b1 = ui.Button(text='Hola', flex=1) self.b2 = ui.Button(text='Hello world', flex=1) self.b3 = ui.Button(text='Foo bar', flex=1) ui.Label(text='spacing 20 (inter-widget)', flex=0) with ui.HBox(flex=0, spacing=20) as self.hbox3: self.b1 = ui.Button(text='Hola', flex=1) self.b2 = ui.Button(text='Hello world', flex=1) self.b3 = ui.Button(text='Foo bar', flex=1) ui.Widget(flex=1) ui.Label(text='Note the spacer Widget above', flex=0) if TEST == 3: with ui.HBox(spacing=20): with ui.FormLayout() as self.form: # e.g. self.b1 = ui.Button(label='Name', text='Hola') self.b1 = ui.Button(title='Name:', text='Hola') self.b2 = ui.Button(title='Age:', text='Hello world') self.b3 = ui.Button(title='Favorite color:', text='Foo bar') with ui.FormLayout() as self.form: # e.g. self.b1 = ui.Button(label='Name', text='Hola') ui.Widget(flex=1) # Add a flexer self.b1 = ui.Button(title='Name:', text='Hola') self.b2 = ui.Button(title='Age:', text='Hello world') self.b3 = ui.Button(title='Favorite color:', text='Foo bar') ui.Widget(flex=1) if TEST == 4: with ui.GridPanel() as self.grid: self.b1 = ui.Button(text='No flex', pos=(0, 0)) self.b2 = ui.Button(text='Hola', pos=(1, 1), flex=(1, 1)) self.b3 = ui.Button(text='Hello world', pos=(2, 2), flex=(2, 1)) self.b4 = ui.Button(text='Foo bar', pos=(4, 4), flex=(1, 2)) self.b5 = ui.Button(text='no flex again', pos=(5, 5)) if TEST == 5: with ui.SplitPanel(): ui.Widget(style='background:#aaa;') with ui.PinboardLayout() as self.grid: self.b1 = ui.Button(text='Stuck at (20, 20)', pos=(20, 30)) self.b2 = ui.Button(text='Dynamic at (20%, 20%)', pos=(0.2, 0.2)) self.b3 = ui.Button(text='Dynamic at (50%, 70%)', pos=(0.5, 0.7)) with ui.DockPanel(pos=(0.5, 0.5), size=(0.3, 0.3)) as self.d: self.a = ui.Widget(style='background:#a00;') self.b = ui.Widget(style='background:#0a0;') self.c = ui.Widget(style='background:#00a;') if TEST == 6: with ui.SplitPanel(): self.a = ui.Button(text='Right A', style='min-width:120px') self.b = ui.Button(text='Right B', style='min-width:70px') with ui.SplitPanel(orientation='v'): self.c = ui.Button(text='Right C') self.d = ui.Button(text='Right D') with ui.DockPanel(): ui.Slider(title='slider') ui.LineEdit(title='edit', text='AAA') self.g = ui.ProgressBar(title='progress', value=0.4) if TEST == 7: with ui.HBox(): ui.Button(text='Button in hbox', flex=0) with ui.SplitPanel(flex=1, orientation='v'): ui.Button(text='Button in splitter', style='min-width:100px') with ui.HBox(style='min-width:100px'): ui.Button(text='Right A', flex=0, style='background:#f00; padding:2em;') ui.Button(text='Right B', flex=1) ui.Button(text='Right C', flex=2) if TEST == 8: with ui.MenuBar(self): with ui.MenuItem(text='File'): ui.MenuItem(text='New') ui.MenuItem(text='Open') ui.MenuItem(text='Save') with ui.MenuItem(text='Edit'): ui.MenuItem(text='Cut') ui.MenuItem(text='Copy') ui.MenuItem(text='Paste') if TEST == 9: with ui.VBox(): ui.Button(text='AAA', flex=0) with ui.SplitPanel(flex=1, orientation='v'): ui.Button(text='CCC') ui.Button(text='DDD') self.e = ui.Button(text='EEE') ui.Button(text='BBB', flex=1) if TEST == 10: with ui.TabPanel(): self.a = ui.Widget(title='red', style='background:#a00;') self.b = ui.Widget(title='green', style='background:#0a0;') self.c = ui.Widget(title='blue', style='background:#00a;') if TEST == 11: with ui.BoxPanel(spacing=10): with ui.GridPanel() as self.g1: self.a = ui.Widget(style='background:#a00;', pos=(0, 0), flex=1) self.b = ui.Widget(style='background:#0a0;', pos=(1, 0)) self.c = ui.Widget(style='background:#00a; min-width:200px; min-height:200px', pos=(1, 1)) with ui.GridPanel() as self.g2: self.a = ui.Widget(style='background:#a00;', pos=(0, 0), flex=2) self.b = ui.Widget(style='background:#0a0; max-width:100px;', pos=(1, 0), flex=1) self.c = ui.Widget(style='background:#00a;', pos=(1, 1), flex=1) if TEST == 12: with ui.HBox(): with ui.VBox(): self.buta = ui.Button(text='red') self.butb = ui.Button(text='green') self.butc = ui.Button(text='blue') with ui.StackedPanel(flex=1) as self.stack: self.a = ui.Widget(style='background:#a00;') self.b = ui.Widget(style='background:#0a0;') self.c = ui.Widget(style='background:#00a;')
def init(self): self.amp = ui.Slider(title='Amplitude', max=2, value=1) self.freq = ui.Slider(title='Frequency', max=10, value=5) self.phase = ui.Slider(title='Phase', max=3, value=1)