Exemplo n.º 1
0
    def __init__(self, screen):
        super(ShortcutsView, self).__init__(screen,
                                            screen.height * 6 // 10,
                                            screen.width * 6 // 10,
                                            hover_focus=True,
                                            can_scroll=False,
                                            title="Shortcuts",
                                            reduce_cpu=True)
        self.set_theme("tlj256")

        layout = Layout([100, 100], fill_frame=True)
        self.add_layout(layout)
        self._row0 = TextBox(20, as_string=True)
        self._row0.disabled = True
        self._row0.value = "F1 - See branch window\n" \
                           "Ctrl-A - See shortcuts window"
        layout.add_widget(self._row0, 0)
        self._row1 = TextBox(20, as_string=True)
        self._row1.disabled = True
        self._row1.value = "F2 - See commit list window\n" \
                           "F3 - See working copy and commit window"
        layout.add_widget(self._row1, 1)
        layout2 = Layout([1, 1])
        self.add_layout(layout2)
        layout2.add_widget(Button("Okay", self._ok), 1)
        self.fix()
Exemplo n.º 2
0
 def initialize(self):
     layout = Layout([100])
     self.add_layout(layout)
     text_widget = TextBox(20)
     layout.add_widget(text_widget, 0)
     text_widget._value = self.dapp.tb_str.split('\n')
     layout.add_widget(Button("Ok", self.close))
Exemplo n.º 3
0
    def test_cjk_forms(self):
        """
        Check form widgets work with CJK characters.
        """
        # Create a dummy screen.
        screen = MagicMock(spec=Screen, colours=8, unicode_aware=False)
        scene = MagicMock(spec=Scene)
        canvas = Canvas(screen, 10, 40, 0, 0)

        # Create the form we want to test.
        form = Frame(canvas, canvas.height, canvas.width, has_border=False)
        layout = Layout([100], fill_frame=True)
        mc_list = MultiColumnListBox(4, [3, 5, 0], [
            (["1", "2", "3"], 1),
            ([u"你", u"確", u"定"], 2),
        ],
                                     titles=[u"你確定嗎?", u"你確定嗎?", u"你確定嗎?"])
        text = Text()
        text_box = TextBox(3)
        form.add_layout(layout)
        layout.add_widget(mc_list)
        layout.add_widget(text)
        layout.add_widget(text_box)
        form.fix()
        form.register_scene(scene)
        form.reset()

        # Set some interesting values...
        text.value = u"你確定嗎? 你確定嗎? 你確定嗎?"
        text_box.value = [u"你確定嗎", u"?"]

        # Check that the CJK characters render correctly - no really this is correctly aligned!
        self.maxDiff = None
        form.update(0)
        self.assert_canvas_equals(
            canvas, u"你你 你你確確 你你確確定定嗎嗎??                      \n" +
            u"1  2    3                               \n" +
            u"你你 確確   定定                              \n" +
            u"                                        \n" +
            u"你你確確定定嗎嗎?? 你你確確定定嗎嗎?? 你你確確定定嗎嗎??        \n" +
            u"你你確確定定嗎嗎                                \n" +
            u"??                                      \n" +
            u"                                        \n" +
            u"                                        \n" +
            u"                                        \n")

        # Check that mouse input takes into account the glyph width
        self.process_mouse(form, [(5, 4, MouseEvent.LEFT_CLICK)])
        self.process_keys(form, ["b"])
        self.process_mouse(form, [(2, 4, MouseEvent.LEFT_CLICK)])
        self.process_keys(form, ["p"])
        form.save()
        self.assertEqual(text.value, u"你p確b定嗎? 你確定嗎? 你確定嗎?")

        self.process_mouse(form, [(2, 5, MouseEvent.LEFT_CLICK)])
        self.process_keys(form, ["p"])
        self.process_mouse(form, [(1, 6, MouseEvent.LEFT_CLICK)])
        self.process_keys(form, ["b"])
        form.save()
        self.assertEqual(text_box.value, [u"你p確定嗎", u"b?"])
Exemplo n.º 4
0
 def add_shortcut_panel(self):
     layout0 = Layout([100])
     _header = TextBox(1, as_string=True)
     _header.disabled = True
     _header.custom_colour = "label"
     _header.value = "Press ctrl-a to see a list of shortcuts. Press ctrl-x to quit."
     self.add_layout(layout0)
     layout0.add_widget(_header, 0)
Exemplo n.º 5
0
    def __init__(self, screen, plotboss, name="My Form"):
        super(PlotJobFrame, self).__init__(screen,
                                           screen.height,
                                           screen.width,
                                           has_border=False,
                                           name=name)
        # Internal state required for doing periodic updates
        self._last_frame = 0
        self._reverse = True
        self.plotboss = plotboss

        # Create the basic form layout...
        layout = Layout([1], fill_frame=False)
        self._header = TextBox(4, as_string=True)
        self._header.disabled = True
        self._header.custom_colour = "label"
        self._list = MultiColumnListBox(
            11,  #Widget.FILL_FRAME,
            ["<6", ">12", ">12", "<40", ">8", ">8", ">10", "<32", "100%"],
            [],
            titles=[
                "INDEX", "JOB_ID", "PLOT_ID", "TMP_DIR", "PID", "PHASE",
                "ELAPSED", "PROGRESS", "FINAL_DIR"
            ],
            name="mc_list",
            parser=AsciimaticsParser())
        self._drive_list = MultiColumnListBox(
            Widget.FILL_FRAME, ["<40", ">12", ">10", ">10", "<32", "<10"], [],
            titles=["DRIVE", "TEMP/FINAL", "TOTAL", "FREE", "USAGE", "JOBS"],
            name="drive_list",
            parser=AsciimaticsParser())
        self._completed_info = TextBox(4, as_string=True)
        self._completed_info.disabled = True
        self._sys_info = TextBox(4, as_string=True)
        self._sys_info.disabled = True
        self.add_layout(layout)
        layout2 = Layout([1], fill_frame=True)
        self.add_layout(layout2)
        layout.add_widget(self._header)
        layout.add_widget(self._list)
        layout2.add_widget(self._drive_list)
        layout2.add_widget(self._completed_info)
        layout2.add_widget(self._sys_info)
        layout2.add_widget(Label("Press `r` to toggle order, or `q` to quit."))
        self.fix()

        # Add my own colour palette
        self.palette = defaultdict(lambda: (Screen.COLOUR_WHITE, Screen.
                                            A_NORMAL, Screen.COLOUR_BLACK))
        for key in ["selected_focus_field", "label"]:
            self.palette[key] = (Screen.COLOUR_WHITE, Screen.A_BOLD,
                                 Screen.COLOUR_BLACK)
        self.palette["title"] = (Screen.COLOUR_BLACK, Screen.A_NORMAL,
                                 Screen.COLOUR_WHITE)
Exemplo n.º 6
0
    def test_disabled_text(self):
        """
        Check disabled TextBox can be used for pre-formatted output.
        """
        # Create a dummy screen.
        screen = MagicMock(spec=Screen, colours=8, unicode_aware=False)
        scene = MagicMock(spec=Scene)
        canvas = Canvas(screen, 10, 40, 0, 0)

        # Create the form we want to test.
        form = Frame(canvas, canvas.height, canvas.width, has_border=False)
        layout = Layout([100], fill_frame=True)
        form.add_layout(layout)
        text_box = TextBox(1, as_string=True)
        text_box.disabled = True
        layout.add_widget(text_box)
        form.fix()
        form.register_scene(scene)
        form.reset()

        # Check that input has no effect on the programmed value.
        text_box.value = "A test"
        self.process_keys(form, ["A"])
        form.save()
        self.assertEqual(text_box.value, "A test")

        # Check that we can provide a custom colour.  Since the default palette has no "custom"
        # key, this will throw an exception.
        self.assertEqual(text_box._pick_colours("blah"),
                         form.palette["disabled"])
        with self.assertRaises(KeyError) as cm:
            text_box.custom_colour = "custom"
            text_box._pick_colours("blah")
        self.assertIn("custom", str(cm.exception))
Exemplo n.º 7
0
    def __init__(self, screen, model):
        super(ContactView, self).__init__(screen,
                                          screen.height * 2 // 3,
                                          screen.width * 2 // 3,
                                          hover_focus=False,
                                          title="Item details",
                                          reduce_cpu=True)
        # Save off the model that accesses the contacts database.
        self._model = model

        # Create the form for displaying the list of contacts.
        layout = Layout([100], fill_frame=True)
        self.add_layout(layout)
        layout.add_widget(Text("Name:", "name"))
        layout.add_widget(Text("Weight:", "weight"))
        layout.add_widget(Text("Modifiers:", "modifiers"))
        layout.add_widget(Text("Range:", "range"))
        layout.add_widget(Text("Damage:", "damage"))
        layout.add_widget(Text("Damage Type:", "damageType"))
        layout.add_widget(Text("Price:", "price"))
        layout.add_widget(Text("Rarity:", "rarity"))
        layout.add_widget(Text("Properties:", "properties"))
        layout.add_widget(
            TextBox(Widget.FILL_FRAME,
                    "Description:",
                    "description",
                    as_string=True))
        layout2 = Layout([1, 1, 1, 1])
        self.add_layout(layout2)
        layout2.add_widget(Button("OK", self._ok), 0)
        layout2.add_widget(Button("Cancel", self._cancel), 3)
        self.fix()
Exemplo n.º 8
0
 def __init__(self, screen):
     super(ContactView, self).__init__(screen,
                                       screen.height * 2 // 3,
                                       screen.width * 2 // 3,
                                       hover_focus=True,
                                       title="Compose",
                                       reduce_cpu=True)
     layout = Layout([100], fill_frame=True)
     self.add_layout(layout)
     self._pow_txt = Text("Proof:", "pow")
     self._pow_txt.value = ''
     layout.add_widget(Text("To:", "recip", on_blur=self._api))
     layout.add_widget(Text("Subject:", "subject"))
     layout.add_widget(self._pow_txt)
     layout.add_widget(
         TextBox(Widget.FILL_FRAME,
                 "Body:",
                 "body",
                 as_string=True,
                 line_wrap=True))
     layout2 = Layout([1, 1, 1, 1])
     self.add_layout(layout2)
     layout2.add_widget(Button("Send", self._send), 0)
     layout2.add_widget(Button("Cancel", self._cancel), 3)
     self.fix()
Exemplo n.º 9
0
 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(
         Text(label="Alpha:",
              name="TB",
              on_change=self._on_change,
              validator="^[a-zA-Z]*$"), 1)
     layout.add_widget(
         Text(label="Number:",
              name="TC",
              on_change=self._on_change,
              validator="^[0-9]*$"), 1)
     layout.add_widget(
         Text(label="Email:",
              name="TD",
              on_change=self._on_change,
              validator=self._check_email), 1)
     layout.add_widget(Divider(height=2), 1)
     layout.add_widget(Label("Group 2:"), 1)
     layout.add_widget(RadioButtons([("Option 1", 1),
                                     ("Option 2", 2),
                                     ("Option 3", 3)],
                                    label="A Longer Selection:",
                                    name="Things",
                                    on_change=self._on_change), 1)
     layout.add_widget(CheckBox("Field 1",
                                label="A very silly long name for fields:",
                                name="CA",
                                on_change=self._on_change), 1)
     layout.add_widget(
         CheckBox("Field 2", name="CB", on_change=self._on_change), 1)
     layout.add_widget(
         CheckBox("Field 3", name="CC", on_change=self._on_change), 1)
     layout.add_widget(DatePicker("Date",
                                  name="DATE",
                                  year_range=range(1999, 2100),
                                  on_change=self._on_change), 1)
     layout.add_widget(
         TimePicker("Time", name="TIME", on_change=self._on_change, seconds=True), 1)
     layout.add_widget(Text("Password", name="PWD", on_change=self._on_change, hide_char="*"), 1)
     layout.add_widget(Divider(height=3), 1)
     layout2 = Layout([1, 1, 1])
     self.add_layout(layout2)
     layout2.add_widget(self._reset_button, 0)
     layout2.add_widget(Button("View Data", self._view), 1)
     layout2.add_widget(Button("Quit", self._quit), 2)
     self.fix()
Exemplo n.º 10
0
    def __init__(self, screen, model):
        super(ContactView, self).__init__(screen,
                                          screen.height * 2 // 3,
                                          screen.width * 2 // 3,
                                          hover_focus=True,
                                          title="Contact Details",
                                          reduce_cpu=True)
        # Save off the model that accesses the contacts database.
        self._model = model

        # Create the form for displaying the list of contacts.
        layout = Layout([100], fill_frame=True)
        self.add_layout(layout)
        layout.add_widget(Text("Name:", "name"))
        layout.add_widget(Text("Address:", "address"))
        layout.add_widget(Text("Phone number:", "phone"))
        layout.add_widget(Text("Email address:", "email"))
        layout.add_widget(
            TextBox(Widget.FILL_FRAME,
                    "Notes:",
                    "notes",
                    as_string=True,
                    line_wrap=True))
        layout2 = Layout([1, 1, 1, 1])
        self.add_layout(layout2)
        layout2.add_widget(Button("OK", self._ok), 0)
        layout2.add_widget(Button("Cancel", self._cancel), 3)
        self.fix()
Exemplo n.º 11
0
    def __init__(self, screen, model):
        super(PartView, self).__init__(screen,
                                       screen.height * 4 // 5,
                                       screen.width * 4 // 5,
                                       hover_focus=True,
                                       can_scroll=False,
                                       title="Part Details",
                                       reduce_cpu=True)
        self.set_theme("cs")
        # Save off the model that accesses the parts database.
        self._model = model

        # Create the form for displaying the list of parts.
        layout = Layout([100], fill_frame=True)
        self.add_layout(layout)
        layout.add_widget(Text("Nom :", "name"))
        layout.add_widget(Text("Categorie :", "mcat"))
        layout.add_widget(Text("Sous-catégorie 1 :", "scat1"))
        layout.add_widget(Text("Sous-catégorie 2 :", "scat2"))
        layout.add_widget(Text("Emplacement :", "pos"))
        layout.add_widget(Text("Quantité :", "amnt"))
        layout.add_widget(
            TextBox(Widget.FILL_FRAME,
                    "Description:",
                    "notes",
                    as_string=True,
                    line_wrap=True))
        layout2 = Layout([1, 1, 1, 1])
        self.add_layout(layout2)
        layout2.add_widget(Button("OK", self._ok), 0)
        layout2.add_widget(Button("Cancel", self._cancel), 3)
        self.fix()
Exemplo n.º 12
0
    def __init__(self, screen, model, ui: UIController):
        super().__init__(screen,
                         height=screen.height // 5,
                         width=screen.width // 2,
                         can_scroll=False,
                         title="Delete Host",
                         hover_focus=True)

        self.model: ModelInterface = model
        self._ui: UIController = ui
        self._theme = None
        self.set_theme(ui.theme)

        # Initialize Widgets
        self._confirm_button = Button("Confirm", self._confirm)
        self._cancel_button = Button("Cancel", self._cancel)
        self._ip_input = Text("IP Address", name="ip")
        self._or = Text("OR", disabled=True)
        self._hostname_input = Text("Hostname", name="hostname")

        # Create and Generate Layouts
        layout = Layout([1], fill_frame=True)
        self.add_layout(layout)
        layout.add_widget(self._hostname_input)
        layout.add_widget(self._or)
        layout.add_widget(self._ip_input)
        layout.add_widget(TextBox(Widget.FILL_FRAME, disabled=True))
        layout.add_widget(Divider())
        button_layout = Layout([1, 1])
        self.add_layout(button_layout)
        button_layout.add_widget(self._confirm_button, 0)
        button_layout.add_widget(self._cancel_button, 1)

        # Save Layouts
        self.fix()
Exemplo n.º 13
0
    def __init__(self, screen):
        super(DemoFrame, self).__init__(screen, screen.height, screen.width)

        # Create the widgets for the demo.
        layout = Layout([1, 18, 1], fill_frame=True)
        self.add_layout(layout)
        self._term_out = TextBox(Widget.FILL_FRAME, line_wrap=True, parser=AnsiTerminalParser())
        layout.add_widget(self._term_out, 1)
        layout.add_widget(Divider(height=2), 1)
        layout2 = Layout([1, 15, 3, 1])
        self.add_layout(layout2)
        self._term_in = Text()
        layout2.add_widget(self._term_in, 1)
        layout2.add_widget(Button("Run", self._run), 2)
        self.fix()
        self.set_theme("monochrome")

        # Open a pseudo TTY to control the interactive session.  Make it non-blocking.
        self._master, slave = pty.openpty()
        fl = fcntl.fcntl(self._master, fcntl.F_GETFL)
        fcntl.fcntl(self._master, fcntl.F_SETFL, fl | os.O_NONBLOCK)

        # Start the shell and thread to pull data from it.
        self._shell = subprocess.Popen(["bash", "-i"], preexec_fn=os.setsid, stdin=slave, stdout=slave, stderr=slave)
        self._lock = threading.Lock()
        self._thread = threading.Thread(target=self._background)
        self._thread.daemon = True
        self._thread.start()
Exemplo n.º 14
0
    def __init__(self, screen, model):
        super(ContactView, self).__init__(screen,
                                          screen.height * 75 // 100,
                                          screen.width * 75 // 100,
                                          hover_focus=True,
                                          title="Login Details",
                                          reduce_cpu=True,
                                          y=1)
        # Save off the model that accesses the contacts database.
        self._model = model

        # Create the form for displaying the list of contacts.
        layout = Layout([100], fill_frame=True)
        self.add_layout(layout)

        layout.add_widget(Text("Login:"******"login"))
        layout.add_widget(Text("Group:", "lgroup"))
        layout.add_widget(Text("Username:"******"username"))
        layout.add_widget(Text("Loginlink:", "link"))
        layout.add_widget(Text("Email address:", "email"))
        layout.add_widget(Text("Length:", "length"))
        layout.add_widget(Divider())
        layout.add_widget(
            TextBox(Widget.FILL_FRAME, "Notes:", "notes", as_string=True))
        layout2 = Layout([1, 1, 1, 1])
        self.add_layout(layout2)
        layout2.add_widget(Button("OK", self._ok), 0)
        layout2.add_widget(Button("Cancel", self._cancel), 3)
        self.fix()
Exemplo n.º 15
0
Arquivo: views.py Projeto: Eeems/ample
 def __init__(self, screen, model):
     super(EmailView, self).__init__(screen,
                                     screen.height,
                                     screen.width,
                                     has_shadow=True,
                                     name='Main View')
     self.data = {
         'subject': '',
         'from': '',
         'to': '',
         'body': '',
         'date': ''
     }
     self.model = model
     self.uid = None
     layout = Layout([10, 80, 80])
     self.add_layout(layout)
     layout.add_widget(Button('Back', self.back_click), column=0)
     layout.add_widget(Button('Reply', self.reply_click), column=2)
     layout = Layout([100])
     self.add_layout(layout)
     layout.add_widget(self._text('Subject', 'subject'))
     layout.add_widget(self._text('To', 'to'))
     layout.add_widget(self._text('From', 'from'))
     layout.add_widget(self._text('Date', 'date'))
     textbox = TextBox(screen.height - 4,
                       label='Body',
                       name='body',
                       as_string=True)
     layout.add_widget(textbox)
     self.fix()
Exemplo n.º 16
0
    def __init__(self, screen):
        super(DemoFrame, self).__init__(screen,
                                        screen.height,
                                        screen.width,
                                        has_border=False,
                                        name="My Form")
        # Internal state required for doing periodic updates
        self._last_frame = 0
        self._sort = 5
        self._reverse = True

        # Create the basic form layout...
        layout = Layout([1], fill_frame=True)
        self._header = TextBox(1, as_string=True)
        self._header.disabled = True
        self._header.custom_colour = "label"
        self._list = MultiColumnListBox(
            Widget.FILL_FRAME,
            [">6", 10, ">4", ">7", ">7", ">5", ">5", "100%"],
            [],
            titles=["PID", "USER", "NI", "VIRT", "RSS", "CPU%", "MEM%", "CMD"],
            name="mc_list")
        self.add_layout(layout)
        layout.add_widget(self._header)
        layout.add_widget(self._list)
        layout.add_widget(
            Label("Press `<`/`>` to change sort, `r` to toggle order, or `q` to quit."))
        self.fix()

        # Add my own colour palette
        self.palette = defaultdict(
            lambda: (Screen.COLOUR_WHITE, Screen.A_NORMAL, Screen.COLOUR_BLACK))
        for key in ["selected_focus_field", "label"]:
            self.palette[key] = (Screen.COLOUR_WHITE, Screen.A_BOLD, Screen.COLOUR_BLACK)
        self.palette["title"] = (Screen.COLOUR_BLACK, Screen.A_NORMAL, Screen.COLOUR_WHITE)
Exemplo n.º 17
0
    def __init__(self, screen, footer=dict(), scene_keybinds=None):
        super(GraphFrame, self).__init__(screen,
                                         screen.height,
                                         screen.width,
                                         has_border=False,
                                         name="My Form")

        layout = Layout([1], fill_frame=True)
        self.add_layout(layout)
        self.__scene_keybinds = scene_keybinds
        self._graph = TextBox(25, name='graph', as_string=True)
        self._graph.disabled = True

        self._graph.custom_colour = 'label'

        self._list = DropdownList(dropdown_options,
                                  label='Pick a graph',
                                  name='dropdown')
        self._graph.value = str(graph_list[self._list.value])

        self._list._on_change = self.on_change

        footers = ['[{}] {}'.format(key, text) for key, text in footer.items()]
        default_footer_text = '[q] Quit'
        self.__footer = Label(' '.join(footers) + ' ' + default_footer_text)

        layout.add_widget(self._list)
        layout.add_widget(self._graph)
        layout.add_widget(self.__footer)

        self.set_theme('monochrome')

        self.fix()
Exemplo n.º 18
0
def inject_voting_state(layout, col=0):
    layout.add_widget(Label('Voting'), col)
    layout.add_widget(Divider(line_char='-'), col)
    layout.add_widget(Text('Address:', 'voting_address'), col)
    layout.add_widget(Text('Owner:', 'voting_owner'), col)
    # TODO in the actual upcoming live implementation figure out how to dynamically set the height
    layout.add_widget(TextBox(3, label='Candidates:', name='voting_candidates'), col)
Exemplo n.º 19
0
    def __init__(self, screen, footer=dict(), scene_keybinds=None):
        super(PriceFrame, self).__init__(screen,
                                         screen.height,
                                         screen.width,
                                         has_border=True,
                                         name="My Form")

        layout = Layout([1], fill_frame=True)
        self.__scene_keybinds = scene_keybinds
        self.add_layout(layout)
        self._price = TextBox(25, name='pricelist', as_string=True)
        self._price.value = price_string
        self._price.disabled = True
        footers = ['[{}] {}'.format(key, text) for key, text in footer.items()]
        default_footer_text = '[q] Quit'
        self.__footer = Label(' '.join(footers) + ' ' + default_footer_text)

        layout.add_widget(
            Label('{:<20}\t{:>15} {:>15} {:>15} {:>15}'.format(
                '', '1 day', '1 week', '1 month', '6 months')))
        layout.add_widget(self._price)
        layout.add_widget(self.__footer)

        self.set_theme('monochrome')

        self.fix()
Exemplo n.º 20
0
 def _compose_main_layout(self):
     layout = Layout([1])
     self.add_layout(layout)
     layout.add_widget(
         TextBox(height=self._canvas.height - 4,
                 disabled=True,
                 name="value",
                 as_string=True))
Exemplo n.º 21
0
    def __init__(self, screen, path):
        super(VenvView, self).__init__(screen,
                                       screen.height,
                                       screen.width,
                                       hover_focus=False,
                                       can_scroll=True,
                                       reduce_cpu=True,
                                       has_border=True)
        self.selected_size = 0
        self.size_found = 0
        self.path = path
        self.venvs = self.__find_venvs(self.path)

        self.set_visual_theme()
        # Top bar, logo & summary
        self.layout_top = Layout([1, 1])
        self.add_layout(self.layout_top)
        logo = TextBox(height=self.ASCII_TITLE_HEIGHT,
                       as_string=True,
                       disabled=True)
        logo.value = self.ASCII_TITLE
        self.layout_top.add_widget(logo, 1)

        self.layout_top.add_widget(Label(''), 0)
        self.layout_top.add_widget(Label('SUMMARY'), 0)
        self.label_size_found = Text('Total: ', disabled=True)
        self.label_size_selected = Text('To Free: ', disabled=True)
        self.layout_top.add_widget(self.label_size_found, 0)
        self.layout_top.add_widget(self.label_size_selected, 0)
        self.__update_sizes()

        # Main list of environments
        self.layout_main = Layout([80, 20], fill_frame=True)
        self.add_layout(self.layout_main)
        self.__draw_list()

        # Bottom buttons
        self.layout_bottom = Layout([1, 1])
        self.add_layout(self.layout_bottom)

        self.layout_bottom.add_widget(Divider(), 0)
        self.layout_bottom.add_widget(Divider(), 1)
        self.layout_bottom.add_widget(Button('Delete', self._delete), 0)
        self.layout_bottom.add_widget(Button('Quit', self._quit), 1)

        self.fix()
Exemplo n.º 22
0
 def _create_help_layout(self):
     help_layout = Layout([1], fill_frame=True)
     self.add_layout(help_layout)
     help_layout.add_widget(Divider())
     # ...the help widget itself
     self._help = TextBox(height=3, label="Help: ", as_string=True)
     self._help.value = "TEST"
     self._help.disabled = True
     help_layout.add_widget(self._help)
     help_layout.add_widget(Divider())
Exemplo n.º 23
0
    def __init__(self, screen, model):
        super(GameFrame, self).__init__(screen,
                                        screen.height,
                                        screen.width,
                                        has_border=False)

        self._model = model
        self._statement = self._model.get_statement(1)
        self._picture = self._model.get_scene("start")

        self.palette = defaultdict(lambda: (Screen.COLOUR_WHITE, Screen.
                                            A_NORMAL, Screen.COLOUR_BLACK))
        for key in ["selected_focus_field", "label"]:
            self.palette[key] = (Screen.COLOUR_BLACK, Screen.A_BOLD,
                                 Screen.COLOUR_WHITE)
        self.palette["title"] = (Screen.COLOUR_BLACK, Screen.A_NORMAL,
                                 Screen.COLOUR_WHITE)

        layout = Layout([100], fill_frame=True)
        self.add_layout(layout)

        self._answer_options = ListBox(Widget.FILL_FRAME,
                                       self._get_answers(),
                                       name="answer_options",
                                       on_select=self._on_select)

        self._picture_display = TextBox(16, as_string=True)
        self._picture_display.disabled = True

        self._remark = TextBox(2, as_string=True)
        self._remark.disabled = True

        self._statement_text = Text()
        self._statement_text.disabled = True

        layout.add_widget(self._picture_display)
        # layout.add_widget(Divider())
        layout.add_widget(self._remark)
        layout.add_widget(self._statement_text)
        layout.add_widget(self._answer_options)
        layout.add_widget(Label("Press `q` to quit."))

        self.fix()
Exemplo n.º 24
0
 def __init__(self, screen):
     super(DemoFrame, self).__init__(screen,
                                     screen.height,
                                     screen.width // 5,
                                     data=form_data,
                                     x=0,
                                     y=0,
                                     name="Side bar")
     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(
         Text(label="Alpha:",
              name="TB",
              on_change=self._on_change,
              validator="^[a-zA-Z]*$"), 1)
     layout.add_widget(
         Text(label="Number:",
              name="TC",
              on_change=self._on_change,
              validator="^[0-9]*$"), 1)
     layout.add_widget(
         Text(label="Email:",
              name="TD",
              on_change=self._on_change,
              validator=self._check_email), 1)
     layout.add_widget(Divider(height=2), 1)
     layout.add_widget(Label("Group 2:"), 1)
     layout.add_widget(
         RadioButtons([("Option 1", 1), ("Option 2", 2), ("Option 3", 3)],
                      label="A Longer Selection:",
                      name="Things",
                      on_change=self._on_change), 1)
     layout.add_widget(
         CheckBox("Field 1",
                  label="A very silly long name for fields:",
                  name="CA",
                  on_change=self._on_change), 1)
     layout.add_widget(
         CheckBox("Field 2", name="CB", on_change=self._on_change), 1)
     layout.add_widget(
         CheckBox("Field 3", name="CC", on_change=self._on_change), 1)
     layout.add_widget(Divider(height=3), 1)
     layout2 = Layout([1, 1, 1])
     self.add_layout(layout2)
     layout2.add_widget(self._reset_button, 0)
     layout2.add_widget(Button("View Data", self._view), 1)
     layout2.add_widget(Button("Quit", self._quit), 2)
     self.fix()
Exemplo n.º 25
0
 def _compose_layout(self):
     main_layout = Layout([1, 1], fill_frame=True)
     self.add_layout(main_layout)
     main_layout.add_widget(
         TextBox(
             label="Public key",
             name="public_key",
             disabled=True,
             height=self._public_key_height,
             line_wrap=True,
             as_string=True,
         ))
     main_layout.add_widget(
         TextBox(
             label="Signature",
             name="signature",
             disabled=True,
             height=self._signature_height,
             line_wrap=True,
             as_string=True,
         ))
Exemplo n.º 26
0
 def __init__(self, screen, has_border=True, reduce_cpu=False):
     super(TestFrame, self).__init__(screen,
                                     screen.height,
                                     screen.width,
                                     name="Test Form",
                                     has_border=has_border,
                                     hover_focus=True,
                                     reduce_cpu=reduce_cpu)
     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(
         Text(label="Text1:", name="TB", on_change=self._on_change), 1)
     layout.add_widget(
         Text(label="Text2:",
              name="TC",
              on_change=self._on_change,
              validator="^[0-9]*$"), 1)
     layout.add_widget(
         Text(label="Text3:",
              name="TD",
              on_change=self._on_change,
              validator=lambda x: x in ("", "a")), 1)
     layout.add_widget(Divider(height=2), 1)
     layout.add_widget(Label("Group 2:"), 1)
     layout.add_widget(
         RadioButtons([("Option 1", 1), ("Option 2", 2), ("Option 3", 3)],
                      label="A Longer Selection:",
                      name="Things",
                      on_change=self._on_change), 1)
     layout.add_widget(
         CheckBox("Field 1",
                  label="A very silly long name for fields:",
                  name="CA",
                  on_change=self._on_change), 1)
     layout.add_widget(
         CheckBox("Field 2", name="CB", on_change=self._on_change), 1)
     layout.add_widget(
         CheckBox("Field 3", name="CC", on_change=self._on_change), 1)
     layout.add_widget(Divider(height=3), 1)
     layout2 = Layout([1, 1, 1])
     self.add_layout(layout2)
     layout2.add_widget(self._reset_button, 0)
     layout2.add_widget(Button("View Data", self._view), 1)
     layout2.add_widget(Button("Quit", self._quit), 2)
     self.fix()
Exemplo n.º 27
0
Arquivo: test.py Projeto: sdfs1231/ICS
 def __init__(self, screen, x, y):
     super(Warning_Frame, self).__init__(screen,
                                         width=screen.width,
                                         height=screen.height // 2,
                                         name='logtextbox',
                                         x=x,
                                         y=y)
     self.set_theme("bright")
     layout = Layout([1, 18])
     self.add_layout(layout)
     layout.add_widget(TextBox(height=1, ), 1)
     layout.add_widget(
         Text(label="Warning:", name="TC", validator="^[0-9]*$"), 1)
     self.fix()
Exemplo n.º 28
0
    def __init__(self, screen, model, ui: UIController):
        super().__init__(screen,
                         height=screen.height // 2,
                         width=screen.width // 2,
                         can_scroll=False,
                         title="Add Command",
                         hover_focus=True)

        self._model: ModelInterface = model
        self._ui: UIController = ui
        self._theme = None
        self.set_theme(ui.theme)

        # Initialize Widgets
        self._confirm_button = Button("Confirm", self._confirm)
        self._cancel_button = Button("Cancel", self._cancel)
        self._ip_input = Text("IPs and/or subnet(s): ",
                              name="ips",
                              disabled=True)
        self._ip_input.value = self._model.current_machine
        self._command_type = RadioButtons([("Powershell", "ps"),
                                           ("DOS", "cmd"), ("Bash", "bash")],
                                          name="cmdtype",
                                          label="Command Type: ")
        # self._or = Text("OR", disabled=True)
        # self._hostname_input = Text("Hostname(s):", name="hostnames")
        self._command_input = TextBox(Widget.FILL_FRAME,
                                      label="Command(s): \n(one per line)",
                                      name="commands",
                                      line_wrap=True)

        # Create and Generate Layouts
        layout = Layout([1], fill_frame=True)
        self.add_layout(layout)
        layout.add_widget(self._ip_input)
        layout.add_widget(self._command_type)
        # layout.add_widget(self._or)
        # layout.add_widget(self._hostname_input)
        layout.add_widget(Divider())
        layout.add_widget(self._command_input)
        layout.add_widget(Divider())

        button_layout = Layout([1, 1])
        self.add_layout(button_layout)
        button_layout.add_widget(self._confirm_button, 0)
        button_layout.add_widget(self._cancel_button, 1)

        # Save Layouts
        self.fix()
Exemplo n.º 29
0
    def draw(self) -> None:
        layout = Layout([100])
        self.add_layout(layout)

        self.recap_text_box = TextBox(1, parser=AsciimaticsParser())
        self.recap_text_box.disabled = True
        layout.add_widget(self.recap_text_box)

        layout.add_widget(Divider())

        self.run_name_widget = Text(name=RUN_NAME_KEY, label=RecapForm.RUN_NAME)
        self.run_name_widget.value = ""
        layout.add_widget(self.run_name_widget)

        self.fix()
Exemplo n.º 30
0
 def __init__(self, screen):
     super(BottomFrame, self).__init__(screen,
                                       int(screen.height // 3),
                                       screen.width // 2,
                                       y=int(screen.height * 2 // 3),
                                       has_border=False,
                                       can_scroll=False,
                                       name="Bottom Form")
     layout = Layout([1, 18, 1])
     self.add_layout(layout)
     layout.add_widget(Label("No scrolling, no border"), 1)
     layout.add_widget(
         TextBox(Widget.FILL_FRAME, label="Box 3:", name="BOX3"), 1)
     layout.add_widget(Text(label="Text 3:", name="TEXT3"), 1)
     layout.add_widget(Button("Quit", self._quit, label="To exit:"), 1)
     self.fix()