How to use the asciimatics.widgets.Frame 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 peterbrittain / asciimatics / samples / experimental.py View on Github external
import sys

# Initial data for the form
form_data = {
    "TA": ["Hello world!", "How are you?"],
    "TB": "alphabet",
    "TC": "123",
    "TD": "a@b.com",
    "Things": 2,
    "CA": False,
    "CB": True,
    "CC": False,
}


class DemoFrame(Frame):
    def __init__(self, screen):
        super(DemoFrame, self).__init__(screen,
                                        int(screen.height * 2 // 3),
                                        int(screen.width * 2 // 3),
                                        data=form_data,
                                        has_shadow=True,
                                        name="My Form")
        layout = Layout([1, 18, 1])
        self.add_layout(layout)
        self._reset_button = Button("Reset", self._reset)
        layout.add_widget(Label("Group 1:"), 1)
        layout.add_widget(TextBox(5,
                                  label="My First Box:",
                                  name="TA",
                                  on_change=self._on_change), 1)
        layout.add_widget(
github peterbrittain / asciimatics / tests / test_widgets.py View on Github external
def test_frame_themes(self):
        """
        Check we can set a colour theme for a Frame.
        """
        # Now set up the Frame ready for testing
        screen = MagicMock(spec=Screen, colours=8, unicode_aware=False)
        scene = Scene([], duration=-1)
        canvas = Canvas(screen, 10, 40, 0, 0)
        form = Frame(canvas, canvas.height, canvas.width)

        # Check colour changes work...
        self.assertEqual(
            form.palette["background"],
            (Screen.COLOUR_WHITE, Screen.A_NORMAL, Screen.COLOUR_BLUE))
        form.set_theme("monochrome")
        self.assertEqual(
            form.palette["background"],
            (Screen.COLOUR_WHITE, Screen.A_NORMAL, Screen.COLOUR_BLACK))

        # Check that a bad theme name has no effect.
        form.set_theme("blah - this doesn't exist")
        self.assertEqual(
            form.palette["background"],
            (Screen.COLOUR_WHITE, Screen.A_NORMAL, Screen.COLOUR_BLACK))
github kayagoban / shadowlands / shadowlands / tui / effects / widgets.py View on Github external
from shadowlands.tui.debug import debug
# Make sure the widget frame is_modal or claimed_focus.
# otherwise the text is not swallowed and our menus are buggered.
# "return None if claimed_focus or self._is_modal else old_event" - widgets.py:882


#debug(self._screen._screen); import pdb; pdb.set_trace()


#debug(); pdb.set_trace()





class ValueOptions(Frame):
    def __init__(self, screen, interface):
        super(ValueOptions, self).__init__(screen, 15, 24, y=2, has_shadow=True, is_modal=True, name="valueopts", title="Value display", can_scroll=False)
        self.set_theme('shadowlands')
        self._interface = interface

    
        layout = Layout([100], fill_frame=True)
        self.add_layout(layout)
        layout.add_widget(Divider(draw_line=False))

        self._node = self._interface.node

        options = []
        currencies = self._interface.price_poller.eth_prices
        for k in currencies.keys():
            options.append( (k, k) )
github tonybaloney / retox / retox / ui.py View on Github external
_scene = Scene([host_frame] + [frame for _, frame in _env_screens.items()], -1, name="Retox")
    _log_scene = Scene([frame for _, frame in _log_screens.items()], duration=10, name="Logs")
    return _env_screens, _scene, _log_scene, host_frame


class RetoxRefreshMixin(object):
    def refresh(self):
        '''
        Refresh the list and the screen
        '''
        self._screen.force_update()
        self._screen.refresh()
        self._update(1)


class RetoxFrame(widgets.Frame, RetoxRefreshMixin):
    '''
    A UI frame for hosting the details of the overall host
    '''

    def __init__(self, screen, args):
        '''
        Create a new frame

        :param screen: The screen instance
        :type  screen: :class:`asciimatics.screen.Screen`

        :param args:  The tox arguments
        :type  args: ``object``
        '''
        super(RetoxFrame, self).__init__(
            screen,
github tonybaloney / retox / retox / ui.py View on Github external
self.refresh()

    @property
    def last_result(self):
        return self._last_result

    @last_result.setter
    def last_result(self, value):
        self._last_result = value
        self._last_result_label.text = u'{0} : {1}'.format(
            'Result',
            RESULT_MESSAGES.get(value, str(value)))
        self.refresh()


class LogFrame(widgets.Frame, RetoxRefreshMixin):
    '''
    A UI frame for hosting the logs of a virtualenv
    '''

    def __init__(self, screen, venv_name, venv_count, index):
        '''
        Create a new frame

        :param screen: The screen instance
        :type  screen: :class:`asciimatics.screen.Screen`

        :param venv_name: The name of this environment, e.g. py27
        :type  venv_name: ``str``

        :param venv_count: How many environments are there?
        :type  venv_count: ``int``
github cowboy8625 / WordRPG / gui / _backup / asciimatics / _template.py View on Github external
import sys

from asciimatics.scene import Scene
from asciimatics.screen import Screen
from asciimatics.exceptions import ResizeScreenError
from asciimatics.widgets import Frame, Layout, Background, VerticalDivider
from asciimatics.widgets import Label, TextBox, Button



class HeadFrame( Frame ):
	def __init__( self, screen ):
		super ( HeadFrame, self ).__init__( screen,
														int( screen.height * 0.1 ),
														int( screen.width ),
														has_border = False,
														can_scroll = False,
														has_shadow = False,
														name = "Header Frame")

		# TODO: Look into setting up a custom palette
		self.set_theme( "bright" )

		layout = Layout( [ 1, 1, 1 ] )
		self.add_layout( layout )
		layout.add_widget( Label( "Header" ), 1 )
github peterbrittain / asciimatics / asciimatics / widgets.py View on Github external
def clone(self, _, scene):
        """
        Create a clone of this Frame into a new Screen.

        :param scene: The new Scene object to clone into.
        """
        # Assume that the application creates a new set of Frames and so we need to match up the
        # data from the old object to the new (using the name).
        if self._name is not None:
            for effect in scene.effects:
                if isinstance(effect, Frame):
                    if effect._name == self._name:
                        effect.data = self.data
                        for layout in self._layouts:
                            layout.update_widgets(new_frame=effect)
github scottkosty / vit / application-asciimatics.py View on Github external
columns = [
          str(task['id']),
          wrap_line(task['description'], desc_width - 6),
          task_date(task, 'scheduled'),
        ]
        return (columns, task['id'])

    def get_summary(self, report=None):
        report = report or self.report
        self.update_report(report)
        summary = []
        for task in self.tasks:
            summary.append(self.build_task_row(task))
        return summary

class ListView(Frame):
    def __init__(self, screen, model):
        super(ListView, self).__init__(screen,
                                       screen.height,
                                       screen.width,
                                       on_load=self._reload_list,
                                       hover_focus=True,
                                       has_border=False,
                                       )
        self._model = model

        # Create the form for displaying the list of tasks.
        width = get_app_width()
        desc_width = get_app_width() - 6
        self._list_view = MultiColumnListBox(
            Widget.FILL_FRAME,
            [6, desc_width - 2, 11],
github cowboy8625 / WordRPG / gui / _backup / asciimatics / player.py View on Github external
import datetime



# TODO: Should pass the 'player' class object in directly
# Initial data for the form
form_character = {
	"name"   	: "STEVE",
	'age'		: "25",
	"gender"	: 2,
	"class" 	: 1
}



class MainWindow( Frame ):
	def __init__( self, screen ):
		super( MainWindow, self ).__init__( screen,
										int( screen.height	),
										int( screen.width ),
										data		= form_character,
										has_border	= True,
										has_shadow	= False,
										name		= "Create Character"
										)
		self._init_gui( )
		self._init_bot_menu( )

		self.fix( )


	def _init_gui( self ):
github kayagoban / shadowlands / shadowlands / tui / effects / widgets.py View on Github external
layout2.add_widget(Button("Select", self._ok), 0)
        self.fix()

    def _ok(self):
        options = self.find_widget('valuepicker')
        self._interface._config.displayed_currency = options._value
        self._destroy_window_stack()
        raise NextScene(self._scene.name)

    def _cancel(self):
        self._destroy_window_stack()
        raise NextScene(self._scene.name)



class YesNoDialog(Frame):
    def __init__(self, screen, height, width, yes_callback=None, no_callback=None, yes_text="Yes", no_text="No",  **kwargs):
        super(YesNoDialog, self).__init__(screen, 3, width, **kwargs)
        self.set_theme('shadowlands')

        layout2 = Layout([1, 1], fill_frame=True)
        self.add_layout(layout2)

        layout2.add_widget(Button("Yes", yes_callback), 1)
        layout2.add_widget(Button("No", no_callback), 0)
        self.fix()


class QuitDialog(YesNoDialog):
    def __init__(self, screen):
        super(QuitDialog, self).__init__(screen, 3, 30, yes_callback=self._ok, no_callback=self._cancel,  has_shadow=True, is_modal=True, name="quitbox", title="Really quit?", can_scroll=False)