Пример #1
0
    def on_prompt_login(self, emitter):
        self.login_dialog = gui.GenericDialog("Login",
                                              "Type here login data",
                                              width=300)
        username_input = gui.Input(width=250)
        password_input = gui.Input(input_type='password', width=250)
        password_input.attributes['type'] = 'password'
        self.login_dialog.add_field_with_label('username', 'Username',
                                               username_input)
        self.login_dialog.add_field_with_label('password', 'Password',
                                               password_input)

        self.login_dialog.confirm_dialog.do(self.on_login_confirm)
        self.login_dialog.show(self)
Пример #2
0
    def main(self):

        self.mainContainer = gui.Container(width='95%',
                                           margin='0px auto',
                                           style={
                                               'display': 'block',
                                               'overflow': 'hidden'
                                           })

        #variable for controlling whether classifier information is shown or gold info
        self.classifier = False
        self.date = 2

        self.loginBox = gui.VBox(
            width="50%",
            margin="10px auto 20px",
        )
        self.loginBox.css_background_color = 'cyan'
        self.loginBox.style['padding'] = "2%"

        heading = gui.Label("Discussion Tracker App", margin="5px  auto")
        userBox = gui.Input(width=200, height=15, margin="5px  auto")
        userBox.attributes['placeholder'] = "username"
        userBox.set_on_key_up_listener(self.formEnterUp)
        passBox = gui.Input(input_type='password',
                            width=200,
                            height=15,
                            margin="5px  auto")
        passBox.attributes['placeholder'] = "password"
        passBox.set_on_key_up_listener(self.formEnterUp)

        button = gui.Button("Login", margin="5px  auto")
        button.onclick.do(self.addContent)

        self.loginBox.append({
            'head': heading,
            'user': userBox,
            'pass': passBox,
            'button': button
        })

        self.mainContainer.append(self.loginBox)

        #print(self.session)
        return self.mainContainer
    def initPathRecording(self, robot):
        # the text input box is for saving and the dropdown is for loading

        recordingBox = self.sectionBox()
        recordingBox.append(gui.Label("Path Recording"))

        fileIn = gui.Input(default_value="file name")
        recordingBox.append(fileIn)

        recordingButtons = gui.HBox()
        recordingBox.append(recordingButtons)

        fileDropdown = gui.DropDown()
        recordingBox.append(fileDropdown)

        startBtn = gui.Button("Start")
        stopBtn = gui.Button("Stop")
        saveBtn = gui.Button("Save")
        loadBtn = gui.Button("Load")

        for btn in [startBtn, stopBtn, saveBtn, loadBtn]:
            recordingButtons.append(btn)

        def updateDropDown():
            fileDropdown.empty()
            for file in glob.glob(os.path.join(self.presetPath(), "*.ankl")):
                fileName = os.path.basename(file)
                fileDropdown.append(fileName, file)

        def startRecording(button, robot):
            autoActions.startRecording(robot)

        def stopRecording(button, robot):
            autoActions.stopRecording(robot)

        def saveRecording(button, robot, textIn):
            autoActions.saveRecording(robot, fileIn.get_value())
            updateDropDown()

        def loadRecording(dropDownItem, file):
            if file.get_key() is None:
                print("No file selected")
                return
            action = autoActions.createDriveRecordedPathAction(
                robot.pathFollower,
                file.get_key()[:-5])
            self.robot.autoScheduler.actionList.append(action)
            self.updateSchedulerFlag = True

        updateDropDown()

        startBtn.set_on_click_listener(startRecording, robot)
        stopBtn.set_on_click_listener(stopRecording, robot)
        saveBtn.set_on_click_listener(saveRecording, robot, fileIn)
        loadBtn.set_on_click_listener(loadRecording, fileDropdown)

        return recordingBox
Пример #4
0
    def on_bt_EditUser_pressed(self, widget):
        #print("bt_EditUser_pressed!")
        self.lbl_admin_panel_message.set_text('')
        self.EditUser_dialog = gui.GenericDialog("Edit user credential",
                                                 "Type here the user info",
                                                 width=300)
        username_input = gui.Input(width=250)
        password_input = gui.Input(input_type='password', width=250)
        user_level_input = gui.DropDown.new_from_list(
            ('Admin', 'Operator', 'guest'), width=200, height=20, margin='8px')
        password_input.attributes['type'] = 'password'
        self.EditUser_dialog.add_field_with_label('username', 'Username',
                                                  username_input)
        self.EditUser_dialog.add_field_with_label('password', 'Password',
                                                  password_input)
        self.EditUser_dialog.add_field_with_label('userlevel', 'User level',
                                                  user_level_input)

        self.EditUser_dialog.confirm_dialog.do(self.on_EditUser_confirm)
        self.EditUser_dialog.show(self)
Пример #5
0
    def on_bt_delUser_pressed(self, widget):
        #print("bt_delUser_pressed!")
        self.lbl_admin_panel_message.set_text('')
        self.delUser_dialog = gui.GenericDialog("Delete user",
                                                "Type here the user info",
                                                width=300)
        username_input = gui.Input(width=250)
        self.delUser_dialog.add_field_with_label('username', 'Username',
                                                 username_input)

        self.delUser_dialog.confirm_dialog.do(self.on_delUser_confirm)
        self.delUser_dialog.show(self)
    def initLedControl(self, robot):
        ledBox = self.sectionBox()

        ledInputBox = sea.hBoxWith(gui.Label("LED Control"))
        ledSet = gui.Button("Set")
        ledIn = gui.Input()

        def ledSetValue(button):
            robot.ledInput = float(ledIn.get_value())

        ledSet.set_on_click_listener(ledSetValue)

        ledInputBox.append(ledSet)
        ledInputBox.append(ledIn)

        ledBox.append(ledInputBox)

        return ledBox
    def initTest(self, robot):
        testBox = self.sectionBox()

        motorNumberIn = gui.Input()
        motorSelectionBox = sea.hBoxWith(gui.Label("Motor Number:"),
                                         motorNumberIn)

        motorSpeedSlider = gui.Slider(default_value=0,
                                      min=-1.0,
                                      max=1.0,
                                      step=0.05)
        testButton = gui.Button("Test")
        motorSpeedBox = sea.hBoxWith(testButton, gui.Label("Speed:"),
                                     motorSpeedSlider)

        def testMotor(button):
            robot.superDrive.disable()
            try:
                motorNum = int(motorNumberIn.get_value()) - 1
            except:
                print("Motor number incorrect")
                return

            wheelNum = 0
            if motorNum >= 3:
                wheelNum = 1
                motorNum -= 3

            if motorNum < 0 or motorNum >= 3:
                print("Motor number incorrect")
                return

            robot.testSettings["wheelNum"] = wheelNum
            robot.testSettings["motorNum"] = motorNum
            robot.testSettings["speed"] = float(motorSpeedSlider.get_value())

        testButton.set_on_click_listener(testMotor)

        testBox.append(gui.Label("Test"))
        testBox.append(motorSelectionBox)
        testBox.append(motorSpeedBox)
        return testBox
    def initPidControlsBox(self, robot):
        pidControlsBox = self.sectionBox()

        # This changes pid values on the robot depending on the button pressed.
        def changePidValue(button):
            term = button.get_text()[-1]
            parentHbox = button.get_parent()
            peerTextArea = parentHbox.children[term + "textarea"]

            try:
                newPidValue = float(peerTextArea.get_value())
            except:
                print(term + " value incorrect")
                return

            if (term == "P"):
                robot.driveGear.p = newPidValue
            elif (term == "I"):
                robot.driveGear.i = newPidValue
            elif (term == "D"):
                robot.driveGear.d = newPidValue

            robot.driveGear.applyGear(robot.superDrive)

        pidControlsBox.append(gui.Label("PID Controls"))

        # P, I, and D each have their own label, text area, and update button
        for term in ["P", "I", "D"]:
            controlBox = gui.HBox()
            # Adds a label to the hBox with the key <term>label
            controlBox.append(gui.Label(term + ": "), term + "label")
            # Adds a text area to the hBox with the key <term>textarea
            controlBox.append(gui.Input(), term + "textarea")
            # Adds an update button to the hBox with the key <term>updatebutton
            button = gui.Button("Update " + term)
            button.set_on_click_listener(changePidValue)
            controlBox.append(button, term + "updatebutton")
            # Adds the control box for this term to the pidControlsBox with the key <term>
            pidControlsBox.append(controlBox, term)

        return pidControlsBox
Пример #9
0
 def test_init(self):
     widget = gui.Input()
     assertValidHTML(widget.repr())
Пример #10
0
 def add_password(self, key: str, desc: str, text: str = "", **kwargs):
     label = gui.Input(input_type="password", width="100%", **kwargs)
     label.set_value(text)
     self.add_field(key=key, desc=desc, field=label)
Пример #11
0
    def initTestControl(self, robot):
        testBox = self.sectionBox()
        testBox.append(gui.Label("TEST MODE"))

        compressorBox = gui.HBox()
        testBox.append(compressorBox)
        compressorBox.append(gui.Label("Compressor:"))
        startCompressorBtn = gui.Button("Start")
        startCompressorBtn.onclick.connect(robot.c_startCompressor)
        compressorBox.append(startCompressorBtn)
        stopCompressorBtn = gui.Button("Stop")
        stopCompressorBtn.onclick.connect(robot.c_stopCompressor)
        compressorBox.append(stopCompressorBtn)

        logBox = gui.HBox()
        testBox.append(logBox)

        logOpticalBtn = gui.Button("Log Optical")
        logOpticalBtn.onclick.connect(robot.c_logOpticalSensors)
        logBox.append(logOpticalBtn)

        swerveBox = gui.HBox()
        testBox.append(swerveBox)

        homeSwerveBtn = gui.Button("Home swerve")
        homeSwerveBtn.onclick.connect(robot.c_homeSwerveWheels)
        swerveBox.append(homeSwerveBtn)

        resetSwerveBtn = gui.Button("Wheels to zero")
        resetSwerveBtn.onclick.connect(robot.c_wheelsToZero)
        swerveBox.append(resetSwerveBtn)

        setSwerveZeroBtn = gui.Button("Set swerve zero")
        setSwerveZeroBtn.onclick.connect(robot.c_setSwerveZero)
        swerveBox.append(setSwerveZeroBtn)

        swerveBrakeBox = gui.HBox()
        testBox.append(swerveBrakeBox)

        swerveBrakeOffBtn = gui.Button("Swerve Brake Off")
        swerveBrakeOffBtn.onclick.connect(robot.c_swerveBrakeOff)
        swerveBrakeBox.append(swerveBrakeOffBtn)

        swerveBrakeOnBtn = gui.Button("Swerve Brake On")
        swerveBrakeOnBtn.onclick.connect(robot.c_swerveBrakeOn)
        swerveBrakeBox.append(swerveBrakeOnBtn)

        resetClawBtn = gui.Button("Reset Claw")
        resetClawBtn.onclick.connect(robot.c_resetClaw)
        testBox.append(resetClawBtn)

        def restartCamServer(widget):
            print("restarting camera server")
            wpilib.CameraServer.launch('camera.py:main')

        camserverBtn = gui.Button("restart camera server")
        camserverBtn.onclick.connect(restartCamServer)
        testBox.append(camserverBtn)

        posBox = gui.HBox()
        testBox.append(posBox)

        posBox.append(gui.Label("Robot:"))
        posBox.append(self.spaceBox())
        self.robotPositionLbl = gui.Label('')
        posBox.append(self.robotPositionLbl)
        posBox.append(self.spaceBox())

        cursorBox = gui.HBox()
        testBox.append(cursorBox)

        cursorBox.append(gui.Label("Cursor:"))
        cursorBox.append(self.spaceBox())
        self.cursorPositionLbl = gui.Label('')
        cursorBox.append(self.cursorPositionLbl)
        cursorBox.append(self.spaceBox())
        xInput = gui.Input()
        yInput = gui.Input()
        angleInput = gui.Input()
        smallBox = sea.vBoxWith(xInput, yInput)
        cursorToPtBtn = gui.Button('Move Cursor to Point')
        cursorToPtBtn.set_on_click_listener(self.moveCursortoPt, xInput,
                                            yInput, angleInput)
        testBox.append(sea.hBoxWith(smallBox, angleInput, cursorToPtBtn))

        pidFrame = gui.HBox()
        testBox.append(pidFrame)
        pidTable = gui.VBox()
        pidFrame.append(pidTable)
        pidRow = gui.HBox()
        pidTable.append(pidRow)
        pIn = gui.Input()
        pidRow.append(pIn)
        iIn = gui.Input()
        pidRow.append(iIn)
        pidRow = gui.HBox()
        pidTable.append(pidRow)
        dIn = gui.Input()
        pidRow.append(dIn)
        fIn = gui.Input()
        pidRow.append(fIn)
        setBtn = gui.Button("Med. Gear PID")
        pidFrame.append(setBtn)

        def setPids(widget):
            drivetrain.mediumPositionGear.p = float(pIn.get_value())
            drivetrain.mediumPositionGear.i = float(iIn.get_value())
            drivetrain.mediumPositionGear.d = float(dIn.get_value())
            drivetrain.mediumPositionGear.f = float(fIn.get_value())

        setBtn.onclick.connect(setPids)

        return testBox
Пример #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
Пример #13
0
    def __init__(self, settings: Settings):
        super().__init__()

        form_title = Title(Level.H4, "ARF File column")
        self.append(form_title)

        self._arf_selection = gui.DropDown()
        self._arf_selection.append(gui.DropDownItem("1"))
        self._arf_selection.append(gui.DropDownItem("2"))
        self._arf_selection.append(gui.DropDownItem("3"))
        self._arf_selection.append(gui.DropDownItem("4"))
        self._arf_selection.set_value(str(settings.arf_column))
        arf_input = LabeledInput(
            "Column of the ARF file to use for the cos correction (column 0 is sza)",
            self._arf_selection,
            style="margin-bottom: 10px")
        self.append(arf_input)

        form_title = Title(Level.H4, "Daily file settings")
        self.append(form_title)

        self._weighted_irradiance_type_selection = gui.DropDown()
        for t in WeightedIrradianceType:
            self._weighted_irradiance_type_selection.append(
                gui.DropDownItem(t))
        self._weighted_irradiance_type_selection.set_value(
            settings.weighted_irradiance_type)
        weighted_irradiance_type_input = LabeledInput(
            "Type of weight function to use for the weighted irradiance",
            self._weighted_irradiance_type_selection,
            style="margin-bottom: 10px",
        )
        self.append(weighted_irradiance_type_input)

        coscor_title = Title(Level.H4, "Cos correction")
        coscor_title.set_style("margin-top: 14px")
        self.append(coscor_title)

        self._no_coscor_checkbox = gui.CheckBoxLabel("Skip cos correction",
                                                     style="height: 30px")
        self._no_coscor_checkbox.set_value(settings.no_coscor)
        self.append(self._no_coscor_checkbox)

        coscor_title = Title(Level.H4, "Temperature correction")
        coscor_title.set_style("margin-top: 14px")
        self.append(coscor_title)
        temperature_explanation = IconLabel(
            "Each value of the spectrum F for a temperature T (°C) will be corrected with a correction "
            "factor C and a reference temperature Tref (°C) with the formula: F * [1 + C * (T - Tref)]",
            "info_outline",
            style="margin-bottom: 10px",
        )
        self.append(temperature_explanation)

        # Temperature correction dual field
        temp_correction = gui.HBox(
            style="justify-content: stretch; width: 260px")
        self._temp_factor_spin = gui.SpinBox(
            settings.temperature_correction_factor,
            -4,
            4,
            0.01,
            style="width: 100px; height: 25px")
        self._temp_ref_spin = gui.SpinBox(settings.temperature_correction_ref,
                                          -50,
                                          50,
                                          0.5,
                                          style="width: 100px; height: 25px")
        temp_factor_label = gui.Label("C:", style="flex-grow: 1")
        temp_correction.append(temp_factor_label)
        temp_correction.append(self._temp_factor_spin)
        temp_ref_label = gui.Label("Tref:",
                                   style="margin-left: 8px; flex-grow: 1")
        temp_correction.append(temp_ref_label)
        temp_correction.append(self._temp_ref_spin)
        self.append(temp_correction)

        default_title = Title(Level.H4, "Default values")
        default_title.set_style("margin-top: 14px")
        self.append(default_title)
        default_explanation = IconLabel(
            "Will be used if no value is found in the files or via api",
            "info_outline",
            style="margin-bottom: 10px")
        self.append(default_explanation)

        # Albedo field
        self._albedo_spin = gui.SpinBox(settings.default_albedo, 0, 1, 0.01)
        albedo_input = LabeledInput("Albedo",
                                    self._albedo_spin,
                                    style="margin-bottom: 10px")
        self.append(albedo_input)

        # Aerosol dual field
        aerosol = gui.HBox(style="justify-content: stretch; width: 100%")
        self._alpha_spin = gui.SpinBox(settings.default_aerosol.alpha,
                                       0,
                                       2,
                                       0.01,
                                       style="width: 110px; height: 25px")
        self._beta_spin = gui.SpinBox(settings.default_aerosol.beta,
                                      0,
                                      1.5,
                                      0.01,
                                      style="width: 110px; height: 25px")
        alpha_label = gui.Label("α:", style="flex-grow: 1")
        aerosol.append(alpha_label)
        aerosol.append(self._alpha_spin)
        beta_label = gui.Label("β:", style="margin-left: 8px; flex-grow: 1")
        aerosol.append(beta_label)
        aerosol.append(self._beta_spin)
        aerosol_input = LabeledInput("Aerosol",
                                     aerosol,
                                     style="margin-bottom: 10px")
        self.append(aerosol_input)

        # Ozone field
        self._ozone_spin = gui.SpinBox(settings.default_ozone, 200, 600, 0.5)
        ozone_input = LabeledInput("Ozone",
                                   self._ozone_spin,
                                   style="margin-bottom: 10px")
        self.append(ozone_input)

        self._straylight_checkbox = gui.CheckBoxLabel(
            "Apply straylight correction", style="min-height: 30px")
        self._straylight_checkbox.set_value(
            settings.default_straylight_correction ==
            StraylightCorrection.APPLIED)
        self.append(self._straylight_checkbox)

        source_title = Title(Level.H4, "Data source")
        source_title.set_style("margin-top: 14px")
        self.append(source_title)
        source_explanation = IconLabel(
            "Data can either come from files on disk or from the online database eubrewnet.",
            "info_outline",
            style="margin-bottom: 10px; line-height: 14pt",
        )
        self.append(source_explanation)

        self._form_selection_checkbox = gui.CheckBoxLabel(
            "Specify files manually instead of giving a date and a brewer id",
            style="min-height: 30px; margin-bottom: 6px")
        self._form_selection_checkbox.set_value(settings.manual_mode)
        self._form_selection_checkbox.onchange.do(
            lambda w, v: self._update_manual_mode(v))
        self.append(self._form_selection_checkbox)

        self._source_container = VBox()

        self._uv_source_selection = gui.DropDown()
        for source in DataSource:
            self._uv_source_selection.append(gui.DropDownItem(source))
        self._uv_source_selection.set_value(settings.uv_data_source)
        uv_source_input = LabeledInput("UV data source",
                                       self._uv_source_selection,
                                       style="margin-bottom: 10px")
        self._source_container.append(uv_source_input)

        self._ozone_source_selection = gui.DropDown()
        for source in DataSource:
            self._ozone_source_selection.append(gui.DropDownItem(source))
        self._ozone_source_selection.set_value(settings.ozone_data_source)
        ozone_source_input = LabeledInput("Ozone data source",
                                          self._ozone_source_selection,
                                          style="margin-bottom: 10px")
        self._source_container.append(ozone_source_input)

        self._uvr_source_selection = gui.DropDown()
        for source in DataSource:
            self._uvr_source_selection.append(gui.DropDownItem(source))
        self._uvr_source_selection.set_value(settings.uvr_data_source)
        uvr_source_input = LabeledInput("UVR data source",
                                        self._uvr_source_selection,
                                        style="margin-bottom: 10px")
        self._source_container.append(uvr_source_input)

        self._brewer_model_source_selection = gui.DropDown()
        for source in DataSource:
            self._brewer_model_source_selection.append(
                gui.DropDownItem(source))
        self._brewer_model_source_selection.set_value(
            settings.brewer_model_data_source)
        brewer_model_source_input = LabeledInput(
            "Brewer model data source",
            self._brewer_model_source_selection,
            style="margin-bottom: 10px")
        self._source_container.append(brewer_model_source_input)

        self.append(self._source_container)
        self._update_manual_mode(settings.manual_mode)

        woudc_title = Title(Level.H4, "WOUDC output")
        woudc_title.set_style("margin-top: 14px")
        self.append(woudc_title)
        gawsis_link = gui.Link("https://woudc.org/", "WOUDC")
        woudc_explanation = IconLabel(
            "Create files in the WOUDC format which can be submitted to\xa0",
            "info_outline",
            style="margin-bottom: 10px",
        )
        woudc_explanation.append(gawsis_link)

        self.append(woudc_explanation)

        self._woudc_checkbox = gui.CheckBoxLabel(
            "Create WOUDC files", style="min-height: 30px; margin-bottom: 6px")
        self._woudc_checkbox.set_value(settings.activate_woudc)
        self._woudc_checkbox.onchange.do(lambda w, v: self._update_woudc(v))
        self.append(self._woudc_checkbox)

        woudc_info = settings.woudc_info
        self._woudc_info_container = VBox()

        self._agency_input = gui.Input(default_value=woudc_info.agency)
        agency_input = LabeledInput("Agency", self._agency_input)
        self._woudc_info_container.append(agency_input)

        self._version_input = gui.Input(default_value=woudc_info.version)
        version_input = LabeledInput("Version", self._version_input)
        self._woudc_info_container.append(version_input)

        self._scientific_authority_input = gui.Input(
            default_value=woudc_info.scientific_authority)
        scientific_authority_input = LabeledInput(
            "Scientific Authority", self._scientific_authority_input)
        self._woudc_info_container.append(scientific_authority_input)

        self._platform_id_input = gui.Input(
            default_value=woudc_info.platform_id)
        platform_id_input = LabeledInput("Platform ID",
                                         self._platform_id_input)
        self._woudc_info_container.append(platform_id_input)

        self._platform_name_input = gui.Input(
            default_value=woudc_info.platform_name)
        platform_name_input = LabeledInput("Platform Name",
                                           self._platform_name_input)
        self._woudc_info_container.append(platform_name_input)

        self._country_input = gui.Input(default_value=woudc_info.country_iso3)
        country_input = LabeledInput("Country (ISO 3)", self._country_input)
        self._woudc_info_container.append(country_input)

        self._gaw_id_input = gui.Input(default_value=woudc_info.gaw_id)
        gaw_id_input = LabeledInput("GAW Id", self._gaw_id_input)
        self._woudc_info_container.append(gaw_id_input)

        self._altitude_spin = gui.SpinBox(woudc_info.altitude, 0, 6000, 1)
        altitude_input = LabeledInput("Altitude",
                                      self._altitude_spin,
                                      style="margin-bottom: 10px")
        self._woudc_info_container.append(altitude_input)

        self.append(self._woudc_info_container)
        self._update_woudc(settings.activate_woudc)
Пример #14
0
    def main(self):
        self.verticalContainer = gui.Container(width=2000,
                                               margin='0px auto',
                                               style={
                                                   'display': 'block',
                                                   'overflow': 'hidden'
                                               })

        # chart container
        self.chartContainer = gui.Container(width=2000,
                                            margin='0px auto',
                                            style={
                                                'display': 'block',
                                                'overflow': 'hidden'
                                            })

        self.selectContainer = gui.Container(
            width='100%',
            layout_orientation=gui.Container.LAYOUT_HORIZONTAL,
            margin='0px',
            style={
                'display': 'block',
                'overflow': 'auto'
            })
        self.select_bt = gui.FileUploader('./',
                                          width=200,
                                          height=30,
                                          margin='10px')
        self.select_bt.ondata.do(self.on_data_select)

        self.index_lb = gui.Label('Index: ',
                                  width=30,
                                  height=30,
                                  margin='10px')
        self.index_input = gui.Input(input_type='number',
                                     default_value=0,
                                     width=40,
                                     height=15,
                                     margin='10px')
        self.index_input.onchange.do(self.on_index_change)
        self.expr = gui.TextInput(width=500, height=15, margin='10px')
        self.expr.set_text('Type in a expression')
        self.expr.onchange.do(self.on_expr_change)

        self.info_lb = gui.Label('Info: ',
                                 width=2000,
                                 height=30,
                                 margin='10px')

        self.selectContainer.append(
            [self.select_bt, self.index_lb, self.index_input, self.expr])

        self.chart = MultiLayerAttentionMap(abspath=self.res_path,
                                            load_path="/res:",
                                            width=2000,
                                            height=1000,
                                            margin='10px')
        self.chartContainer.append(self.selectContainer)
        self.chartContainer.append(self.info_lb)
        self.chartContainer.append(self.chart, "chart")

        self.next_bt = gui.Button('Next', width=200, height=30, margin='10px')
        self.next_bt.onclick.do(self.on_next_button_pressed)
        self.last_bt = gui.Button('Last', width=200, height=30, margin='10px')
        self.last_bt.onclick.do(self.on_last_button_pressed)

        self.verticalContainer.append(self.chartContainer)
        self.verticalContainer.append(self.next_bt)
        self.verticalContainer.append(self.last_bt)
        return self.verticalContainer
    def initScheduler(self, robot):
        schedulerBox = self.sectionBox()

        controlBox = gui.HBox()
        schedulerBox.append(controlBox)
        manualModeBtn = gui.Button("Manual")
        manualModeBtn.set_on_click_listener(robot.c_manualMode)
        controlBox.append(manualModeBtn)
        autoModeBtn = gui.Button("Auto")
        autoModeBtn.set_on_click_listener(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)

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

        self.genericActionList = gui.ListView()
        self.genericActionList.append("Drive to Point", "drive")
        self.genericActionList.append("Rotate in Place", "rotate")
        self.genericActionList.append("Rotate towards Point", "face")
        self.genericActionList.append("Shoot", "shoot")
        self.genericActionList.append("Toggle Intake", "intake")
        self.genericActionList.append("Set Starting Positon", "set")
        self.genericActionList.append("Set Robot Starting Angle", "angle")
        index = 0
        for action in robot.genericAutoActions:
            self.genericActionList.append(gui.ListItem(action.name),
                                          str(index))
            index += 1
        self.genericActionList.set_on_selection_listener(
            self.c_addGenericAction)
        addActionBox.append(self.genericActionList)

        hbox.append(gui.HBox(width=10))

        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.set_on_click_listener(self.c_clearSchedule)
        clearScheduleBox.append(clearScheduleBtn)

        self.schedulerList = gui.ListView()
        self.schedulerList.set_on_selection_listener(self.c_removeAction)
        scheduleListBox.append(self.schedulerList)

        schedulePresetLbl = gui.Label("Auto Sequence 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.set_on_click_listener(self.c_openAutoPreset,
                                            self.presetDropdown)
        newPresetBtn = gui.Button("New")
        schedulePresets.append(newPresetBtn)
        newPresetBtn.set_on_click_listener(self.c_saveAutoPresetFromText,
                                           presetIn)
        schedulePresets.append(newPresetBtn)
        savePresetBtn = gui.Button("Save")
        schedulePresets.append(savePresetBtn)
        savePresetBtn.set_on_click_listener(self.c_saveAutoPresetFromDropdown,
                                            self.presetDropdown)
        schedulePresets.append(savePresetBtn)
        deletePresetBtn = gui.Button("Delete")
        schedulePresets.append(deletePresetBtn)
        deletePresetBtn.set_on_click_listener(self.c_deleteAutoPreset,
                                              self.presetDropdown)
        schedulePresets.append(deletePresetBtn)

        return schedulerBox
Пример #16
0
    def constructUI(self):

        row1 = gui.Container()                          # Create a row
        row1.add_class('w3-row')
        row1.style.update({'position': 'relative'})
        self.append(row1)

        box_1_left = gui.Container()                    # Create a column
        box_1_left.add_class('w3-col l3 s12')
        row1.append(box_1_left)

        card = gui.Container()
        card.add_class('w3-card-4 w3-margin w3-white')
        card.style.update({'padding': '20px', 'margin': '10px'})
        box_1_left.append(card)

        title = gui.Container()
        title.add_class('w3-light-grey')
        title.add_child(key='title', value='<h4 class="w3-wide w3-center">User Details</h2>')
        card.append(title)

        dropdown1 = gui.DropDown()
        dropdown1.add_class('w3-input w3-tiny w3-white')
        for item in ['Option 1', 'Option 2', 'Option 3']:
            dropdown_item = gui.DropDownItem(item)
            dropdown1.append(dropdown_item)
        card.append(dropdown1)

        dropdown1.onchange.do(self.change_text)

        input1 = gui.Input()
        input1.add_class('w3-input w3-tiny')
        card.append(key='input1', value=input1)

        self.label1 = gui.Label(f'Enter your Name ({dropdown1.get_item().get_text()} selected)')
        self.label1.add_class('w3-tiny')
        card.append(self.label1)

        input2 = gui.Input()
        input2.add_class('w3-input w3-tiny')
        card.append(input2)

        label2 = gui.Label('Enter your City')
        label2.add_class('w3-tiny')
        card.append(label2)

        card.add_child(key='spacer1', value='<br><br>')

        btn1_ok = gui.Button('OK', width='30%')
        btn1_ok.add_class('w3-button w3-green w3-left')
        card.append(btn1_ok)

        btn1_cancel = gui.Button('Cancel', width='30%')
        btn1_cancel.add_class('w3-button w3-yellow w3-right')
        card.append(btn1_cancel)

        card.add_child(key='spacer2', value='<br><br>')


        ######## Right Container
        box_1_right = gui.Container()  # Create a column
        box_1_right.add_class('w3-col l3 s12')
        row1.append(box_1_right)

        self.card2 = gui.Container()
        self.card2.add_class('w3-card-4 w3-margin w3-padding w3-white w3-display-container')
        box_1_right.append(self.card2)

        title = gui.Container()
        title.add_class('w3-light-grey')
        title.add_child(key='title', value='<h4 class="w3-wide w3-center">Automatic Form</h2>')
        self.card2.append(title)

        for i in range(1,10):
            input = gui.Input()
            input.add_class('w3-input w3-small')
            self.card2.append(key=f'input_{i}', value=input)
            label = gui.Label(f'This is Label {i}')
            label.add_class('w3-small')
            self.card2.append(label)

        self.card2.add_child(key='spacer1', value='<br><br>')

        footer = gui.Container()
        footer.add_child(key='footer', value='<p class="w3-small w3-center">Created with REMI and W3.CSS</p>')
        self.card2.append(footer)

        self.card2.add_child(key='spacer2', value='<br><br>')

        btn2_ok = gui.Button('Dialog', width='30%')
        btn2_ok.add_class('w3-button w3-green w3-display-bottommiddle')
        self.card2.append(btn2_ok)

        # Call method for gathering information and showing dialog
        btn2_ok.onclick.do(self.notify)