def main(self):

        vertContainer = gui.Widget(
            width='80%',
            layout_orientation=gui.Widget.LAYOUT_VERTICAL,
            margin='0px auto',
            style={
                'display': 'block',
                'overflow': 'auto',
                'background-color': '#BEBEBE'
            })
        vertContainer.style['text-align'] = 'center'
        vertContainer.style['align-items'] = 'center'
        vertContainer.style['justify-content'] = 'center'

        wid = gui.VBox(width=300, height=200, margin='0px auto')
        self.lbl1 = gui.Label('bottom text')
        self.lbl1.style['margin'] = 'auto'
        wid.append(self.lbl1)

        self.img = gui.Image('/res/wildcat.png', height=150, margin='0px auto')

        b1 = gui.Button('Add new tab', width=200, height=30)
        b2 = gui.Button('Show third tab', width=200, height=30)
        b3 = gui.Button('Show first tab', width=200, height=30)

        tb = gui.TabBox(width='100%')
        tb.add_tab([b1, b2], 'First', None)

        b1.set_on_click_listener(self.on_bt1_pressed, tb, 0)
        b2.set_on_click_listener(self.on_bt2_pressed, tb, 0)

        vertContainer.append(tb)

        return vertContainer
Beispiel #2
0
    def main(self):

        b1 = gui.Button('Show second tab', width=200, height=30)

        tb = gui.TabBox(width='80%')
        tb.style.update({
            "margin": "0px",
            "width": "40%",
            "height": "95%",
            "top": "3%",
            "left": "5%",
            "position": "absolute",
            "overflow": "auto",
            "background-color": "#e4e4e4",
            "border-width": "0px",
            "border-style": "None",
            "border-color": "#a8a8a8"
        })
        tb.add_tab(b1, 'First', None)

        b2 = gui.Button('Show third tab', width=200, height=30)
        tb.add_tab(b2, 'Second', None)

        b3 = gui.Button('Show first tab', width=200, height=30)
        tb.add_tab(b3, 'Third', None)

        b1.onclick.do(self.on_bt1_pressed, tb, b2)
        b2.onclick.do(self.on_bt2_pressed, tb, 'Third')
        b3.onclick.do(self.on_bt3_pressed, tb, 0)

        return tb
Beispiel #3
0
    def update_tabs(self, user):
        self.tab_box = gui.TabBox(width="80%")
        for type_ in ExperimentType:
            self.widget = gui.Widget(width="100%")
            button = gui.Button(f"Run {type_.name} view experiment", margin="10px")
            button.set_on_click_listener(self.run_experiment, user, type_)
            self.widget.append(button)

            if type_ in self._user_tlx_tables:
                print("Found it!")
                self.widget.append(self._user_tlx_tables[type_])

            self.tab_box.add_tab(self.widget, f"{type_.name} view", None)
Beispiel #4
0
    def main(self):

        b1 = gui.Button('First Button', width=200, height=30)

        tb = gui.TabBox(width='80%')
        tb.add_tab(b1, 'First', None)

        b2 = gui.Button('Second Button', width=200, height=30)
        tb.add_tab(b2, 'Second', None)

        b3 = gui.Button('Third Button', width=200, height=30)
        tb.add_tab(b3, 'Third', None)

        return tb
Beispiel #5
0
    def main(self):

        b1 = gui.Button('Show second tab', width=200, height=30)

        tb = gui.TabBox(width='80%')
        tb.add_tab(b1, 'First', None)

        b2 = gui.Button('Second Button', width=200, height=30)
        tb.add_tab(b2, 'Second', None)

        b3 = gui.Button('Third Button', width=200, height=30)
        tb.add_tab(b3, 'Third', None)

        b1.set_on_click_listener(self.on_bt1_pressed, tb, b2)

        return tb
Beispiel #6
0
    def main(self):
        b1 = gui.Button('Timer Config', width=210, height=25)

        tb = gui.TabBox(width='100%', height='100%')
        tb.add_tab(b1, 'Timer Config', None)

        b2 = gui.Button('Timer Status', width=210, height=25)
        tb.add_tab(b2, 'Timer Status', None)

        b3 = gui.Button('Show first tab', width=210, height=25)
        tb.add_tab(b3, 'Third', None)

        b1.set_on_click_listener(self.on_bt1_pressed, tb, b2)
        b2.set_on_click_listener(self.on_bt2_pressed, tb, 'Third')
        b3.set_on_click_listener(self.on_bt3_pressed, tb, 0)

        return tb
Beispiel #7
0
    def main(self):

        b1 = gui.Button('Show second tab', width=200, height=30)

        tb = gui.TabBox(width='80%')
        tb.append(b1, 'First')

        b2 = gui.Button('Show third tab', width=200, height=30)
        tb.add_tab(b2, 'Second', None)

        b3 = gui.Button('Show first tab', width=200, height=30)
        tb.add_tab(b3, 'Third', None)

        b1.onclick.do(self.on_bt1_pressed, tb, b2)
        b2.onclick.do(self.on_bt2_pressed, tb, 'Third')
        b3.onclick.do(self.on_bt3_pressed, tb, 0)

        return tb
Beispiel #8
0
    def main(self):

        # Keep application instance in the global shared variable
        Config.APP_INSTANCE = self
        # add bootstrap
        self.page.children["head"].add_child("additional_head_data", css.HTML_HEAD)

        self.history = HistoryWidget()
        self.settings = AppSettingsWidget(width="100%")
        self.resources = SystemResourcesWidget(width="100%")

        tabs = gui.TabBox(width="95%")
        css.apply_styles(tabs, css.APP_TABS_CSS)
        tabs.add_tab(self.history, "Events history")
        tabs.add_tab(self.settings, "Settings")
        tabs.add_tab(self.resources, "System")
        tabs.select_by_index(0)
        return tabs
Beispiel #9
0
    def main(self):
        main_container = gui.VBox(width="80%",
                                  height=ALL,
                                  style={
                                      'margin': '0px auto',
                                      'position': 'relative'
                                  })

        tb = gui.TabBox(width=ALL, height=ALL)
        cw = ReplacesManageWidget(self)
        tb.add_tab(cw, 'Замены')
        tb.add_tab(
            ListWidget(self,
                       table='lessons',
                       field='lesson',
                       onchange=lambda: cw.refresh_lesson_dd()), 'Предметы')
        tb.add_tab(
            ListWidget(self,
                       table='teachers',
                       field='fio',
                       onchange=lambda: cw.refresh_teacher_dd()), 'Учителя')

        main_container.add_child("tab_box", tb)
        return main_container
Beispiel #10
0
 def test_init(self):
     w = gui.TabBox()
     l = gui.Label('testTabBox_label')
     w.add_tab(l, name='testtabbox', tab_cb=None) 
     self.assertIn('testTabBox_label',w.repr())
     assertValidHTML(w.repr())
    def main(self, robot, appCallback):
        self.robot = robot

        root = gui.VBox(width=600)

        title = gui.Label('Motor Tester')
        title.style['margin'] = '24px'
        title.style['font-size'] = '36px'
        title.style['font-weight'] = 'bold'
        root.append(title)

        self.talonBox = gui.SpinBox(default_value=0, min_value=0, max_value=99, step=1)
        self.talonBox.set_on_change_listener(self.queuedEvent(robot.c_setTalon))
        root.append(sea.hBoxWith(
            gui.Label('Talon:'),
            gui.HBox(width=SPACE),
            self.talonBox
        ))

        self.selectedTalonLbl = gui.Label('')
        root.append(sea.hBoxWith(
            gui.Label('Selected talon:'),
            gui.HBox(width=SPACE),
            self.selectedTalonLbl
        ))

        self.outputVoltageLbl = gui.Label('')
        root.append(sea.hBoxWith(
            gui.Label('Output voltage:'),
            gui.HBox(width=SPACE),
            self.outputVoltageLbl
        ))

        self.outputCurrentLbl = gui.Label('')
        root.append(sea.hBoxWith(
            gui.Label('Output current:'),
            gui.HBox(width=SPACE),
            self.outputCurrentLbl
        ))

        self.encoderPositionLbl = gui.Label('')
        root.append(sea.hBoxWith(
            gui.Label('Encoder position:'),
            gui.HBox(width=SPACE),
            self.encoderPositionLbl
        ))

        self.encoderVelocityLbl = gui.Label('')
        root.append(sea.hBoxWith(
            gui.Label('Encoder velocity:'),
            gui.HBox(width=SPACE),
            self.encoderVelocityLbl
        ))

        controlTabBox = gui.TabBox(width='100%')
        root.append(controlTabBox)

        controlTabBox.add_tab(gui.Widget(), 'Disabled',
            self.queuedEvent(robot.c_updateDisabled))

        self.outputSlider = gui.Slider(default_value="0", min=-100, max=100,
                                       width='100%')
        controlTabBox.add_tab(self.outputSlider, 'Percent Output',
                              self.c_percentOutputTab)
        self.outputSlider.set_on_change_listener(
            self.queuedEvent(robot.c_updatePercentOutput))

        velocityFrame = gui.HBox(width='100%')
        controlTabBox.add_tab(velocityFrame, 'Velocity', self.c_velocityTab)
        self.velocityOutputSlider = gui.Slider(default_value="0",
                                               min=-100, max=100, width='100%')
        velocityFrame.append(self.velocityOutputSlider)
        self.maxVelocityBox = gui.SpinBox(
            default_value='8000', min=0, max=1000000, step=100, width='100')
        velocityFrame.append(self.maxVelocityBox)
        self.velocityOutputSlider.set_on_change_listener(
            self.queuedEvent(robot.c_updateVelocity),
            self.velocityOutputSlider, self.maxVelocityBox)
        self.maxVelocityBox.set_on_change_listener(
            self.queuedEvent(robot.c_updateVelocity),
            self.velocityOutputSlider, self.maxVelocityBox)

        self.offsetBox = gui.SpinBox('0', -1000000, 1000000, 100)
        holdButton = gui.Button('Hold', width='100')
        holdButton.set_on_click_listener(
            self.queuedEvent(robot.c_updatePosition), self.offsetBox)
        controlTabBox.add_tab(sea.hBoxWith(
            gui.Label('Offset:'),
            gui.HBox(width=SPACE),
            self.offsetBox,
            holdButton
        ), 'Hold Position', self.queuedEvent(robot.c_updateDisabled))

        # margin
        root.append(gui.HBox(height=10))

        appCallback(self)
        return root
Beispiel #12
0
    def initScheduler(self, robot):
        schedulerBox = self.sectionBox()

        controlBox = gui.HBox()
        schedulerBox.append(controlBox)
        manualModeBtn = gui.Button("Manual")
        manualModeBtn.onclick.connect(robot.c_manualMode)
        controlBox.append(manualModeBtn)
        autoModeBtn = gui.Button("Auto")
        autoModeBtn.onclick.connect(robot.c_autoMode)
        controlBox.append(autoModeBtn)

        self.controlModeGroup = sea.ToggleButtonGroup()
        self.controlModeGroup.addButton(manualModeBtn, "manual")
        self.controlModeGroup.addButton(autoModeBtn, "auto")

        hbox = gui.HBox()
        hbox.style['align-items'] = 'flex-start'
        schedulerBox.append(hbox)

        addActionBox = gui.VBox()
        hbox.append(addActionBox)

        self.autoSpeed = 6

        def slowSpeed():
            self.autoSpeed = 3

        def mediumSpeed():
            self.autoSpeed = 6

        def fastSpeed():
            self.autoSpeed = 8

        speedTabBox = gui.TabBox()
        speedTabBox.add_tab(gui.Widget(), "Slow", slowSpeed)
        speedTabBox.add_tab(gui.Widget(), "Med", mediumSpeed)
        speedTabBox.add_tab(gui.Widget(), "Fast", fastSpeed)
        speedTabBox.select_by_index(1)
        addActionBox.append(speedTabBox)

        addActionBox.append(gui.Label("Auto actions:"))

        self.genericActionList = gui.ListView()
        self.genericActionList.append("Drive to Point", "drivetopoint")
        self.genericActionList.append("Navigate to Point", "navigatetopoint")
        self.genericActionList.append("Rotate in place", "rotate")
        index = 0
        for action in robot.genericAutoActions:
            self.genericActionList.append(gui.ListItem(action.name),
                                          str(index))
            index += 1
        self.genericActionList.onselection.connect(self.c_addGenericAction)
        addActionBox.append(self.genericActionList)

        hbox.append(self.spaceBox())

        scheduleListBox = gui.VBox()
        hbox.append(scheduleListBox)
        clearScheduleBox = gui.HBox()
        clearScheduleBox.style['align-items'] = 'flex-end'
        scheduleListBox.append(clearScheduleBox)
        clearScheduleBox.append(gui.Label("Schedule:"))
        clearScheduleBtn = gui.Button("Clear")
        clearScheduleBtn.onclick.connect(self.c_clearSchedule)
        clearScheduleBox.append(clearScheduleBtn)

        self.schedulerList = gui.ListView()
        self.schedulerList.onselection.connect(self.c_removeAction)
        scheduleListBox.append(self.schedulerList)

        schedulePresetLbl = gui.Label("Auto Schedule Presets")
        schedulerBox.append(schedulePresetLbl)
        presetIn = gui.Input(default_value="file name")
        schedulerBox.append(presetIn)
        schedulePresets = gui.HBox()
        schedulerBox.append(schedulePresets)
        self.presetDropdown = gui.DropDown()
        self.updatePresetFileDropdown()
        schedulerBox.append(self.presetDropdown)
        openPresetBtn = gui.Button("Open")
        schedulePresets.append(openPresetBtn)
        openPresetBtn.onclick.connect(self.c_openAutoPreset,
                                      self.presetDropdown)
        newPresetBtn = gui.Button("New")
        schedulePresets.append(newPresetBtn)
        newPresetBtn.onclick.connect(self.c_saveAutoPresetFromText, presetIn)
        schedulePresets.append(newPresetBtn)
        savePresetBtn = gui.Button("Save")
        schedulePresets.append(savePresetBtn)
        savePresetBtn.onclick.connect(self.c_saveAutoPresetFromDropdown,
                                      self.presetDropdown)
        schedulePresets.append(savePresetBtn)
        deletePresetBtn = gui.Button("Delete")
        schedulePresets.append(deletePresetBtn)
        deletePresetBtn.onclick.connect(self.c_deleteAutoPreset,
                                        self.presetDropdown)
        schedulePresets.append(deletePresetBtn)

        return schedulerBox
Beispiel #13
0
    def main(self):

        # Make containers
        vertContainer = gui.Widget(
            width='100%',
            height=300,
            layout_orientation=gui.Widget.LAYOUT_VERTICAL,
            margin='0px auto',
            style={
                'display': 'block',
                'overflow': 'auto',
                'background-color': '#BEBEBE'
            })
        vertContainer.style['text-align'] = 'center'

        wid = gui.HBox(width=300, height=150, margin='0px auto')
        wid.style['align-items'] = 'center'
        wid.style['justify-content'] = 'baseline'
        wid.style['font-size'] = '30px'
        wid.style['background-color'] = '#BEBEBE'

        buttonContainer = gui.HBox(width='80%', height=100, margin='0px auto')
        buttonContainer.style['align-items'] = 'baseline'
        buttonContainer.style['justify-content'] = 'space-around'
        buttonContainer.style['background-color'] = '#BEBEBE'
        buttonContainer.style['text-align'] = 'center'

        labelContainer = gui.HBox(width='80%', height=50, margin='0px auto')
        labelContainer.style['align-items'] = 'baseline'
        labelContainer.style['justify-content'] = 'space-around'
        labelContainer.style['background-color'] = '#BEBEBE'
        labelContainer.style['text-align'] = 'center'

        # Components
        #self.img = gui.Image('/res/wildcat.png', height=150, margin='0px auto')

        self.lbl = gui.Label('',
                             width='80%',
                             height=100,
                             margin='0px auto',
                             style="position: absolute")
        self.lbl.style['margin'] = 'auto'
        self.lbl.style['font-weight'] = 'bold'
        self.lbl.style['color'] = '#000000'

        bt = gui.Button('Add Sensor Module', width=200, height=50)
        bt.style['margin'] = 'auto 50px'
        bt.style['background-color'] = '#9876aa'
        bt.style['color'] = '#2b2b2b'

        bt1 = gui.Button('Add On/Off Module', width=200, height=50)
        bt1.style['margin'] = 'auto 50px'
        bt1.style['background-color'] = '#9876aa'
        bt1.style['color'] = '#2b2b2b'

        bt2 = gui.Button('Shut off', width=200, height=50)
        bt2.style['margin'] = 'auto 50px'
        bt2.style['background-color'] = '#9876aa'
        bt2.style['color'] = '#2b2b2b'

        self.sensorlabel = gui.Label('sensor value',
                                     width='80%',
                                     height=100,
                                     margin='0px auto',
                                     style="position: absolute")
        self.sensorlabel.style['margin'] = 'auto'
        self.sensorlabel.style['font-weight'] = 'bold'
        self.sensorlabel.style['color'] = '#000000'

        self.onofflabel = gui.Label('On/Off value',
                                    width='80%',
                                    height=100,
                                    margin='0px auto',
                                    style="position: absolute")
        self.onofflabel.style['margin'] = 'auto'
        self.onofflabel.style['font-weight'] = 'bold'
        self.onofflabel.style['color'] = '#000000'

        current_process = "No current process"
        self.process_label = gui.Label(current_process,
                                       width='80%',
                                       height=50,
                                       margin='0px auto',
                                       style="position: absolute")
        labelContainer.append(self.process_label)

        # Containers Code
        wid.append(self.lbl)
        #wid.append(self.img)
        buttonContainer.append(bt)
        buttonContainer.append(bt1)
        buttonContainer.append(bt2)

        vertContainer.append([wid, labelContainer, buttonContainer])

        tb = gui.TabBox(width='100%')
        tb.style['background-color'] = '#BEBEBE'
        tb.add_tab(vertContainer, "Home Screen", None)

        # Actions

        bt.set_on_click_listener(self.sensor_button_pressed, tb)
        bt1.set_on_click_listener(self.onoff_button_pressed, tb)
        bt2.set_on_click_listener(self.shutdown_button)

        # Thread code
        self.thread_alive_flag = True
        self.my_thread_result = 'n/a'
        self.my_thread_result2 = 'n/a'
        t = threading.Thread(target=self.my_algorithm)
        t.start()

        self.COUNTER = 0

        # returning the root widget
        return tb