Ejemplo n.º 1
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.css_width = "100%"
        hours = [f"{h}:00" for h in range(24)]
        self.from_hour_combo = gui.DropDown.new_from_list(hours)
        self.to_hour_combo = gui.DropDown.new_from_list(hours)
        self.weekdays = [
            ToggleButton("Mo", width="inherit"),
            ToggleButton("Tu", width="inherit"),
            ToggleButton("We", width="inherit"),
            ToggleButton("Th", width="inherit"),
            ToggleButton("Fr", width="inherit"),
            ToggleButton("Sa", width="inherit"),
            ToggleButton("Su", width="inherit"),
        ]
        self.from_hour_combo.set_value("8:00")
        self.to_hour_combo.set_value("18:00")

        layout = gui.HBox(width="100%")
        layout.append(gui.Label("From: "))
        layout.append(self.from_hour_combo)
        layout.append(gui.Label("To: "))
        layout.append(self.to_hour_combo)
        self.append(layout)

        layout = gui.HBox(width="100%")
        for day in self.weekdays:
            layout.append(day)
        self.append(layout)
Ejemplo n.º 2
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        hours_layout = gui.HBox()
        hours_layout.css_height = f"{self.HEIGHT}px"
        width = f"{100 / 24}%"

        # create list of clickable buttons for every hour
        self.hourly_buttons = []
        for hour in range(24):
            btn = ToggleButton(text="", internal_value=hour, width=width)
            btn.css_height = f"0px"
            btn.css_margin = "0px 1px"
            btn.css_position = "relative"
            self.hourly_buttons.append(btn)
            hours_layout.append(btn)
        self.append(hours_layout)

        hours_layout = gui.HBox()
        for hour in range(24):
            btn = gui.Label(text=f"{hour + 1}", width=width)
            btn.css_text_align = "center"
            btn.css_font_size = "smaller"
            hours_layout.append(btn)
        self.append(hours_layout)

        self.update_from_dates([])
Ejemplo n.º 3
0
    def sensor_button_pressed(self, container, tabbox):

        # On button press, create new tab for the module
        self.process_label.set_text("Initiated sensor pairing...")
        self.do_gui_update()
        # Subcontainer for the 'pairing initiated box'
        mainmessageContainer = gui.Widget(width='100%', height=300, layout_orientation=gui.Widget.LAYOUT_VERTICAL, margin='0px auto',
                                         style={'display': 'block', 'overflow': 'auto', 'background-color': '#BEBEBE'})
        mainmessageContainer.style['text-align'] = 'center'
        mainmessageContainer.style['align-items'] = 'center'
        mainmessageContainer.style['justify-content'] = 'space-around'
        mainmessageContainer.style['font-size'] = '20px'

        self.newlabel = gui.Label('Sensor Module', width='60%', height=150, margin='0px auto')#,style="position: absolute")

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

        button_ReturnToHome = gui.Button('Return to Home Screen', width=200, height=50)
        button_ReturnToHome.style['margin'] = 'auto 50px'
        button_ReturnToHome.style['background-color'] = '#9876aa'
        button_ReturnToHome.style['color'] = '#2b2b2b'

        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'
        labelContainer.append(self.sensorlabel)

        button_ReturnToHome.set_on_click_listener(self.on_bt_pressed, tabbox, 0)

        buttonBox.append(button_ReturnToHome)
        mainmessageContainer.append([self.newlabel, labelContainer, buttonBox])

        # Display the result of the pairing

        pairing_return = init_test()
        self.newlabel2 = pairing_return
        if pairing_return:
            self.process_label.set_text("Pairing successful")
            self.COUNTER = self.COUNTER + 1
            tabbox.add_tab(mainmessageContainer, "Sensor Module", None)
        else:
            self.process_label.set_text("Pairing failed")
        self.do_gui_update()
        time.sleep(3)
        self.process_label.set_text("No current process")
        self.do_gui_update()

        t2 = threading.Thread(target=self.my_2algorithm)
        t2.start()
Ejemplo n.º 4
0
    def _init_elements(self):
        self._date_end = date.today()
        self._date_start = self._date_end - timedelta(days=3)

        self._scanning_file_message = gui.HBox(
            style="align-self: flex-start; margin-bottom: 10px")
        self._scanning_file_message.append(
            gui.Image("/res:spinner.gif", style="margin-right: 4px"))
        self._scanning_file_message.append(gui.Label("Scanning files"))
        self.append(self._scanning_file_message)
        hide(self._scanning_file_message)

        file_form = gui.HBox(style="margin-bottom: 20px; flex-wrap: wrap")

        self._brewer_dd = gui.DropDown()
        self._update_brewer_ids()
        self._brewer_dd.onchange.do(self._on_bid_change)
        self._brewer_input = LabeledInput("Brewer id",
                                          self._brewer_dd,
                                          style="margin-right: 20px")

        self._uvr_dd = gui.DropDown()
        self._update_uvr_files()
        self._uvr_dd.onchange.do(self._on_uvr_change)
        self._uvr_input = LabeledInput("UVR file",
                                       self._uvr_dd,
                                       style="margin-right: 20px")

        self._date_start_selector = gui.Date(default_value="2019-06-24")
        self._date_start_selector.onchange.do(self._on_date_start_change)
        self._date_start_input = LabeledInput("Start date",
                                              self._date_start_selector,
                                              style="margin-right: 20px")

        self._date_end_selector = gui.Date(default_value="2019-06-27")
        self._date_end_selector.onchange.do(self._on_date_end_change)
        self._date_end_input = LabeledInput("End date",
                                            self._date_end_selector,
                                            style="margin-right: 20px")

        file_form.append(self._brewer_input)
        file_form.append(self._uvr_input)
        file_form.append(self._date_start_input)
        file_form.append(self._date_end_input)

        self.append(file_form)

        self._refresh_button = gui.Button("Refresh files",
                                          style="margin-bottom: 10px")
        self._refresh_button.onclick.do(self.refresh)

        self.append(self._refresh_button)
Ejemplo n.º 5
0
    def build_keg_settings(self, hx_conf, index, channel):
        cap = hx_conf['channels'][channel]['size'][0]
        tare = hx_conf['channels'][channel]['size'][1]
        name = hx_conf['channels'][channel]['name']
        size_name = hx_conf['channels'][channel]['size_name']
        size = hx_conf['channels'][channel]['size']

        keg_size_list = list(self.h.keg_data)
        keg_size_list.append('custom')

        keg_box = gui.Widget()

        box_name = gui.Label('Sensor ' + str(index) + ' Channel ' + channel)
        keg_box.append(box_name)

        keg_name = gui.HBox()
        keg_name_lbl = gui.Label('Keg Name', width='20%')
        keg_name.append(keg_name_lbl, 'lbl')
        keg_name_val = gui.TextInput(single_line=True, height='1.5em')
        keg_name_val.set_value(name)
        keg_name.append(keg_name_val, 'val')
        keg_box.append(keg_name, 'name')

        keg_size = gui.HBox()
        keg_size_lbl = gui.Label('Keg Size', width='20%')
        keg_size.append(keg_size_lbl, 'lbl')
        keg_size_val = gui.DropDown.new_from_list(keg_size_list)
        keg_size_val.select_by_value(size_name)
        keg_size.append(keg_size_val, 'val')
        keg_box.append(keg_size, 'size')

        custom = gui.HBox()
        vol_lbl = gui.Label('Volume (l)', width='20%')
        custom.append(vol_lbl, 0)
        custom_vol = gui.TextInput(single_line=True,
                                   height='1.5em',
                                   width='30%')
        custom_vol.set_value(str(size[0]))
        custom.append(custom_vol, 1)
        tare_lbl = gui.Label('Empty Weight (kg)', width='30%')
        custom.append(tare_lbl, 2)
        custom_tare = gui.TextInput(single_line=True,
                                    height='1.5em',
                                    width='20%')
        custom_tare.set_value(str(size[1]))
        custom.append(custom_tare, 3)

        keg_box.append(custom, 'custom')

        return keg_box
Ejemplo n.º 6
0
    def main(self):
        wid = gui.VBox(width=500,
                       height=500,
                       style={
                           'margin': '5px auto',
                           'padding': '10px'
                       })

        lbl_description = gui.Label("""Example about TableWidget usage.
                                    Change rows and columns count in order to see the behaviour. 
                                    After changing the size, 'Fill the table' content by means of the button."""
                                    )

        wid.append(lbl_description)

        table = gui.TableWidget(10, 3, True, True, width=300, height=300)
        table.style['font-size'] = '8px'

        container = gui.HBox(width='100%')
        lbl_row_count = gui.Label('Rows:')
        spin_row_count = gui.SpinBox(10, 0, 15)
        spin_row_count.onchange.do(self.on_row_count_change, table)
        container.append(lbl_row_count)
        container.append(spin_row_count)
        wid.append(container)

        container = gui.HBox(width='100%')
        lbl_column_count = gui.Label('Columns:')
        spin_column_count = gui.SpinBox(3, 0, 4)
        spin_column_count.onchange.do(self.on_column_count_change, table)
        container.append(lbl_column_count)
        container.append(spin_column_count)
        wid.append(container)

        bt_fill_table = gui.Button('Fill table', width=100)
        bt_fill_table.onclick.do(self.fill_table, table)
        wid.append(bt_fill_table)

        chk_use_title = gui.CheckBoxLabel('Use title', True)
        chk_use_title.onchange.do(self.on_use_title_change, table)
        wid.append(chk_use_title)

        self.fill_table(table, table)

        table.on_item_changed.do(self.on_table_item_changed)

        wid.append(table)
        # returning the root widget
        return wid
Ejemplo n.º 7
0
    def on_button_show_rsc(self, emitter):

        # Clear view w/ message
        self.action_wait()

        # get data
        self.rscs = cluster.get_rd()

        # Clear wait message
        self.view_clear()

        if self.rscs:
            for rsc in self.rscs:
                # A display row for each resources
                row = gui.HBox(style={'border':'1px solid gray', 'margin':'10px', 'text-align':'left'})
                self.disp_rsc_row.append(row)

                # Add row heading
                lbl_msg = str(self.disp_rsc_row_count) + '. Resource: ' + rsc['rsc_name']
                lbl = gui.Label(lbl_msg)
                self.disp_rsc_row[self.disp_rsc_row_count].append(lbl, 'rsc_name')
                print(lbl_msg)

                # Populate the row w/ resource nodes
                rsc_nodes = cluster.get_rsc_by_rsc(rsc['rsc_name'])
                self.rsc_row_add(rsc_nodes, row=self.disp_rsc_row_count)

                self.disp_rsc_row_count += 1
                print('Rsc count: ' + str(self.disp_rsc_row_count))
        else:
            lbl_msg = 'No LINSTOR Resources found'
            self.add_view_line(lbl_msg)

        # Add widgets for Resource Create
        row = gui.HBox(style={'border':'1px solid gray', 'margin':'10px', 'text-align':'left'})
        self.disp_rsc_row.append(row)

        lbl_rsc_create_msg = 'Create a new resource volume'
        lbl_rsc_create = gui.Label(lbl_rsc_create_msg)
        bt_rsc_create = gui.Button('Proceed', width=200, height=30, margin='10px')
        bt_rsc_create.onclick.connect(self.rsc_create)

        self.disp_rsc_row[self.disp_rsc_row_count].append(lbl_rsc_create, 'lbl')
        # text window is global for proper live look up
        self.disp_rsc_row[self.disp_rsc_row_count].append(self.txt_rsc_create, 'new_rsc')
        self.disp_rsc_row[self.disp_rsc_row_count].append(bt_rsc_create, 'btn')
        self.disp_rsc_row_count += 1
        self.view_container.append(self.disp_rsc_row, 'rsc_list')
Ejemplo n.º 8
0
 async def update_key(self, key, value):
     control = self.controls.get(key, None)
     if control:
         if control['value'] != value:
             control['edit_value'].set_text(value)
     else:
         control = dict(
             label_key=G.Label(key, width="40%"),
             value=value,
             edit_value=G.TextInput(value, width="40%"),
             hbox=G.HBox(width="100%"),
             button_update=G.Button(u"🗘"),
             button_delete=G.Button(u"X")
         )
         self.make_update_handler(control['button_update'], key, control['edit_value'])
         self.make_delete_handler(control['button_delete'], key)
         control['hbox'].append([
             control['label_key'],
             control['edit_value'],
             control['button_update'],
             control['button_delete']
         ])
         control['edit_value'].set_text(value)
         self.vbox_list.append(control['hbox'])
         self.controls[key] = control
         await trio.sleep(0)
Ejemplo n.º 9
0
    def __init__(self, *args):
        super(HistoryEventWidget, self).__init__(*args)
        self.css_margin = "5px auto"
        self.add_class("border border-secondary")
        self.image_path: Optional[str] = None
        self.image_thumbnail = StaticPILImageWidget(None)
        self.labels_lbl = gui.Label("")
        self.event_date_lbl = gui.Label("")
        self.camera_name_lbl = gui.Label("")
        self.roi_name_lbl = gui.Label("")
        self.download_image_btn = SButton(
            "", "fa-file-download", styles={"padding": "5px 10px"}
        )
        self.select_checkbox = gui.CheckBox()

        self.image_thumbnail.set_size(*Config.MINI_THUMBNAIL_SIZE)
        self.image_thumbnail.css_margin = "1px"
        self.labels_lbl.css_width = "20%"
        self.event_date_lbl.css_width = "20%"

        hl = gui.HBox()
        hl.append(self.select_checkbox)
        hl.append(self.image_thumbnail)
        hl.append(self.labels_lbl)
        hl.append(self.event_date_lbl)
        hl.append(self.camera_name_lbl)
        hl.append(self.roi_name_lbl)
        hl.append(self.download_image_btn)
        self.layout = hl
        self.append(hl)

        # signals
        self.download_image_btn.onclick.do(self.on_download_image)
        self.image_thumbnail.onclick.do(self.on_download_image)
        self.select_checkbox.onclick.do(self.checkbox_toggled)
Ejemplo n.º 10
0
    def main(self):
        body = gui.VBox(width='100%', height='100%')
        main_container = gui.VBox(width=400,
                                  height=140,
                                  style={
                                      'align': 'center',
                                      'border': '5px #FFAC55 solid'
                                  })
        btn_container = gui.HBox(width=300, height=30)
        link_to_github = gui.Link(
            'https://github.com/npes87184/PyM3UGenerator', 'Fork me here')

        self.lbl = gui.Label('Please choose a folder')
        self.select_bt = gui.Button('Select folder', width=100, height=30)
        self.go_bt = gui.Button('Go', width=100, height=30)

        self.select_bt.onclick.do(self.on_select_btn_pressed)
        self.go_bt.onclick.do(self.on_go_btn_pressed)

        btn_container.append(self.select_bt)
        btn_container.append(self.go_bt)

        main_container.append(self.lbl)
        main_container.append(btn_container)
        main_container.append(link_to_github)
        body.append(main_container)

        return body
Ejemplo n.º 11
0
    def _tlx_weighting(self, user, type_):
        self.all_combos = list(list(pair) for pair in combinations(self.tlx.components.keys(), 2))
        shuffle(self.all_combos)
        self.weights = {k: 0 for k in self.tlx.components.keys()}

        self.weight_index = 0
        self.pair = ["", ""]

        self.dialog = gui.GenericDialog(title="NASA-TLX Weighting", message=f"NASA Task Load Index for the {type_.name} view experiment performed by {user.name}. Which component do you feel contributed more to your task load?", width="300px")

        self.weight_progress_label = gui.Label(f"1/{len(self.all_combos)}")
        self.dialog.add_field("dweightprogress", self.weight_progress_label)

        box = gui.HBox(width="100%", height=50, margin="10px")
        self.button_left = gui.Button("", margin="10px")
        self.button_right = gui.Button("", margin="10px")
        box.append(self.button_left)
        box.append(self.button_right)
        self.dialog.add_field("dweightbox", box)

        self.pair = self.all_combos[self.weight_index]
        shuffle(self.pair)
        self.button_left.set_text(self.tlx.components[self.pair[0]].name)
        self.button_right.set_text(self.tlx.components[self.pair[1]].name)
        self.button_left.set_on_click_listener(self.weight_button_pressed, self.pair[0])
        self.button_right.set_on_click_listener(self.weight_button_pressed, self.pair[1])

        self.dialog.set_on_confirm_dialog_listener(self.weighting_done)
        self.dialog.show(self)
    def initBezier(self, robot):
        bezierBox = self.sectionBox()
        bezierBox.append(gui.Label("Bezier Path Following"))

        bezierButtons = gui.HBox()
        bezierBox.append(bezierButtons)

        self.bezierPathLines = []

        def addPoint(button):
            self.bezierPathLines.append(self.selectedCoord)
            self.updateSchedulerFlag = True

        addBtn = gui.Button("Add Point")
        bezierButtons.append(addBtn)
        addBtn.set_on_click_listener(addPoint)

        def endPath(button):
            self.bezierPathLines.append(self.selectedCoord)
            self.c_addGenericAction(None, "bezier", self.bezierPathLines)
            self.bezierPathLines = []

        endBtn = gui.Button("End Path")
        bezierButtons.append(endBtn)
        endBtn.set_on_click_listener(endPath)

        def resetPath(button):
            self.bezierPathLines = []
            self.updateSchedulerFlag = True

        resetBtn = gui.Button("Reset Path")
        bezierButtons.append(resetBtn)
        resetBtn.set_on_click_listener(resetPath)

        return bezierBox
Ejemplo n.º 13
0
    def main(self):
        # creating two "pages" widgets to be shown alternatively
        lbl = gui.Label("Page 2. Press the button to change the page.",
                        style={'font-size': '20px'})
        bt2 = gui.Button("change page")
        page2 = gui.HBox(children=[lbl, bt2],
                         style={
                             'margin': '0px auto',
                             'background-color': 'lightgray'
                         })

        lbl = gui.Label("Page 1. Press the button to change the page.",
                        style={'font-size': '20px'})
        bt1 = gui.Button("change page")
        page1 = gui.VBox(children=[lbl, bt1],
                         style={
                             'width': '300px',
                             'height': '200px',
                             'margin': '0px auto',
                             'background-color': 'white'
                         })

        bt1.onclick.do(self.set_different_root_widget, page2)
        bt2.onclick.do(self.set_different_root_widget, page1)

        # returning the root widget
        return page1
Ejemplo n.º 14
0
    def _model_page(self):

        # Define root widget.
        main_container = gui.Widget(width='100%',
                                    style={
                                        'vertical-align': 'top',
                                        'align-content': 'center'
                                    })

        # Define title and instructions text.
        models_title = wc.h2('Bayesian Non-Parametric Models')
        models_title.style['text-align'] = 'center'
        models_instructions = wc.h4(
            'Choose a model from the pulldown menu. Afterwards, the user can choose to load a '
            'existing model trained for a specific data set to visualise results and generate '
            'data from the model. Or the user can train a new model by (1) setting model '
            'hyperparameters, (2) choosing a data set, and (3) setting experiment parameters.'
        )
        models_instructions.style['text-align'] = 'justify-all'

        # Define row container for model selection.
        selection_container = gui.HBox(width='50%',
                                       margin='auto',
                                       style={
                                           'display': 'block',
                                           'overflow': 'auto',
                                           'align-content': 'center',
                                           'margin-top': '50px'
                                       })

        model_label = wc.h5('Model: ')
        model_label.style['margin-top'] = '8px'

        # Define drop down with different models.
        self.model_dropdown = gui.DropDown(width='250px',
                                           style={'margin-right': '15px'})
        self.model_dropdown.add_class("form-control dropdown")
        self.model_dropdown.append(
            dict(
                zip(self.models,
                    [gui.DropDownItem(model_str)
                     for model_str in self.models])))

        self.model_select_button = gui.Button('Select',
                                              width='100px',
                                              style={'box-shadow': 'none'})
        self.model_select_button.add_class('btn btn-primary')
        self.model_select_button.onclick.connect(
            self.select_button_clicked)  # Listener function for mouse click.

        # Build up the webpage.
        selection_container.append(
            [model_label, self.model_dropdown, self.model_select_button])
        main_container.append([
            self.nav_bar, models_title, models_instructions,
            selection_container, self.footer
        ])

        # Return the root widget.
        return main_container
Ejemplo n.º 15
0
    def main(self, robot, appCallback):
        self.robot = robot

        root = gui.HBox(width = 1000, margin = "0px auto")
        root.style['align-items'] = 'stretch'

        leftSide = gui.VBox()
        leftSide.style['align-items'] = 'stretch'

        rightSide = gui.VBox()
        rightSide.style['align-items'] = 'flex-start'

        self.motorDataDict = { \
            "ampRow" : None,
            "tempRow" : None,
            "maxAmpRow" : None,
            "maxTempRow" : None,
            "amp" : [],
            "temp" : [],
            "maxAmp" : [],
            "maxTemp" : []
            }

        leftSide.append(self.initStats(robot))
        leftSide.append(self.initLedControl(robot))

        rightSide.append(self.initManual(robot))
        rightSide.append(self.initTest(robot))

        root.append(leftSide)
        root.append(rightSide)

        appCallback(self)
        return root
Ejemplo n.º 16
0
 def __init__(self,
              sourcePart: 'WebSourcePart',
              posKey: str,
              showSkipBtns: bool = False,
              showNextBtns: bool = False):
     self._sourcePart = sourcePart
     # all buttons are inserted into HBox
     self._box = gui.HBox()
     self.append(self._box, posKey)
     self._buttons = [
         self._createBtn(">", "12", PlayCommand.UNPAUSE),
         self._createBtn("II", "13", PlayCommand.PAUSE),
         self._createBtn("O", "14", PlayCommand.STOP),
     ]
     if showSkipBtns:
         self._buttons += [
             # posKeys - to the left
             self._createBtn("<<", "11", PlayCommand.SB),
             # posKeys - to the right
             self._createBtn(">>", "15", PlayCommand.SF),
         ]
     if showNextBtns:
         self._buttons += [
             # posKeys - to the left
             self._createBtn("|<<", "10", PlayCommand.PREV),
             # posKeys - to the right
             self._createBtn(">>|", "16", PlayCommand.NEXT),
         ]
Ejemplo n.º 17
0
    def main(self):
        wid = gui.HBox()
        wid.style['position'] = 'absolute'
        ctrl = gui.VBox(width=400)
        ctrl.style['justify-content'] = 'space-around'

        plotContainer = gui.Widget()

        plt = PlotlyWidget(data=self.data, id='plot')
        self.plt = plt
        plotContainer.append(plt)

        self.historyBox = LabelSpinBox(default_value=100, min=1, max=10000000,
                                       step=1, label='history')

        lbl = gui.Label('GUI')

        bt = gui.Button('Start', width=200, height=30)
        bt.style['margin'] = 'auto 50px'
        bt.style['background-color'] = 'green'

        self.started = False

        # setting the listener for the onclick event of the button
        bt.set_on_click_listener(self.on_button_pressed, ctrl)

        ctrl.append(lbl)
        ctrl.append(self.historyBox)
        ctrl.append(bt)

        # returning the root widget
        wid.append(ctrl)
        wid.append(plotContainer)

        return wid
Ejemplo n.º 18
0
    def add_field(self, key: str, desc: str, field: gui.Widget):
        """
        Adds a field to the dialog together with a descriptive label and a unique identifier.

        Note: You can access to the fields content calling the function GenericDialog.get_field(key).

        Args:
            key (str): The unique identifier for the field.
            desc (str): The string content of the description label.
            field (Widget): The instance of the field Widget. It can be for example a TextInput or maybe
            a custom widget.
        """
        label = gui.Label(desc)
        label.style["min-width"] = self.css_labels_min_width
        label.css_font_weight = 1000

        field.add_class("input")
        if not isinstance(field, gui.Button):
            field.set_style({
                "padding": "5px 5px",
                "background": "white",
                "border-bottom": "2px solid  # 00000061",
            })

        container = gui.HBox()
        container.style.update({
            "justify-content": "space-between",
            "overflow": "auto",
            "padding": "3px",
        })
        container.append(label, key="lbl" + key)
        container.append(field, key=key)
        self.container.append(container, key=key)
        self.inputs[key] = field
Ejemplo n.º 19
0
    def __init__(self, appInstance, **kwargs):
        self.appInstance = appInstance
        super(WidgetCollection, self).__init__(**kwargs)
        self.lblTitle = gui.Label("Widgets Toolbox")
        self.lblTitle.add_class("DialogTitle")
        self.widgetsContainer = gui.HBox(width='100%', height='85%')
        self.widgetsContainer.style.update({
            'overflow-y': 'scroll',
            'overflow-x': 'hidden',
            'flex-wrap': 'wrap',
            'background-color': 'white'
        })

        self.append([self.lblTitle, self.widgetsContainer])

        #load all widgets
        self.add_widget_to_collection(gui.HBox, width='250px', height='250px')
        self.add_widget_to_collection(gui.VBox, width='250px', height='250px')
        self.add_widget_to_collection(gui.Widget,
                                      width='250px',
                                      height='250px')
        self.add_widget_to_collection(gui.Button, width='100px', height='30px')
        self.add_widget_to_collection(gui.TextInput,
                                      width='100px',
                                      height='30px')
        self.add_widget_to_collection(gui.Label, width='100px', height='30px')
        self.add_widget_to_collection(gui.ListView,
                                      width='100px',
                                      height='30px')
        self.add_widget_to_collection(gui.ListItem,
                                      width='100px',
                                      height='30px')
        self.add_widget_to_collection(gui.DropDown,
                                      width='100px',
                                      height='30px')
        self.add_widget_to_collection(gui.DropDownItem,
                                      width='100px',
                                      height='30px')
        self.add_widget_to_collection(gui.Image, width='100px', height='100px')
        self.add_widget_to_collection(gui.CheckBoxLabel,
                                      width='100px',
                                      height='30px')
        self.add_widget_to_collection(gui.CheckBox,
                                      width='30px',
                                      height='30px')
        self.add_widget_to_collection(gui.SpinBox,
                                      width='100px',
                                      height='30px')
        self.add_widget_to_collection(gui.Slider, width='100px', height='30px')
        self.add_widget_to_collection(gui.ColorPicker,
                                      width='100px',
                                      height='30px')
        self.add_widget_to_collection(gui.Date, width='100px', height='30px')
        self.add_widget_to_collection(gui.Link, width='100px', height='30px')
        self.add_widget_to_collection(gui.VideoPlayer,
                                      width='100px',
                                      height='100px')
        self.add_widget_to_collection(gui.TableWidget,
                                      width='100px',
                                      height='100px')
Ejemplo n.º 20
0
 def filtersMenu(self, widget):
     self.dialog = gui.GenericDialog(
         title='Filters Menu',
         message='Click Ok To Confirm Selection',
         width='300px')
     self.main_cont = gui.HBox(width=300)
     dates_cont = gui.VBox(width='50%')
     for date in dates:
         chb = gui.CheckBoxLabel(date, filt[date])
         chb.onchange.do(self.checkbox)
         dates_cont.append(chb)
     chb.onchange.do(self.checkbox)
     dates_cont.append(chb)
     self.main_cont.append(dates_cont)
     names_cont = gui.VBox(width='50%')
     for name in names:
         chb = gui.CheckBoxLabel(name, filt[name])
         chb.onchange.do(self.checkbox)
         names_cont.append(chb)
     self.main_cont.append(names_cont)
     names_cont.style['align-items'] = 'flex-start'
     dates_cont.style['align-items'] = 'flex-start'
     names_cont.style['justify-content'] = 'flex-start'
     dates_cont.style['justify-content'] = 'flex-start'
     self.dialog.add_field('main_cont', self.main_cont)
     self.dialog.confirm_dialog.do(self.diag_conf)
     self.dialog.show(self)
Ejemplo n.º 21
0
    def init__gui__(self):
        self.vbox_list_requests = G.VBox(width="100%")
        self.vbox_list_requests.append(G.Label("[Pending user requests]"))

        self.button_update = G.Button(u"🗘")
        self.button_update.onclick.do(self.a(self.on_update_all))

        self.vbox_publics = G.VBox(width="100%")
        self.vbox_publics.append(G.Label("[Publics]"))

        self.hbox_create_new = G.HBox(width="100%")
        self.edit_name = G.TextInput()
        self.button_add_new = G.Button("+")
        self.hbox_create_new.append([self.edit_name, self.button_add_new])
        self.button_add_new.onclick.do(self.a(self.on_add_new))

        self.vbox_publish_form = G.VBox(width="100%")
        self.select_channels = G.DropDown()
        self.edit_publish =G.TextInput()
        self.button_publish = G.Button("publish")
        self.button_publish.onclick.do(self.a(self.on_publish))
        self.vbox_publish_form.append([
            G.Label("[new publishment]"),
            self.select_channels,
            self.edit_publish,
            self.button_publish
        ])

        self.publics_controls = dict()
Ejemplo n.º 22
0
    def init__gui__(self):
        self.x = gui.TextInput()
        self.y = gui.TextInput()

        self.hbox = hbox = gui.HBox(width="100%")
        hbox.append([gui.Label("X = "), self.x, gui.Label("Y = "), self.y])
        self.label = gui.Label(text=f" Result: ")
        self.button = gui.Button("update")
        self.button.onclick.do(self.onclickbutton)
Ejemplo n.º 23
0
def hBoxWith(*args, **kwargs):
    """
    Construct a REMI HBox with the given keyword arguments, and add all of the
    given widgets to it.
    """
    box = gui.HBox(**kwargs)
    for widget in args:
        box.append(widget)
    return box
Ejemplo n.º 24
0
 def _getLabelBox(self, width, height):
     box = gui.HBox(width=width - 20, height=height, margin='0px auto')
     # index
     text = self._node.label
     if self._totalParents > 1:
         text += "-> (" + str(self._totalParents - 1) + ") ->"
     box.append(gui.Label(text=text), '1')
     box.set_on_click_listener(self._openNodeOnClick)
     return box
Ejemplo n.º 25
0
 async def show_pending_request(self, chat_id, info):
     approve_button = G.Button("approve")
     hbox = G.HBox(width="100%")
     hbox.append([
         G.Label(f"{info}", width=150),
         approve_button
     ])
     self.vbox_list_requests.append(hbox)
     self.make_approve_handler(hbox, approve_button, chat_id)
    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
Ejemplo n.º 27
0
    def initFieldMap(self, robot):
        fieldBox = self.sectionBox()

        robotBox = gui.HBox()
        fieldBox.append(robotBox)

        setPositionBtn = gui.Button("Set Robot to Cursor")
        setPositionBtn.onclick.connect(self.c_setRobotPosition)
        robotBox.append(setPositionBtn)

        def setRobotAngle(button, angle):
            pathFollower = self.robot.pathFollower
            pathFollower.setPosition(pathFollower.robotX, pathFollower.robotY,
                                     angle)

        leftBtn = gui.Button('<')
        leftBtn.onclick.connect(setRobotAngle, math.radians(90))
        robotBox.append(leftBtn)
        rightBtn = gui.Button('>')
        rightBtn.onclick.connect(setRobotAngle, math.radians(-90))
        robotBox.append(rightBtn)
        upBtn = gui.Button('^')
        upBtn.onclick.connect(setRobotAngle, 0)
        robotBox.append(upBtn)
        downBtn = gui.Button('v')
        downBtn.onclick.connect(setRobotAngle, math.radians(180))
        robotBox.append(downBtn)

        self.fieldSvg = gui.Svg(CompetitionBotDashboard.FIELD_WIDTH,
                                CompetitionBotDashboard.FIELD_HEIGHT)
        self.fieldSvg.set_on_mousedown_listener(self.mouse_down_listener)
        fieldBox.append(self.fieldSvg)

        self.image = gui.SvgShape(0, 0)
        self.image.type = 'image'
        self.image.attributes['width'] = CompetitionBotDashboard.FIELD_WIDTH
        self.image.attributes['height'] = CompetitionBotDashboard.FIELD_HEIGHT
        self.image.attributes['xlink:href'] = '/res:frcField.PNG'
        self.fieldSvg.append(self.image)

        self.targetPoints = coordinates.targetPoints
        for point in self.targetPoints:
            point = fieldToSvgCoordinates(point.x, point.y)
            wp_dot = gui.SvgCircle(point[0], point[1], 5)
            wp_dot.attributes['fill'] = 'blue'
            self.fieldSvg.append(wp_dot)

        self.cursorArrow = Arrow('red')
        self.fieldSvg.append(self.cursorArrow)

        self.robotArrow = Arrow('green')
        self.fieldSvg.append(self.robotArrow)

        self.robotPathLines = []

        return fieldBox
Ejemplo n.º 28
0
    def append_field(self, field, key='', bold=False):

        key = field.identifier if key == '' else key
        self.inputs[key] = field
        _row = gui.HBox()
        _row.style['justify-content'] = 'space-between'
        _row.style['overflow'] = 'auto'
        _row.style['padding'] = '3px'
        _row.append(self.inputs[key], key=key)
        self._container.append(_row, key=key)
Ejemplo n.º 29
0
 def __init__(self, posKey: str):
     # labels are inserted into HBox
     self._box = gui.HBox()
     self.append(self._box, posKey)
     self._timePosLabel = gui.Label(text="")
     self._box.append(self._timePosLabel, "1")
     self._separatorLabel = gui.Label(text="")
     self._box.append(self._separatorLabel, "2")
     self._trackDuration = gui.Label(text="")
     self._box.append(self._trackDuration, "3")
    def main(self, robot, appCallback):
        self.robot = robot

        self.fieldWidth = 520
        self.fieldHeight = 260
        self.fieldPixelsPerFoot = 10

        root = gui.HBox()
        root.style['align-items'] = 'stretch'

        leftSide = gui.VBox()
        leftSide.style['align-items'] = 'stretch'

        middle = gui.VBox()

        rightSide = gui.VBox()
        rightSide.style['align-items'] = 'stretch'

        self.motorDataDict = { \
            "ampRow" : None,
            "tempRow" : None,
            "maxAmpRow" : None,
            "maxTempRow" : None,
            "amp" : [],
            "temp" : [],
            "maxAmp" : [],
            "maxTemp" : []
            }

        leftSide.append(self.initStats(robot))
        leftSide.append(self.initLedControl(robot))
        leftSide.append(self.initScheduler(robot))
        leftSide.append(self.initBezier(robot))
        leftSide.append(self.initPathRecording(robot))

        middle.append(self.initCamera(robot))
        middle.append(self.initFieldMap(robot))
        middle.append(self.initFieldSwitcher(robot))

        rightSide.append(self.initManual(robot))
        self.autoSpeedGroup.highlight("medium")
        rightSide.append(self.initPidControlsBox(robot))
        rightSide.append(self.initVisionControl(robot))
        rightSide.append(self.initTest(robot))
        rightSide.append(self.initSubsystemsInfo(robot))

        root.append(leftSide)
        root.append(middle)
        root.append(rightSide)

        self.updateSchedulerFlag = False

        appCallback(self)
        return root