예제 #1
0
 def init(self):
     with ui.HBox(flex=1):
         with ui.Widget(flex=1,style="overflow-y:scroll"):
             with ui.VBoxPanel(flex=0) as self.leftView:
                 with ui.HBox(flex=0,style="background:#ee0;min-height:40px;max-height:40px"):
                     ui.Label(text="<b>主设备</b>")
                     ui.Label(text="<b>从设备</b>")
         with ui.VBox(flex=0,padding=6,style="background:#eee;color:#000;min-width:200px"):
             self.listenMode = ui.RadioButton(text="CEV485监听模式",checked=True)
             self.simuAllClient = ui.RadioButton(text="模拟所有客户端响应")
             self.simuOneKeyModClient = ui.RadioButton(text="模拟一键报警")
             self.btnStart = ui.Button(text="模拟启动",css_class="button button-primary button-rounded button-small",pos=(10,10),base_size=(160,32))
             ui.Widget(flex=1)
예제 #2
0
파일: splines.py 프로젝트: silky/flexx
    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)
예제 #3
0
        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')