예제 #1
0
    def _create_resources_layout(self):
        status_layout = Layout([1, 1], fill_frame=False)
        # ...the resources list
        self._resources_list = MultiColumnListBox(
            10,  # Height
            ["<12", ">10"],
            [],
        )
        self._resources_list.disabled = True

        # ...then the 2 special occupations
        self._special_occupation_list = MultiColumnListBox(
            2,  # Height
            ["<12", ">10"],
            [],
        )
        self._special_occupation_list.disabled = True

        # ...then the occupation list
        self._occupation_list = MultiColumnListBox(
            10,  # Height
            ["<12", ">10"],
            [],
        )
        self.add_layout(status_layout)
        status_layout.add_widget(Label("Resources"), column=0)
        status_layout.add_widget(self._resources_list, column=0)
        status_layout.add_widget(Label("Workers"), column=1)
        status_layout.add_widget(self._special_occupation_list, column=1)
        status_layout.add_widget(Divider(), column=1)
        status_layout.add_widget(self._occupation_list, column=1)
예제 #2
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)
예제 #3
0
    def __init__(self, screen, model):
        super(EntityListView, self).__init__(
            screen,
            screen.height,
            screen.width,
            on_load=self._reload_list,
            hover_focus=False,
            can_scroll=False,
            title="",
        )

        self.set_theme("custom")

        self._model = model

        self._entity_list_view = MultiColumnListBox(
            Widget.FILL_FRAME,
            ["<24", "<64"],
            model.get_children(),
            name="entities",
            on_change=self._on_pick,
            on_select=self._enter_child,
        )
        self._quantities_list_view = MultiColumnListBox(
            10,
            ["<24", "<64"],
            model.get_quantities(),
            name="quantities",
            on_change=self._on_pick,
            on_select=self._enter_quantity,
        )

        entity_list_layout = Layout([100], fill_frame=True)
        self.add_layout(entity_list_layout)
        entity_list_layout.add_widget(self._entity_list_view)
        entity_list_layout.add_widget(Divider())

        details_layout = Layout([100])
        self.add_layout(details_layout)
        details_layout.add_widget(self._quantities_list_view)
        details_layout.add_widget(Divider())

        button_row_layout = Layout([1, 1, 1, 1])
        self.add_layout(button_row_layout)
        button_row_layout.add_widget(Button("Quit", self._quit), 3)

        self._refresh_status()
        self.fix()
        self._on_pick()
예제 #4
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?"])
예제 #5
0
    def __init__(self, screen, model):
        '''
        Constructor
        '''
        super(StockView, self).__init__(screen,
                                          screen.height,
                                          screen.width,
                                          hover_focus=True,
                                          can_scroll=False,
                                          title="Vypis skladu",
                                          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)
        self._list_view = MultiColumnListBox(
            height=Widget.FILL_FRAME,
            options=model.stock.get_stock_summary(), 
            columns=("50%", "50%"),
            titles=("Nazev", "Sklad [ks]"),
            name="products",
            add_scroll_bar=True,
            on_change=None,
            on_select=self._on_select)
        layout.add_widget(self._list_view)
        layout.add_widget(Divider())
        layout2 = Layout([1])
        self.add_layout(layout2)
        layout2.add_widget(Button("Zpět", self._back))

        self.fix()
        self.reset()
예제 #6
0
    def __init__(self, screen, model):
        super(SellHistoryView, self).__init__(screen,
                                          screen.height,
                                          screen.width,
                                          on_load=self._reload_list,
                                          hover_focus=True,
                                          can_scroll=False,
                                          title="Historie prodejů",
                                          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)
        self._list_view = MultiColumnListBox(
            height=Widget.FILL_FRAME,
            options=model.stock.get_sell_history(), 
            columns=("50%", "50%"),
            titles=("Datum", "Ks."),
            name="Sales",
            add_scroll_bar=True,
            on_change=None,
            on_select=None)
        layout.add_widget(self._list_view)
        layout.add_widget(Divider())
        layout2 = Layout([1, 1])
        self.add_layout(layout2)
        layout2.add_widget(Button("Zpět", self._back))

        self.fix()
예제 #7
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)
예제 #8
0
파일: treeview.py 프로젝트: yws/asciimatics
    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._root = root_dir

        # Create the basic form layout...
        layout = Layout([1], fill_frame=True)
        # TODO: Create a new widget for the file viewer?
        self._list = MultiColumnListBox(
            Widget.FILL_FRAME,
            [0, ">8", ">14"],
            [],
            titles=["Filename", "Size", "Last modified"],
            name="mc_list",
            on_select=self.on_select)
        self.add_layout(layout)
        layout.add_widget(Label("Local disk browser"))
        layout.add_widget(self._list)
        layout.add_widget(Label("Press `q` to quit."))
        self.fix()
        self._populate_list()
예제 #9
0
 def __init__(self, screen, model):
     super(BoxListView, self).__init__(screen,
                                       screen.height * 4 // 5,
                                       screen.width * 4 // 5,
                                       on_load=self._reload_list,
                                       hover_focus=True,
                                       can_scroll=False,
                                       title=f"Boite {model.current_pos}")
     # Save off the model that accesses the parts database.
     self._model = model
     # Create the form for displaying the list of parts.
     self._list_view = MultiColumnListBox(
         Widget.FILL_FRAME,
         columns=['30%', '20%', '20%', '20%', '10%'],
         options=self._model.get_items_in_box(self._model.current_pos),
         titles=['Name', 'Cat', 'S-Cat', 'S-S-Cat', 'Qte'],
         add_scroll_bar=True,
         on_change=self._on_pick,
         on_select=self._edit,
         name="parts")
     self.set_theme("cs")
     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("Back", self._back), 3)
     self.fix()
     self._on_pick()
예제 #10
0
    def __init__(self, screen, model):
        super(CommitView, self).__init__(model,
                                         screen,
                                         screen.height * 9 // 10,
                                         screen.width * 9 // 10,
                                         on_load=self._reload_list,
                                         hover_focus=True,
                                         can_scroll=False,
                                         title="Commits")
        self._model = model

        self._list_view = MultiColumnListBox(
            Widget.FILL_FRAME, ["10%", "60%", "15%", "15%"],
            model.list_commits(),
            titles=["Hash", "Message", "Author", "Date"],
            name="commits",
            add_scroll_bar=True,
            on_select=self.__view_diff)

        self.add_navigation_header()
        self.add_divider()

        self.table_layout = Layout([100], fill_frame=True)
        self.add_layout(self.table_layout)
        self.table_layout.add_widget(self._list_view)
        self.table_layout.add_widget(Divider())

        self.add_shortcut_panel()
        self.fix()
예제 #11
0
    def __init__(self, screen, model):
        super(ProcessXMLFeedView, self).__init__(screen,
                                          screen.height,
                                          screen.width,
                                          on_load=self._reload_list,
                                          hover_focus=True,
                                          can_scroll=False,
                                          title="Aplikovat zmeny",
                                          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)
        self._list_view = MultiColumnListBox(
            height=Widget.FILL_FRAME,
            options=model.xmlFeed.get_actions(), 
            columns=("50%", "50%"),
            titles=("Produkt", "Akce"),
            name="actions",
            add_scroll_bar=True,
            on_change=None,
            on_select=self._on_select)
        layout.add_widget(self._list_view)
        layout.add_widget(Divider())
        layout2 = Layout([1, 1])
        self.add_layout(layout2)
        layout2.add_widget(Button("Aplikovat vse", self._apply_all), 0)
        layout2.add_widget(Button("Zpět", self._back), 1)


        self.fix()
예제 #12
0
    def __init__(self, screen, model):
        super(ProcessOrdersView, self).__init__(screen,
                                          screen.height,
                                          screen.width,
                                          on_load=self._reload_list,
                                          hover_focus=True,
                                          can_scroll=False,
                                          title="Zauctovat objednavky",
                                          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)
        self._list_view = MultiColumnListBox(
            height=Widget.FILL_FRAME,
            options=model.orders.get_orders(), 
            columns=("25%", "25%", "25%", "25%"),
            titles=("ID", "Datum", "Stav", "Celkova cena"),
            name="actions",
            add_scroll_bar=True,
            on_change=None,
            on_select=self._on_select)
        layout.add_widget(self._list_view)
        layout.add_widget(Divider())
        layout2 = Layout([1, 1])
        self.add_layout(layout2)
        layout2.add_widget(Button("Zauctovat vse", self._apply_all), 0)
        layout2.add_widget(Button("Zpět", self._back), 1)

        self.fix()
    def __init__(self, screen, model):
        super(ListView, self).__init__(screen,
                                       height=screen.height,
                                       width=screen.width,
                                       can_scroll=False,
                                       on_load=self._reload_list,
                                       title='Windows PATH variable transfer ')
        self._model = model

        self.current_id = 0

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

        self._list_view = MultiColumnListBox(
            Widget.FILL_FRAME,
            columns=['<3', '<5', '<10', '<20%', '<100%'],
            options=self._model.get_summary(),
            titles=['S', 'Wind', 'branch', 'value', 'data'],
            name="key values",
            add_scroll_bar=True,
            on_change=self._on_pick,
            on_select=self._select)
        layout.add_widget(self._list_view)

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

        layout2.add_widget(Button('Load config', self._load_configfile), 0)
        layout2.add_widget(Button('Select all', self._select_all), 1)
        layout2.add_widget(Button('Update registry', self._update_registry), 2)
        layout2.add_widget(Button('Unselect all', self._unselect_all), 3)
        layout2.add_widget(Button("Quit", self._quit), 4)

        self.fix()
예제 #14
0
파일: tui_msgs.py 프로젝트: dwhall/HeyMac
    def __init__(self, screen, msgs_model, ident_model, stngs_model,
                 status_model):
        super().__init__(screen,
                         screen.height,
                         screen.width,
                         title="HeyMac",
                         on_load=self._on_load,
                         can_scroll=False)
        self._msgs_model = msgs_model
        self._ident_model = ident_model
        self._stngs_model = stngs_model
        self._status_model = status_model

        # Received messages area
        layout1 = Layout([100], fill_frame=True)
        self.add_layout(layout1)
        self._msgs_box = MultiColumnListBox(Widget.FILL_FRAME, [9, 12, 0], [],
                                            name="msgs",
                                            titles=["Time", "From", "Message"])
        self._msgs_box.disabled = True
        self._msgs_box.custom_colour = "title"
        layout1.add_widget(self._msgs_box)
        self._msgs_model.set_update_clbk(self._updt_msgs)

        # Message-to-send input area
        layout2 = Layout([100])
        self.add_layout(layout2)
        self._msg_input = Text(label="Send:",
                               name="msg_input",
                               on_change=self._on_input_change,
                               max_length=200)
        layout2.add_widget(self._msg_input)

        # Activity bar
        layout3 = Layout([1, 1, 1, 1, 1, 1])
        self.add_layout(layout3)
        self._time = Label("00:00:00", name="time")
        self._ident = Button(self._ident_model.get_summary(),
                             self._on_click_ident,
                             name="ident")
        self._stngs = Button(self._stngs_model.get_summary(),
                             self._on_click_stngs,
                             name="stngs")
        self._status = Button(self._status_model.get_summary(),
                              self._on_click_status)
        self._txrx = Label("--/--", name="txrx")
        self._quit = Button("Quit", self._on_click_quit)
        layout3.add_widget(self._time, 0)
        layout3.add_widget(self._ident, 1)
        layout3.add_widget(self._stngs, 2)
        layout3.add_widget(self._status, 3)
        layout3.add_widget(self._txrx, 4)
        layout3.add_widget(self._quit, 5)

        self.fix()
        self._on_input_change()
예제 #15
0
    def __init__(self, screen, order_book: LocalOrderBook):
        super(OrderBookFrame, self).__init__(screen,
                                             screen.height,
                                             screen.width,
                                             has_border=False,
                                             name="Order Book")
        # Internal state required for doing periodic updates
        self._last_frame = 0
        self._ob = order_book
        self._level = screen.height // 2 - 1

        # 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._asks = MultiColumnListBox(screen.height // 2,
                                        ["<25%", "<25%", "<25%"], [],
                                        titles=["Level", "Price", "Amount"],
                                        name="ask_book",
                                        parser=AsciimaticsParser())
        self._bids = MultiColumnListBox(screen.height // 2,
                                        ["<25%", "<25%", "<25%"], [],
                                        titles=["Level", "Price", "Amount"],
                                        name="bid_book",
                                        parser=AsciimaticsParser())
        self.add_layout(layout)
        layout.add_widget(self._header)
        layout.add_widget(self._asks)
        layout.add_widget(self._bids)
        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)
예제 #16
0
    def __init__(self, screen, dirstat: DirectoryStat):
        super(TDirStatView, self).__init__(
            screen, screen.height, screen.width,
            has_border=True,
            name="My Form")
        # Model
        self.dirstat: DirectoryStat = dirstat
        self.disk_usage = shutil.disk_usage(str(self.dirstat.path)).used

        # Settings
        self.percent_mode = PercentMode.rel_to_dir

        # Create layouts
        layout_1 = Layout([1], fill_frame=True)
        layout_2 = Layout([1, 1])
        self.add_layout(layout_1)
        self.add_layout(layout_2)

        titles = [("Name", 0), ("%", "20>"), ("Size", "15>"), ("Items", "15>")]
        self._list = MultiColumnListBox(
            height=Widget.FILL_FRAME,
            columns=[c[1] for c in titles],
            titles=[c[0] for c in titles],
            options=[],
            name="qdirstat_list",
            on_select=self.enter_directory,
            on_change=self.details)

        self._details = Text()
        self._details.disabled = True
        self._details.custom_colour = "field"

        percent_mode_radio_btn = RadioButtons(
            [("% Relative to Directory", PercentMode.rel_to_dir),
             ("% Relative to Drive", PercentMode.rel_to_drive_usage)],
            on_change=lambda: self.set_percent_mode(
                percent_mode_radio_btn.value))

        layout_1.add_widget(Label("TDirStat"))
        layout_1.add_widget(Divider())
        layout_1.add_widget(self._list)
        layout_1.add_widget(Divider())

        layout_2.add_widget(self._details, column=0)
        layout_2.add_widget(
            column=1,
            widget=percent_mode_radio_btn)

        layout_2.add_widget(Label("Press Enter to select or `q` to quit."))
        # Prepare the Frame for use
        self.fix()
예제 #17
0
 def _create_building_layout(self):
     buildings_layout = Layout([1, 1], fill_frame=False)
     # ...list of buildings
     self._buildings_list = MultiColumnListBox(
         10,  # Height
         ["<12", ">10"],
         [],
     )
     self._buildings_list.disabled = True
     # ...list of current construction
     self._under_construction = MultiColumnListBox(
         10,  # Height
         ["<12", "<9", "<0"],
         [],
         titles=["Building", "Builders", "Progress"],
     )
     self.add_layout(buildings_layout)
     buildings_layout.add_widget(Divider(), column=0)
     buildings_layout.add_widget(Label("Buildings"), column=0)
     buildings_layout.add_widget(self._buildings_list, column=0)
     buildings_layout.add_widget(Divider(), column=1)
     buildings_layout.add_widget(Label("Under Construction"), column=1)
     buildings_layout.add_widget(self._under_construction, column=1)
예제 #18
0
    def __init__(self, screen, model):
        global _detailIsOpen, _currentIndex
        _detailIsOpen = True
        super(DetailView, self).__init__(screen,
                                         int(screen.height * 0.8),
                                         int(screen.width * 0.8),
                                         on_load=self._reload_list,
                                         hover_focus=True,
                                         can_scroll=False,
                                         title="Detail View")
        # Save off the model that accesses the contacts database.
        self._model = model
        self._refresh = _refreshRate

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

        self._list_detail_view = MultiColumnListBox(
            height=Widget.FILL_FRAME,
            columns=["<50%", "<50%"],
            options=model.get_detail(_currentIndex),
            titles=["Parameter", "Value"],
            on_change=self._on_pick)
        layout.add_widget(self._list_detail_view)
        layout2 = Layout([1, 1, 1, 1])
        self.add_layout(layout2)
        self._refresh_label = Label("Refresh(s): {0:.2f}".format(_refreshRate))
        layout2.add_widget(Button("close", self._cancel), 0)
        layout2.add_widget(self._refresh_label, 1)
        layout3 = Layout([1])
        self.add_layout(layout3)
        layout3.add_widget(
            Label("Press 'Esc' to close. '+'/'-' to change refresh rate.",
                  align="^"), 0)

        # def _refresh_minus(self):
        #     self._refresh = max(0.1,self._refresh-0.1)
        #     self._refresh_label.text = "Refresh(s): {0:.2f}".format(self._refresh)
        #     self._reload_list()

        # def _refresh_plus(self):
        #     self._refresh = max(0.1,self._refresh+0.1)
        #     self._refresh_label.text = "Refresh(s): {0:.2f}".format(self._refresh)
        #     self._reload_list()

        self.fix()
        self._on_pick()
예제 #19
0
    def _init_machine_list_widget(self):
        machines = self.model.displayed_machines

        fields = [
            "Type", "State", "OS", "Hostname", "IP", "Last Active",
            "Next Command"
        ]
        widths = ["<10%", "<10%", "<10%", "<20%", "<10%", "<10%", "<30%"]
        # old = [f"<{100 // len(fields)}%" for _ in fields]
        return MultiColumnListBox(height=Widget.FILL_FRAME,
                                  columns=widths,
                                  options=[(x, i)
                                           for i, x in enumerate(machines)],
                                  titles=fields,
                                  add_scroll_bar=True,
                                  on_select=self._view_host,
                                  name="machines")
예제 #20
0
    def __init__(self, screen, model):
        global _detailIsOpen
        _detailIsOpen == False
        super(MainView, self).__init__(
            screen,
            int(screen.height * 0.9),
            int(screen.width * 0.9),
            on_load=self._reload_list,
            hover_focus=True,
            can_scroll=False,
            title="asciiGPU {0} (Michael Auerswald @ 908video GmbH)".format(
                _version))
        # Save off the model that accesses the contacts database.
        self._model = model
        self._refresh = _refreshRate

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

        # Create the form for displaying the list of contacts.
        self._list_view = MultiColumnListBox(
            height=Widget.FILL_FRAME,
            columns=[23, 53, 10, 10, 14],
            options=model.get_columns(),
            titles=["GPU", "Usage", "Usage", "Temp", "Throttling"],
            on_change=self._on_pick,
            on_select=self._on_select)
        layout.add_widget(self._list_view)
        layout2 = Layout([1, 1, 1, 1])
        self.add_layout(layout2)
        self._refresh_label = Label("Refresh(s): {0:.2f}".format(_refreshRate))
        layout2.add_widget(Button("Quit", self._quit), 0)
        layout2.add_widget(self._refresh_label, 1)
        # layout2.add_widget(Button("-", self._refresh_minus), 2)
        # layout2.add_widget(Button("+", self._refresh_plus), 3)
        layout3 = Layout([1])
        self.add_layout(layout3)
        layout3.add_widget(
            Label(
                "Press 'q' or 'Esc' to exit. '+'/'-' to change refresh rate.",
                align="^"), 0)

        self.fix()
        self._on_pick()
예제 #21
0
파일: views.py 프로젝트: Eeems/ample
 def __init__(self, screen, model):
     super(MainView, self).__init__(screen,
                                    screen.height,
                                    screen.width,
                                    has_shadow=True,
                                    name='Main View')
     self.model = model
     status_layout = Layout([80, 10, 10])
     self.add_layout(status_layout)
     self.status_label = Label('Not Connected')
     status_layout.add_widget(self.status_label, column=0)
     status_layout.add_widget(Button('Reload', self.reload_click), column=1)
     status_layout.add_widget(Button('Logout', self.logout_click), column=2)
     layout = Layout([100])
     self.add_layout(layout)
     self.emails = MultiColumnListBox(screen.height - 10, ['<50%', '<50%'],
                                      self.model.unread_options,
                                      name='emails',
                                      on_select=self.select_email)
     layout.add_widget(self.emails)
     self.fix()
예제 #22
0
파일: views.py 프로젝트: pjlampil/artmr
    def __init__(self, screen, controller):
        super(StartListView, self).__init__(screen,
                                       screen.height,
                                       screen.width,
                                       on_load=self._reload_list,
                                       hover_focus=True,
                                       title="artmr v" + VERSION + " - START LIST for " + controller.get_current_competition().name)
        self._controller = controller
        self._last_frame = 0
        self._sort = "alpha"

        self._list_view = MultiColumnListBox(
            Widget.FILL_FRAME,
            ['15%', '45%','10%', '15%', '15%'],
            self._get_summary(),
            name="start list",
            on_change=self._on_pick,
            titles=['Number', 'Name', 'Cat.', 'Team', 'Starting'])
        self._splits_button = Button("Timing", self._splits)
        self._edit_button = Button("Tgl Sort", self._toggle_sort)
        self._present_button = Button("Tgl Starting", self._starting)
        self._quit_button = Button("Quit", self._quit)
        self._start_time = None

        layout = Layout([100], fill_frame=True)
        self.add_layout(layout)
        self._info_label = Label("Press F2 to load a starting list. Use Space / Present to confirm starting competitors. Go to Timing page to start the race.")
        layout.add_widget(self._list_view)
        layout.add_widget(self._info_label)
        layout.add_widget(Divider())
        layout2 = Layout([1, 1, 1, 1])
        self.add_layout(layout2)
        layout2.add_widget(self._splits_button, 0)
        layout2.add_widget(self._present_button, 1)
        layout2.add_widget(self._edit_button, 2)
        layout2.add_widget(self._quit_button, 3)

        self.fix()
        self._on_pick()
예제 #23
0
    def __init__(self, screen, model):
        super(QuantityDetailsView, self).__init__(
            screen,
            screen.height,
            screen.width,
            on_load=self._reload_list,
            hover_focus=False,
            can_scroll=False,
            title="",
        )

        self.set_theme("custom")

        self._model = model

        self._data_files_view = MultiColumnListBox(Widget.FILL_FRAME,
                                                   ["<40", "<64"],
                                                   model.get_data_files(),
                                                   name="data_files")
        self._copy_path_button = Button("Copy path", self._copy_path)
        self._copy_uuid_button = Button("Copy UUID", self._copy_uuid)

        self._copy_path_button.disabled = not USE_PYPERCLIP
        self._copy_uuid_button.disabled = not USE_PYPERCLIP

        info_layout = Layout([100], fill_frame=True)
        self.add_layout(info_layout)
        info_layout.add_widget(self._data_files_view)
        info_layout.add_widget(Divider())

        button_row_layout = Layout([1, 1, 1, 1])
        self.add_layout(button_row_layout)
        button_row_layout.add_widget(self._copy_path_button, 0)
        button_row_layout.add_widget(self._copy_uuid_button, 1)
        button_row_layout.add_widget(Button("Close", self._close), 3)

        self.fix()
        self._reload_list()
예제 #24
0
    def _compose_layout(self):
        list_layout = Layout([1], fill_frame=True)
        self.add_layout(list_layout)
        self._statuses = MultiColumnListBox(
            height=self._canvas.height - 4,
            columns=("40%", "20%", "40%"),
            titles=("Hash", "gRPC", "Status"),
            options=[],
            name="statuses",
            on_select=self._show_status,
        )
        list_layout.add_widget(self._statuses)
        list_layout.add_widget(Divider())

        action_layout = Layout([1, 1, 1])
        self.add_layout(action_layout)
        action_layout.add_widget(
            Button(text="Show", on_click=self._show_status))
        action_layout.add_widget(
            Button(text="Refresh",
                   on_click=lambda: self._model.request_statuses()), 1)
        action_layout.add_widget(
            Button(text="Cancel", on_click=self._model.cancel), 2)
예제 #25
0
    def __init__(self,
                 screen,
                 table,
                 edit_scene,
                 header_text='TableFrame',
                 spacing=2,
                 has_border=True):
        self.table = table
        self.__screen = screen
        self.__edit_scene = edit_scene
        self.__spacing = spacing
        super().__init__(screen,
                         screen.height,
                         screen.width,
                         has_border=has_border,
                         name=header_text,
                         on_load=self._reload_list)
        layout = Layout([1], fill_frame=True)
        # Header
        self.__header = TextBox(1, as_string=True)
        self.__header.disabled = True
        self.__header.custom_colour = "label"
        self.__header.value = header_text
        # List of rows
        self.__list = MultiColumnListBox(Widget.FILL_FRAME,
                                         self.table.get_column_widths(
                                             self.__spacing), [],
                                         titles=self.table.get_column_names(),
                                         name='row_index')

        self.add_layout(layout)
        layout.add_widget(self.__header)
        layout.add_widget(self.__list)
        self.fix()

        # Change colours
        self.set_theme('monochrome')
예제 #26
0
파일: typeedit.py 프로젝트: duck57/poke-db
    def __init__(self, screen, model):
        super(ListView, self).__init__(
            screen,
            screen.height * 2 // 3,
            screen.width * 2 // 3,
            on_load=self._reload_list,
            hover_focus=True,
            title="Type List",
        )
        # Save off the model that accesses the types database.
        self._model = model

        # Create the form for displaying the list of types.
        self._list_view = MultiColumnListBox(
            Widget.FILL_FRAME,
            ["<0", ">5"],
            model.get_summary(),
            name="types",
            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()
        self._delete_button.disabled = True
예제 #27
0
    def __init__(self, screen, worker_info_manager: WorkerInfoManager):
        super(WorkerInfoScene, self).__init__(screen,
                                              screen.height,
                                              screen.width,
                                              title='Worker Info',
                                              reduce_cpu=False)

        self._last_frame = 0
        self._model = worker_info_manager
        self._model._refresh()
        self.data = {'updated_at': str(dt.now())}
        self.palette = PALETTE

        rollup_layout = Layout([100])
        self.add_layout(rollup_layout)
        self.rollup_widget = MultiColumnListBox(round(screen.height * .05),
                                                ['12%'] * 8, [],
                                                titles=[
                                                    'Worker Count',
                                                    'Average CPU',
                                                    'Average Memory',
                                                    'Total Fds',
                                                    'Total Executing',
                                                    'Total In Mem',
                                                    'Total Ready',
                                                    'Total In Flight',
                                                ],
                                                parser=AsciimaticsParser())
        rollup_layout.add_widget(self.rollup_widget)

        div_layout = Layout([100])
        self.add_layout(div_layout)
        div_layout.add_widget(Divider())

        column_layout = Layout([100])
        self.add_layout(column_layout)
        self.worker_widget = MultiColumnListBox(
            round(screen.height * .95),
            [
                '20%',
                '10%',
                '20%',
                '10%',
                '10%',
                '10%',
                '10%',
                '10%',
            ],
            [],
            titles=[
                'Worker Address',
                'CPU',
                'Memory',
                'File Descriptors',
                'Executing',
                'In Memory',
                'Ready',
                'In Flight',
            ],
            parser=AsciimaticsParser(),
        )
        column_layout.add_widget(self.worker_widget)

        self.fix()
예제 #28
0
    def __init__(self, screen: Any, cache: TopCache, show_details: bool):

        super(TopView, self).__init__(screen,
                                      screen.height,
                                      screen.width,
                                      has_border=True,
                                      can_scroll=False)
        self.cache = cache
        self.show_details = show_details
        self.set_theme("monochrome")
        self.palette["title"] = (
            Screen.COLOUR_BLACK,
            Screen.A_NORMAL,
            Screen.COLOUR_WHITE,
        )

        self.job_count = len(self.cache.jobs)
        self.pool_count = len(self.cache.pools)

        max_widget_height = (int(
            (screen.height - BASE_LINES) / 3) - EXTRA_LINES_PER_WIDGET)

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

        self.onefuzz_reversed = {
            "pools": True,
            "jobs": True,
            "tasks": True,
            "messages": True,
        }

        dimensions = {
            "pools": {
                "height": min(self.pool_count + 1, max_widget_height),
                "setup": self.cache.POOL_FIELDS,
            },
            "jobs": {
                "height": min(self.job_count + 1, max_widget_height),
                "setup": self.cache.JOB_FIELDS,
            },
            "tasks": {
                "height": Widget.FILL_FRAME,
                "setup": self.cache.TASK_FIELDS
            },
            "messages": {
                "height": min(10, max_widget_height),
                "setup": ["Updated", "Type", "Message"],
            },
            "status": {
                "height": 1
            },
        }

        for name in ["status", "pools", "jobs", "tasks", "messages"]:
            if name == "messages" and not self.show_details:
                continue

            titles = dimensions[name].get("setup")

            if titles:
                title = TextBox(1, as_string=True, name=name + "_title")
                title.disabled = True
                title.custom_colour = "label"
                layout.add_widget(title)

            widget = MultiColumnListBox(
                dimensions[name]["height"],
                column_config(titles),
                [],
                titles=titles,
                name=name,
                add_scroll_bar=bool(titles),
            )
            if not titles:
                widget.disabled = True

            layout.add_widget(widget)
            layout.add_widget(Divider())

        layout.add_widget(Label("Press `q` to quit or `r` to reorder."))
        self.fix()
예제 #29
0
    def test_multi_column_list_box(self):
        """
        Check MultiColumnListBox works as expected.
        """
        # 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(
            Widget.FILL_FRAME, [3, "4", ">4", "<4", ">10%", "100%"], [
                (["1", "2", "3", "4", "5", "6"], 1),
                (["11", "222", "333", "444", "555", "6"], 2),
                (["111", "2", "3", "4", "5", "6"], 3),
                (["1", "2", "33333", "4", "5", "6"], 4),
                (["1", "2", "3", "4", "5", "6666666666666666666666"], 5),
            ],
            titles=["A", "B", "C", "D", "E", "F"],
            name="mc_list")
        form.add_layout(layout)
        layout.add_widget(mc_list)
        form.fix()
        form.register_scene(scene)
        form.reset()

        # Check we have a default value for our list.
        form.save()
        self.assertEqual(form.data, {"mc_list": 1})

        # Check that UP/DOWN change selection.
        self.process_keys(form, [Screen.KEY_DOWN])
        form.save()
        self.assertEqual(form.data, {"mc_list": 2})
        self.process_keys(form, [Screen.KEY_UP])
        form.save()
        self.assertEqual(form.data, {"mc_list": 1})

        # Check that PGUP/PGDN change selection.
        self.process_keys(form, [Screen.KEY_PAGE_DOWN])
        form.save()
        self.assertEqual(form.data, {"mc_list": 5})
        self.process_keys(form, [Screen.KEY_PAGE_UP])
        form.save()
        self.assertEqual(form.data, {"mc_list": 1})

        # Check that the widget is rendered correctly.
        form.update(0)
        self.assert_canvas_equals(
            canvas, "A  B      C D      E F                  \n" +
            "1  2      3 4      5 6                  \n" +
            "11 222  333 444  555 6                  \n" +
            "...2      3 4      5 6                  \n" +
            "1  2   3... 4      5 6                  \n" +
            "1  2      3 4      5 6666666666666666666\n" +
            "                                        \n" +
            "                                        \n" +
            "                                        \n" +
            "                                        \n")

        # Check that mouse input changes selection.
        self.process_mouse(form, [(2, 2, MouseEvent.LEFT_CLICK)])
        form.save()
        self.assertEqual(form.data, {"mc_list": 2})
        self.process_mouse(form, [(2, 1, MouseEvent.LEFT_CLICK)])
        form.save()
        self.assertEqual(form.data, {"mc_list": 1})

        # Check that the start_line can be read and set - and enforces good behaviour
        mc_list.start_line = 0
        self.assertEqual(mc_list.start_line, 0)
        mc_list.start_line = len(mc_list.options) - 1
        self.assertEqual(mc_list.start_line, len(mc_list.options) - 1)
        mc_list.start_line = 10000000
        self.assertEqual(mc_list.start_line, len(mc_list.options) - 1)

        # Check that options can be read and set.
        mc_list.options = [(["a", "b", "c", "d", "e", "f"], 0)]
        self.assertEqual(mc_list.options,
                         [(["a", "b", "c", "d", "e", "f"], 0)])
        mc_list.options = []
        self.assertEqual(mc_list.options, [])

        # Check that the form re-renders correctly afterwards.
        form.update(1)
        self.assert_canvas_equals(
            canvas, "A  B      C D      E F                  \n" +
            "                                        \n" +
            "                                        \n" +
            "                                        \n" +
            "                                        \n" +
            "                                        \n" +
            "                                        \n" +
            "                                        \n" +
            "                                        \n" +
            "                                        \n")

        # Check that the current focus ignores unknown events.
        event = object()
        self.assertEqual(event, form.process_event(event))
예제 #30
0
파일: views.py 프로젝트: pjlampil/artmr
    def __init__(self, screen, controller):
        super(SplitListView, self).__init__(screen,
                                       screen.height,
                                       screen.width,
                                       on_load=self._reload_list,
                                       hover_focus=True,
                                       reduce_cpu=True,
                                       title="artmr v" + VERSION + " - RESULTS for " + controller.get_current_competition().name)

        #logging.basicConfig(filename='example.log',level=logging.INFO)

        self._controller = controller

        self._last_frame = 0
        # Create the form for displaying the list of competitors.
        self._list_view = MultiColumnListBox(
            Widget.FILL_FRAME,
            ['8%', '10%', '10%', '8%', '35%', '10%', '19%'],
            self._get_summary(),
            name="splits",
            on_change=self._on_pick,
            titles=['Rank', 'Time', 'Diff', 'Number', 'Name', 'Cat.', 'Team'])

        self._start_list_view = MultiColumnListBox(
            Widget.FILL_FRAME,
            ['25%','75%'],
            self._get_competitor_summary(),
            name="competitors",
            on_change=self._on_comp_pick,
            titles=['Number', 'Name'])


        self._edit_button = Button("Edit", self._match_split)
        self._start_button = Button("Start", self._start)
        self._quit_button = Button("Quit", self._quit)
        self._split_button = Button("Split", self._add)
        self._start_list_button = Button("Start list", self._start_list)

        self._start_button.disabled = (self._controller.get_current_competition().startTime != None)
        self._split_button.disabled = (self._controller.get_current_competition().startTime == None)

        layout = Layout([20, 10, 70])
        layout0 = Layout([100])
        layout1 = Layout([75,25], fill_frame=True)
        layout2 = Layout([100])
        self.add_layout(layout)
        self.add_layout(layout0)
        self.add_layout(layout1)
        self.add_layout(layout2)

        self._time_label = Label("Elapsed Time:")
        self._time_label_value = Label("NOT STARTED")

        self._cat_label = Label("Selected Category [F2]:")
        self._cat_label_value = Label("All")
        self._cat_label.disabled = True

        layout.add_widget(self._time_label,0)
        layout.add_widget(self._time_label_value, 1)
        layout.add_widget(self._cat_label, 0)
        layout.add_widget(self._cat_label_value, 1)
        layout1.add_widget(Label("Start list"), 1)
        layout1.add_widget(self._list_view, 0)
        layout1.add_widget(self._start_list_view, 1)
        layout0.add_widget(Divider())
        layout2.add_widget(Divider())

        if self._controller.get_current_competition().startTime == None:
            self._info_label_text = "Press Space / Start to begin timing. Press F2 for category filter."
        else: 
            self._info_label_text = "Create new splits with S / Space. Select competitor first or add a competitor to a split with Edit / E. Press F2 for category filter. Export with X."

        self._info_label = Label(self._info_label_text)
        self._info_label_reset = None

        layout2.add_widget(self._info_label)

        layout3 = Layout([1, 1, 1, 1, 1])
        self.add_layout(layout3)
        layout3.add_widget(self._start_list_button, 0)
        layout3.add_widget(self._start_button, 1)
        layout3.add_widget(self._split_button, 2)
        layout3.add_widget(self._edit_button, 3)
        layout3.add_widget(self._quit_button, 4)

        self.fix()
        self._on_pick()