예제 #1
0
파일: edit.py 프로젝트: figtools/figgy-cli
 def main(self):
     edit_form = Form()
     self.value_box = edit_form.add(MultiLineInput,
                                    value=self.value,
                                    name=f'Input value for: {self.name}',
                                    max_height=12)
     self.description_box = edit_form.add(MultiLineInput,
                                          value=self.description,
                                          name="Optional Description: ",
                                          max_height=12)
     edit_form.edit()
예제 #2
0
    def main(self):
        global npy_form
        self._browse_box = Form(
            name=
            "Browse Parameters: - 'e' to expand, 'c' to collapse, <s> to select, <d> to delete, "
            "<Tab> & <Shift+Tab> moves cursor between `OK` and `Tree` views.")

        # Value Box Relative Location
        val_relx, val_rely = int(self._browse_box.columns /
                                 2) * -1, int(self._browse_box.lines - 1) * -1
        val_max_height = int(self._browse_box.lines / 2) - self.BUFFER
        val_max_width = int(self._browse_box.columns / 2) - self.BUFFER

        # Selection Box Relative Location
        sel_relx, sel_rely = int(
            self._browse_box.columns /
            2) * -1, int(self._browse_box.lines / 2 + 1) * -1
        sel_max_height = int(self._browse_box.lines / 2) - self.BUFFER
        sel_max_width = int(self._browse_box.columns / 2) - self.BUFFER

        tree = self._browse_box.add(LogicalMLTree,
                                    on_select_callable=self.on_select,
                                    on_delete_callable=self.on_delete,
                                    max_width=self._browse_box.columns +
                                    val_relx - self.BUFFER)

        self.value_box = self._browse_box.add_widget(SelectedValueBox,
                                                     name="Parameter Value: ",
                                                     relx=val_relx,
                                                     rely=val_rely,
                                                     max_height=val_max_height,
                                                     max_width=val_max_width,
                                                     allow_filtering=False,
                                                     editable=False)

        self.select_state_box = self._browse_box.add_widget(
            SelectedValueBox,
            name="Selections: ",
            relx=sel_relx,
            rely=sel_rely,
            max_height=sel_max_height,
            max_width=sel_max_width,
            allow_filtering=False,
            editable=False)

        td = DeletableNPSTreeData(content='Root',
                                  selectable=True,
                                  expanded=True,
                                  ignoreRoot=True)
        start = Utils.millis_since_epoch()
        children = []
        if self._browse.prefix:
            prefix_child = td.newChild(content=self._browse.prefix,
                                       selectable=False,
                                       expanded=False)
            children = [prefix_child]
        else:
            log.info(
                f"--{prefix.name} missing, defaulting to normal browse tree.")

            for namespace in self._config_view.get_authorized_namespaces():
                child = td.newChild(content=namespace,
                                    selectable=False,
                                    expanded=False)
                children.append(child)

        for child in children:
            self._browse.dirs.add(child.getContent())

        futures = []

        with ThreadPoolExecutor(max_workers=10) as pool:
            for child in children:
                futures.append(
                    pool.submit(self._browse.add_children, child.getContent(),
                                child))

        for future in as_completed(futures):
            pass

        tree.values = td
        self._browse_box.edit()
        selection_objs = tree.get_selected_objects(return_node=True)

        for selection in selection_objs:
            full_path = ''
            while selection._parent is not None:
                full_path = selection.content + full_path
                selection = selection._parent
            self._browse.selected_ps_paths.append(full_path)

        delete_objs = tree.get_objects_to_delete(return_node=True)
        for selection in delete_objs:
            full_path = ''
            while selection._parent is not None:
                full_path = selection.content + full_path
                selection = selection._parent
            self._browse.deleted_ps_paths.append(full_path)
예제 #3
0
 def main(self):
     form = Form(name='Welcome to Npyscreen')
     form.edit()