How to use the asciimatics.widgets.Divider function in asciimatics

To help you get started, we’ve selected a few asciimatics examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github kayagoban / shadowlands / shadowlands / sl_frame.py View on Github external
def add_button(self, ok_fn, text, layout=[100], layout_index=0, add_divider=True):
        _layout = Layout(layout)
        self.add_layout(_layout)
        _layout.add_widget(Button(text, ok_fn), layout_index)
        if add_divider:
            _layout.add_widget(Divider(draw_line=False))
github kayagoban / shadowlands / shadowlands / sl_frame.py View on Github external
def add_listbox(self, height, options, default_value=None, on_select=None, layout=[100], layout_index=0, add_divider=True, **kwargs):
        _layout = Layout(layout)
        self.add_layout(_layout)
        list_widget = ListBox(height, options, on_select=on_select, **kwargs)
        _layout.add_widget(list_widget, layout_index)
        if add_divider:
            _layout.add_widget(Divider(draw_line=False))
        if default_value is not None:
            list_widget._value = default_value
        return lambda: list_widget.value
github peterbrittain / asciimatics / samples / contact_list.py View on Github external
self._model = model

        # Create the form for displaying the list of contacts.
        self._list_view = ListBox(
            Widget.FILL_FRAME,
            model.get_summary(),
            name="contacts",
            add_scroll_bar=True,
            on_change=self._on_pick,
            on_select=self._edit)
        self._edit_button = Button("Edit", self._edit)
        self._delete_button = Button("Delete", self._delete)
        layout = Layout([100], fill_frame=True)
        self.add_layout(layout)
        layout.add_widget(self._list_view)
        layout.add_widget(Divider())
        layout2 = Layout([1, 1, 1, 1])
        self.add_layout(layout2)
        layout2.add_widget(Button("Add", self._add), 0)
        layout2.add_widget(self._edit_button, 1)
        layout2.add_widget(self._delete_button, 2)
        layout2.add_widget(Button("Quit", self._quit), 3)
        self.fix()
        self._on_pick()
github cowboy8625 / WordRPG / gui / _backup / asciimatics / player.py View on Github external
# self.layout.add_widget(CheckBox("Field 1",
		# 						   label="A very silly long name for fields:",
		# 						   name="CA",
		# 						   on_change=self._on_change), 1)
		# self.layout.add_widget(
		# 	CheckBox("Field 2", name="CB", on_change=self._on_change), 1)
		# self.layout.add_widget(
		# 	CheckBox("Field 3", name="CC", on_change=self._on_change), 1)
		
		char_class = DropdownList( [ ( "FIGHTER", 1), ( "MAGE", 2 ), ( "ASSASIN", 3 ) ],
									label 		= "CLASS:",
									name 			= "class",
									on_change	= self._on_change)
		self.layout.add_widget( char_class, 1 )

		self.layout.add_widget( Divider( height = 3 ), 1 )
github missionpinball / mpf / mpf / core / text_ui.py View on Github external
def _update_ball_devices(self, **kwargs):
        del kwargs
        # TODO: do not create widgets. just update contents
        self.ball_device_widgets = []
        self.ball_device_widgets.append(Label("BALL COUNTS"))
        self.ball_device_widgets.append(Divider())

        try:
            for pf in self.machine.playfields.values():
                widget = Label('{}: {} '.format(pf.name, pf.balls))
                if pf.balls:
                    widget.custom_colour = "pf_active"
                else:
                    widget.custom_colour = "pf_inactive"
                self.ball_device_widgets.append(widget)

        except AttributeError:
            pass

        for bd in self.ball_devices:
            widget = Label('{}: {} ({})'.format(bd.name, bd.balls, bd.state))
            if bd.balls:
github peterbrittain / asciimatics / asciimatics / widgets.py View on Github external
def __init__(self, draw_line=True, height=1):
        """
        :param draw_line: Whether to draw a line in the centre of the gap.
        :param height: The required vertical gap.
        """
        # Dividers have no value and so should have no name for look-ups either.
        super(Divider, self).__init__(None, tab_stop=False)
        self._draw_line = draw_line
        self._required_height = height
github missionpinball / mpf / mpf / core / text_ui.py View on Github external
def _update_switch_layout(self):
        num = 0
        self.switch_widgets = []
        self.switches = {}
        self.switch_widgets.append((Label("SWITCHES"), 1))
        self.switch_widgets.append((Divider(), 1))
        self.switch_widgets.append((Label(""), 2))
        self.switch_widgets.append((Divider(), 2))

        for sw in sorted(self.machine.switches.values()):
            if sw.invert:
                name = sw.name + '*'
            else:
                name = sw.name

            col = 1 if num <= int(len(self.machine.switches) / 2) else 2

            switch_widget = Label(name)
            if sw.state:
                switch_widget.custom_colour = "active_switch"

            self.switch_widgets.append((switch_widget, col))
            self.switches[sw.name] = (sw, switch_widget)
github kayagoban / shadowlands / shadowlands / sl_frame.py View on Github external
def add_file_browser(self, path='/', height=15, on_change_fn=None, add_divider=True):
        layout = Layout([100])
        self.add_layout(layout)
        browser = FileBrowser(height, path, on_change=on_change_fn)
        layout.add_widget(browser)
        if add_divider: 
            layout.add_widget(Divider(draw_line=False))
        return lambda: browser._value
github missionpinball / mpf / mpf / core / text_ui.py View on Github external
def _update_switch_layout(self):
        num = 0
        self.switch_widgets = []
        self.switches = {}
        self.switch_widgets.append((Label("SWITCHES"), 1))
        self.switch_widgets.append((Divider(), 1))
        self.switch_widgets.append((Label(""), 2))
        self.switch_widgets.append((Divider(), 2))

        for sw in sorted(self.machine.switches.values()):
            if sw.invert:
                name = sw.name + '*'
            else:
                name = sw.name

            col = 1 if num <= int(len(self.machine.switches) / 2) else 2

            switch_widget = Label(name)
            if sw.state:
                switch_widget.custom_colour = "active_switch"

            self.switch_widgets.append((switch_widget, col))