示例#1
0
    def add_text_box(self, title, row, column, row_span = 1, column_span = 1, padx = 1, pady = 0, initial_text = ''):
        """Function that adds a new text box to the CUI grid

        Parameters
        ----------
        title : str
            The title of the textbox
        row : int
            The row value, from the top down
        column : int
            The column value from the top down
        row_span=1 : int
            The number of rows to span accross
        column_span=1 : int
            the number of columns to span accross
        padx=1 : int
            number of padding characters in the x direction
        pady=0 : int
            number of padding characters in the y direction
        initial_text='' : str
            Initial text for the textbox

        Returns
        -------
        new_text_box : TextBox
            A reference to the created textbox object.
        """

        id = 'Widget{}'.format(len(self.widgets.keys()))
        new_text_box = widgets.TextBox(id, title,  self.grid, row, column, row_span, column_span, padx, pady, initial_text)
        self.widgets[id] = new_text_box
        if self.selected_widget is None:
            self.set_selected_widget(id)
        return new_text_box
示例#2
0
    def add_text_box(self,
                     title: str,
                     row: int,
                     column: int,
                     row_span: int = 1,
                     column_span: int = 1,
                     padx: int = 1,
                     pady: int = 0,
                     initial_text: str = '',
                     password: bool = False) -> 'py_cui.widgets.TextBox':
        """Function that adds a new text box to the CUI grid

        Parameters
        ----------
        title : str
            The title of the textbox
        row : int
            The row value, from the top down
        column : int
            The column value from the top down
        row_span=1 : int
            The number of rows to span accross
        column_span=1 : int
            the number of columns to span accross
        padx=1 : int
            number of padding characters in the x direction
        pady=0 : int
            number of padding characters in the y direction
        initial_text='' : str
            Initial text for the textbox
        password=False : bool
            Toggle to show '*' instead of characters.

        Returns
        -------
        new_text_box : TextBox
            A reference to the created textbox object.
        """

        id = len(self.get_widgets().keys())
        new_text_box = widgets.TextBox(id, title, self._grid, row, column,
                                       row_span, column_span, padx, pady,
                                       self._logger, initial_text, password)
        self._widgets[id] = new_text_box
        if self._selected_widget is None:
            self.set_selected_widget(id)
        self._logger.debug(
            f'Adding widget {title} w/ ID {id} of type {str(type(new_text_box))}'
        )
        return new_text_box