Example #1
0
    def test_center_widget(self):
        w = CenterWidget(self.w2)

        w.render(10)

        expected_result = [u"   Test"]

        self.evaluate_result(w.get_lines(), expected_result)
    def refresh(self, args=None):
        super().refresh()

        # Text widget
        # Show text to user. This is basic widget which will handle
        # wrapping of words for you.
        text_widget = TextWidget("Text widget")
        self.window.add_with_separator(text_widget)

        # Center widget
        # Wrap extisting widget and center it to the middle of the screen.
        text = TextWidget("Center widget")
        center_widget = CenterWidget(text)
        self.window.add_with_separator(
            center_widget, blank_lines=3)  # Add two more blank lines

        # Checkbox widget
        # Checkbox which can hold 2 states.
        checkbox_widget = CheckboxWidget(key="o",
                                         title="Checkbox title",
                                         text="Checkbox text",
                                         completed=True)
        self.window.add_with_separator(checkbox_widget)

        # Checkbox widget unchecked
        checkbox_widget_unchecked = CheckboxWidget(key="o",
                                                   title="Checkbox title",
                                                   text="Unchecked",
                                                   completed=False)
        self.window.add_with_separator(checkbox_widget_unchecked)
 def refresh(self, args=None):
     """Print text to user with number of continue clicked."""
     super().refresh(args)
     # Print counter to the screen.
     widget = TextWidget("You pressed {} times on continue".format(self.continue_count))
     # Center this counter to middle of the screen.
     center_widget = CenterWidget(widget)
     # Add the centered widget to the window container.
     self.window.add(center_widget)
Example #4
0
    def refresh(self, args=None):
        """Refresh method is called always before the screen will be printed.

        All items for printing should be updated or created here.
        """
        # Init window container. The windows container will be erased here.
        # The window container is the base container. Everything for rendering should be put
        # into this container, including other containers.
        super().refresh(args)

        # Add the screen header message before our items.
        header = TextWidget("Please complete all the spokes to continue")
        header = CenterWidget(header)
        self.window.add_with_separator(header, blank_lines=2)

        # Create the empty container.
        # It will add numbering, process user input and positioning for us.
        self._container = ListRowContainer(2)

        # Create widget to get user name.
        widget = self._create_name_widget()
        # Add widget, callback, arguments to the container.
        #
        # widget - Widget we want to render. It will be numbered automatically.
        #          Could be container if needed.
        # callback - This callback will be called by the ListRowContainer.process_user_input()
        #            method when a user press the number of this item. Callback will get args
        #            passed as 3rd argument.
        # args - Argument for callback.
        self._container.add(widget, self._push_screen_callback,
                            self._name_spoke)

        # Create surname widget and add it to the container.
        widget = self._create_surname_widget()
        self._container.add(widget, self._push_screen_callback,
                            self._surname_spoke)

        # Create password widget and add it to the container.
        widget = self._create_password_widget()
        self._container.add(widget, self._push_screen_callback,
                            self._password_spoke)

        # Add the ListRowContainer container to the WindowContainer container.
        self.window.add_with_separator(self._container)
 def refresh(self, args=None):
     """Write message to user."""
     super().refresh(args)
     w = TextWidget("Counter {}".format(self._counter))
     self.window.add_with_separator(CenterWidget(w))
    def refresh(self, args=None):
        super().refresh(args)

        w = CenterWidget(TextWidget("Press '1' to enter Entry counter"))

        self.window.add_with_separator(w)
 def refresh(self, args=None):
     """Write message to user."""
     super().refresh(args)
     w = TextWidget(self._message)
     self.window.add(CenterWidget(w))