Esempio n. 1
0
    def get_footer(self, name, app):
        """returns a frame footer widget"""

        main_menu_items = app.menus.get_view_menu_items('Main')
        view_menu_items = app.menus.get_view_menu_items(name)

        main_menu_grid = self.get_grid_flow(app, main_menu_items)
        view_menu_items = self.get_grid_flow(app, view_menu_items)

        legend_items = []
        for legend in S.display['legend']:
            legend_items.append(self.get_text('bold', legend[0], 'center'))
        legend_grid = U.GridFlow(legend_items, 21, 0, 0, 'center')
        legend_grid_map = U.AttrMap(legend_grid, 'bold')

        legend_items = []
        for legend in S.display['legend']:
            legend_items.append(
                self.get_text('highlight', legend[1], 'center'))
        legend_items_grid = U.GridFlow(legend_items, 21, 0, 0, 'center')
        legend_items_map = U.AttrMap(legend_items_grid, 'highlight')

        if view_menu_items:
            pile = U.Pile([
                view_menu_items,
                main_menu_grid,
                legend_grid_map,
                legend_items_map])
        else:
            pile = U.Pile([
                main_menu_grid,
                legend_grid_map,
                legend_items_map])
        return pile
Esempio n. 2
0
    def setup_listbox(self):
        """The main listbox"""
        self.disht_group = []
        radio_dish_types = ur.GridFlow(
            [ur.AttrMap(
                ur.RadioButton(self.disht_group, txt), 'buttn', 'buttnf')
                                for txt in DISH_TYPES], 15, 0, 2, 'left'
        )
        for item in self.disht_group:
            if item.get_label() == self.recipe.dish_type:
                item.set_state(True)

        self.general_info = self._get_general_info()

        self.general_info = ur.Padding(
            ur.Pile(self.general_info), align='left', left=2
        )
        headings_general_and_dish_types = ur.GridFlow(
                    [HEADINGS['general_info'],
                     HEADINGS['dish_types'],
                     HEADINGS['notes'],
                     ], 53, 0, 2, 'left'
        )
        headings_ingred_and_method = ur.GridFlow(
                    [HEADINGS['ingredients'],
                     HEADINGS['method'],
                     ], 79, 0, 2, 'left'
        )

        self.ingred_block = IngredientsContainer(
            ingredients = self.recipe.get_ingredients()
        )
        
        self.method_block = EntryBlock(
            self.recipe.steps
        )
        
        self.notes_block = EntryBlock(
            self.recipe.notes
        )
        
        general_and_dish = ur.GridFlow(
            [self.general_info,
            radio_dish_types,
            self.notes_block], 53, 0, 2, 'left'
        )
        
        ingred_and_method = ur.GridFlow(
            [self.ingred_block,
            self.method_block], 79, 0, 2, 'left'
        )
        
        self.listbox_content = [
            BLANK, headings_general_and_dish_types,
            BLANK, general_and_dish,
            BLANK, headings_ingred_and_method,
            BLANK, ingred_and_method
        ]
        list_box = ur.ListBox(ur.SimpleListWalker(self.listbox_content))
        return list_box
Esempio n. 3
0
 def gameView(self):
     output = urwid.Frame(
         urwid.Columns([
             ('weight', 2,
              urwid.LineBox(
                  urwid.Overlay(
                      urwid.ListBox(
                          urwid.SimpleListWalker([self.game_ascii_art])),
                      urwid.SolidFill(u'\N{MEDIUM SHADE}'), 'left',
                      ('relative', 100), 'middle', ('relative', 100)))),
             urwid.LineBox(
                 urwid.Overlay(
                     urwid.ListBox(
                         urwid.SimpleListWalker([self.game_message])),
                     urwid.SolidFill(u'\N{MEDIUM SHADE}'), 'left',
                     ('relative', 100), 'middle', ('relative', 100)))
         ]),
         header=urwid.LineBox(
             urwid.GridFlow([urwid.Text("H A N G M A N")], 15, 0, 0,
                            'center')),
         footer=urwid.LineBox(
             urwid.GridFlow(
                 [urwid.Button("Pause", on_press=self.fsm.pause)], 10, 0, 5,
                 'left')))
     self.loop.unhandled_input(self.gameInput)
     return output
Esempio n. 4
0
    def _create_game_panel(self, date=None) -> urwid.LineBox:
        next_btn = SelectableText(u'Next', on_press=self.cycle_games)
        prev_btn = SelectableText(u'Prev', on_press=self.cycle_games)
        date_btn = SelectableText(u'Date',
                                  on_press=self.date_picker,
                                  user_data=self)

        if not date:
            date = arrow.now().to('local')
        else:
            date = date.get_date()

        if self.app.sizing.gp_main > 20:
            date_text = urwid.Text(date.strftime('%a %b %d, %Y'))
        else:
            date_text = urwid.Text(date.strftime('%x'))

        num_games = urwid.Text(f'Game(s): {self.app.size}')

        btn_grid = urwid.GridFlow([prev_btn, next_btn, date_btn],
                                  self.app.sizing.gp_btns, 3, 1, 'center')

        if self.app.sizing.gp_main < 16:
            top_grid = urwid.GridFlow(
                [date_text, num_games, prev_btn, next_btn, date_btn],
                self.app.sizing.gp_main, 2, 1, 'center')
        else:
            top_grid = urwid.GridFlow([date_text, num_games, btn_grid],
                                      self.app.sizing.gp_main, 3, 1, 'center')

        cards = []

        if self.app.size > self.app.max_games:
            count = self.app.max_games
        elif self.app.size == 0:
            count = 0
            cards = [
                Text(u'No games today. Select another date from above.'),
            ]
        else:
            count = self.app.size

        for game in self.app.banner_games:
            self.app.hidden_next.appendleft(self._create_game_card(game))

        for i in range(count):
            cards.append(('weight', 3, self.app.hidden_next.pop()))

        columns = urwid.Columns(cards)

        if self.app.sizing.gp_divider:
            pile = urwid.Pile([top_grid, urwid.Divider(), columns])
        else:
            pile = urwid.Pile([top_grid, columns])

        box = box_wrap(pile, self._rows)

        return urwid.LineBox(box)
Esempio n. 5
0
def getTableQuotes():

    tableQuotes = []
    title = [
        urwid.Text("SYM"),
        urwid.Text("DIF"),
        urwid.Text("PRICE"),
        urwid.Text("TIME"),
        urwid.Text("ACTION"),
        urwid.Text("ALERT")
    ]

    tableQuotes.append((urwid.GridFlow(title, 10, 1, 0,
                                       "left"), ("pack", None)))

    for s, q in sorted(quotesStorage.iteritems(),
                       key=lambda q: q[1]["dif"],
                       reverse=True):

        #http://www.jarloo.com/real-time-google-stock-api/
        dif = float(q["data"]["ChangePercent"]) / 100
        price = float(q["data"]["LastTradePrice"].replace(",", ""))
        fec = parser.parse(q["data"]["LastTradeTime"]).time().strftime("%H:%M")

        attr = "default"
        if dif > 0:
            attr = "alta"
        elif dif < 0:
            attr = "baja"

        action = ""
        attrAction = "default"
        if "buyAt" in config["what2watch"][s]:
            if price <= config["what2watch"][s]["buyAt"]:
                action = "BUY"
                attrAction = "alta"

        if "sellAt" in config["what2watch"][s]:
            if price >= config["what2watch"][s]["sellAt"]:
                action = "SELL"
                attrAction = "baja"

        #http://urwid.org/reference/widget.html#urwid.GridFlow
        cells = [
            urwid.Text(s),
            urwid.Text((attr, "{:>+3.2%}".format(q["dif"]))),
            urwid.Text("{:>8.2f}".format(price)),
            urwid.Text("{}".format(fec)),
            urwid.Text((attrAction, action)),
            urwid.Text(
                ("alert", "ALERT!" if q["dif"] > config["alert"] else ""))
        ]

        tableQuotes.append((urwid.GridFlow(cells, 10, 1, 0,
                                           "left"), ("pack", None)))

    return tableQuotes
    def __init__(self, parent):

        software_src_list = ['RH CDN', 'Distro', 'Community']
        osd_types = ['filestore', 'bluestore']
        dmcrypt_settings = ['standard', 'encrypted']

        cfg = parent.cfg

        self.sw_source_group = []
        self.osd_type = []
        self.dmcrypt_group = []

        self.text = (
            "Environment\n\nDefine the types of environment settings that "
            "will determine the way the cluster is installed and configured.")

        self.deployment_user = FixedEdit("Deployment User : ",
                                         width=8,
                                         valid_chars=self.alphanum)
        self.deployment_user.edit_text = 'root'

        software_buttons = [
            urwid.RadioButton(self.sw_source_group, txt, state=False)
            for txt in software_src_list
        ]
        software_buttons[software_src_list.index(
            cfg.defaults.sw_src)].state = True
        self.software_sources = urwid.GridFlow(software_buttons,
                                               14,
                                               4,
                                               0,
                                               align='left')

        osd_buttons = [
            urwid.RadioButton(self.osd_type, txt, state=False)
            for txt in osd_types
        ]
        osd_buttons[osd_types.index(cfg.defaults.osd_objectstore)].state = True
        self.osd_options = urwid.GridFlow(osd_buttons, 14, 4, 0, align='left')

        dmcrypt_buttons = [
            urwid.RadioButton(self.dmcrypt_group, txt, state=False)
            for txt in dmcrypt_settings
        ]
        dmcrypt_buttons[dmcrypt_settings.index(
            cfg.defaults.dmcrypt)].state = True
        self.dmcrypt_options = urwid.GridFlow(dmcrypt_buttons,
                                              14,
                                              4,
                                              0,
                                              align='left')
        self.next_btn = ui_button(callback=self.validate)

        UIBaseClass.__init__(self, parent)
Esempio n. 7
0
 def poor_man_refresh(self, what_to_do=True):
     temp_minute = datetime.datetime.now().minute
     if temp_minute < 10:
         temp_minute = "0" + str(temp_minute)
     else:
         temp_minute
     clock_element = urwid.AttrMap(
         urwid.BigText(
             "{0}{1}{2}".format(datetime.datetime.now().hour,
                                ":", temp_minute),
             urwid.font.HalfBlock5x4Font()), "clock_c")
     burger = BoxButton('burger',
                        999,
                        is_sprite=True,
                        on_press=self.show_menu,
                        no_border=True,
                        user_data=None,
                        theme=get_theme("burger"))
     button_line_box = urwid.AttrMap(
         urwid.LineBox(urwid.Pile([
             urwid.Divider(" ", top=0, bottom=0),
             urwid.GridFlow(self.buttons_list[self.page_num][0],
                            cell_width=50,
                            h_sep=0,
                            v_sep=2,
                            align='center'),
             urwid.Divider(" ", top=0, bottom=0)
         ]),
                       trcorner=u"\u2584",
                       tlcorner=u"\u2584",
                       tline=u"\u2584",
                       bline=u"\u2580",
                       blcorner=u"\u2580",
                       brcorner=u"\u2580",
                       lline=u"\u2588",
                       rline=u"\u2588"), "outer_box_c")
     base = urwid.Filler(
         urwid.Pile([
             urwid.Columns([
                 urwid.Padding(clock_element, 'left', width='clip'),
                 urwid.Padding(burger, 'right', width=('relative', 19))
             ]), button_line_box,
             urwid.Divider(" ", top=0, bottom=0),
             urwid.GridFlow(self.nav_array,
                            cell_width=50,
                            h_sep=0,
                            v_sep=0,
                            align='center')
         ]), 'top')
     if what_to_do:
         self.loop.widget = base
     else:
         return base
Esempio n. 8
0
File: gli.py Progetto: monsieurp/gli
    def quit_popup(self, text=['']):
        body_text = urwid.Text(text, align='center')
        body_filler = urwid.Filler(body_text, valign='middle')
        body_padding = urwid.Padding(body_filler, left=1, right=1)

        body = urwid.AttrMap(urwid.LineBox(body_padding), 'exit')

        cont = urwid.Button('Continue', self.choice)
        cont = urwid.AttrWrap(cont, 'efoc', 'esel')

        quit = urwid.Button('Quit', self.choice)
        quit = urwid.AttrWrap(quit, 'efoc', 'esel')

        rs = urwid.Button('Restart', self.choice)
        rs = urwid.AttrWrap(rs, 'efoc', 'esel')

        footer = urwid.GridFlow([cont, quit, rs], 12, 1, 22, 'center')

        layout = urwid.Frame(body, footer=footer, focus_part='footer')

        w = urwid.Overlay(layout,
                          self,
                          align='center',
                          width=40,
                          valign='middle',
                          height=10)
        w = urwid.AttrMap(w, 'exit')

        self.loop.widget = w
Esempio n. 9
0
    def buildFrame(self):
        boardButtons = []
        for story in self.storyList:
            if self.uFilter:
                if self.uFilter.lower() in story.lower():
                    boardButtons.append(
                        urwid.LineBox(
                            urwid.AttrWrap(
                                urwid.Button(story, self.changeFrameBoard),
                                'center')))
            else:
                boardButtons.append(
                    urwid.LineBox(
                        urwid.AttrWrap(
                            urwid.Button(story, self.changeFrameBoard),
                            'center')))

        self.parsedItems = len(boardButtons)
        width = len(max(self.storyList, key=len))
        buttonGrid = urwid.GridFlow(
            boardButtons, width + 9, 2, 2,
            'center')  # add 9 to width to account for widget padding
        listbox_content = [buttonGrid]

        return urwid.ListBox(urwid.SimpleListWalker(listbox_content))
Esempio n. 10
0
    def _create_contents(self):
        grid = []

        index = 0
        for item in self._row:
            if item is None:
                cell_data = u'NULL'
            else:
                if isinstance(item, bytearray):
                    try:
                        cell_data = item.decode(encoding='utf8')
                    except:
                        cell_data = item.hex()
                else:
                    cell_data = str(item)
            cell_name = str(self._columns[index]['name'])

            contents = []
            contents.append((40, urwid.AttrMap(urwid.Text(cell_name), 'editbox:label')))
            contents.append(urwid.AttrMap(urwid.Text(cell_data),
                'editbox'))
            grid.append(urwid.Columns(contents))
            index += 1

        grid = urwid.GridFlow(grid, cell_width=80, h_sep=1, v_sep=1,
                align='left')
        return grid
Esempio n. 11
0
 def __init__(self):
     self.options = []
     unsure = urwid.RadioButton(self.options, u"Unsure")
     yes = urwid.RadioButton(self.options, u"Yes")
     no = urwid.RadioButton(self.options, u"No")
     display_widget = urwid.GridFlow([unsure, yes, no], 15, 3, 1, 'left')
     urwid.WidgetWrap.__init__(self, display_widget)
Esempio n. 12
0
    def __init__(self, srvapi, tid, title=None):
        self._title = title
        self._torrent = {}

        sections = []
        self._sections = {}
        for section_cls in _sections:
            section = section_cls()
            sections.append(section)
            self._sections[section.title] = section

        def add_title(title, section):
            header = urwid.Columns([('pack', urwid.Text('──┤ %s ├' % title)),
                                    urwid.Divider('─')])
            return urwid.Pile([('pack', header), section])

        grid = urwid.GridFlow([], cell_width=1, h_sep=3, v_sep=1, align='left')
        for section in sections:
            opts = grid.options('given', section.width)
            section_wrapped = add_title(section.title, section)
            grid.contents.append((section_wrapped, opts))

        grid_sb = urwid.AttrMap(
            ScrollBar(urwid.AttrMap(Scrollable(grid), 'torrentsummary')),
            'scrollbar')
        super().__init__(grid_sb)

        # Register new request in request pool
        keys = set(
            ('name', )).union(key for w in sections for key in w.needed_keys)
        self._poller = srvapi.create_poller(srvapi.torrent.torrents, (tid, ),
                                            keys=keys)
        self._poller.on_response(self._handle_response)
Esempio n. 13
0
    def create(self) -> urwid.Widget:
        self._progress = RsyncProgressBar(self.rsync, self.get_rsync_params())
        urwid.connect_signal(self._progress, "done", self._on_sync_done)
        urwid.connect_signal(self._progress, "failed", self._on_sync_failed)

        self._b_close = widget.PlainButton("Close")
        urwid.connect_signal(self._b_close, "click", self._on_close)

        b_cancel = widget.PlainButton("Cancel")
        urwid.connect_signal(b_cancel, "click", self._on_cancel)

        self.status_msg = urwid.Text("\n")

        self._button_row = urwid.GridFlow([b_cancel], 16, 1, 1, align="center")

        content = urwid.Pile(
            [
                urwid.Divider(),
                urwid.Text(self.msg_description),
                urwid.Divider(),
                self._progress,
                self.status_msg,
                self._button_row,
            ]
        )
        w = urwid.LineBox(content, title=self.msg_title)
        return w
Esempio n. 14
0
    def define_dialog(self):
        # align=center, only for fixed size dialog
        self.options = []

        applyButtonTitle = "Save and restart"
        padding = " " * ((self.width - 6 - len(applyButtonTitle)) // 2)
        applyButton = urwid.Button(padding + applyButtonTitle + padding)
        urwid.connect_signal(applyButton, 'click', lambda button: self.apply())
        window = []

        radioButtonInstances = []
        for i in range(len(self.themes)):
            radioButtonName = self.themes[i]
            selected = False
            if self.themes[i].lower() == self.preference["theme"].lower():
                selected = True
            radioButtonInstance = urwid.AttrMap(
                urwid.RadioButton(self.options, radioButtonName, selected),
                'radiobutton')
            radioButtonInstances.append(radioButtonInstance)

        radioButtons = urwid.GridFlow(radioButtonInstances, self.width - 2, 3,
                                      1, 'left')

        window.extend([
            urwid.AttrMap(urwid.Text("Themes\n"), 'dialog.content'),
            urwid.AttrMap(radioButtons, 'dialog.content'),
            urwid.AttrMap(urwid.Text("\n"), 'dialog.content'),
            urwid.AttrMap(applyButton, 'button')
        ])
        self.widget = urwid.AttrMap(
            UWLineBox(urwid.AttrMap(urwid.Filler(urwid.Pile(window)),
                                    'dialog'),
                      title=self.title), 'dialog')
Esempio n. 15
0
    def show(self, loop):
        # Header
        header_text = urwid.Text(self.title, align='center')
        header = urwid.AttrMap(header_text, 'dialog')

        # Footer
        ok_btn = urwid.Button('Ok', self.on_ok)
        ok_btn = urwid.AttrWrap(ok_btn, 'dialog_button', 'dialog_button_focus')

        footer = urwid.GridFlow([ok_btn], 12, 1, 1, 'center')

        body = urwid.Filler(
            urwid.Pile([urwid.Text(self.message),
                        urwid.Text(""), footer]))

        # Layout
        layout = urwid.Frame(body, header=header)

        w = DialogOverlay(on_close=self.on_close,
                          on_enter=self.on_ok,
                          top_w=urwid.AttrMap(urwid.LineBox(layout), "dialog"),
                          bottom_w=loop.widget,
                          align='center',
                          width=40,
                          valign='middle',
                          height=10)

        loop.widget = w
Esempio n. 16
0
    def graph_controls(self):
        # setup category buttons
        vc = self.controller.model.valid_categories
        self.category_buttons = [
            self.button(cat, self.on_cat_button, i) for i, cat in vc
        ]
        # setup animate button
        nav_controls = urwid.GridFlow([
            self.button(" prev ", self.on_nav_button, -1),
            self.button("replay", self.on_nav_button, 0),
            self.button(" next ", self.on_nav_button, 1),
        ], 10, 3, 0, 'center')

        self.progress = self.progress_bar(done=self.controller.model.runtime)
        self.progress_wrap = urwid.WidgetWrap(self.progress)

        l = [urwid.Text("Categories", align="center")]
        l += self.category_buttons
        l += [
            urwid.Divider(),
            urwid.Text("Navigation", align="center"),
            nav_controls,
            urwid.Divider(),
            urwid.LineBox(self.status),
            urwid.Divider(),
            self.progress_wrap,
            urwid.Divider(),
            self.button("Save and quit", self.save_and_exit_program),
            self.button("Quit without saving", self.exit_program),
        ]
        w = urwid.ListBox(urwid.SimpleListWalker(l))
        return w
Esempio n. 17
0
    def buildThread(self):
        self.postWidgetDict = {}

        for p in self.comments:
            self.postReplyDict[str(p.userIden)] = []

            commentWidget = self.notBrainletCommentTagParser(p)

            if self.uFilter:
                if self.uFilter.lower() in p.content.lower():
                    self.postWidgetDict[p.userIden] = commentWidget
            else:
                self.postWidgetDict[p.userIden] = commentWidget

        postWidgetList = []
        for pNum, pWidget in self.postWidgetDict.items():
            if pNum in self.postReplyDict:
                buttonReplyList = [urwid.AttrWrap(QuoteButton(str(r), self.uvm), 'quote') for r in self.postReplyDict[pNum]]
                pWidget.append(urwid.Text('Replies: '))
                pWidget.append(urwid.GridFlow(buttonReplyList, len(str(pNum)) + 4, 0, 0, 'left'))
                # pWidget.append(urwid.Text('Replies: ' + str(self.postReplyDict[pNum])))
            postWidgetList.append(urwid.LineBox(urwid.Pile(pWidget)))

        self.parsedItems = len(self.comments)


        listbox_content = postWidgetList
        listbox = urwid.ListBox(urwid.SimpleListWalker(listbox_content))

        return listbox
Esempio n. 18
0
    def draw(self):
        content_frame = urwid.Frame(body=None)

        top = urwid.Text(self.text)
        top = urwid.Padding(top, align='left', width='pack')
        top = urwid.AttrMap(urwid.Filler(top, valign='top'), 'wcolor')

        yes = urwid.AttrMap(urwid.Button('Yes', self.handle_input), 'focus',
                            'selectable')
        no = urwid.AttrMap(urwid.Button('No', self.handle_input), 'focus',
                           'selectable')

        buttons = urwid.GridFlow([yes, no], 10, 3, 1, 'center')

        bottom = urwid.Padding(buttons, align='right', width='pack')
        bottom = urwid.AttrMap(urwid.Filler(bottom, valign='bottom'), 'wcolor')

        content = urwid.Pile([top, bottom], focus_item=1)
        content = urwid.AttrMap(urwid.LineBox(content), 'wcolor')

        content = urwid.Overlay(content,
                                urwid.AttrMap(urwid.SolidFill(gli.SFILL),
                                              'bgcolor'),
                                align='center',
                                valign='middle',
                                width=60,
                                height=20)
        content_frame.body = content

        self._w = content_frame
Esempio n. 19
0
    def initFooter(self):
        connectButton = FooterButton(u"\u23ce", "Connect", "enter",
                                     self.on_footer_click)
        mcButton = FooterButton("F5", "Browse", "f5", self.on_footer_click)
        addFolderButton = FooterButton("F6", "New Folder", "f6",
                                       self.on_footer_click)
        addButton = FooterButton("F7", "New Conn.", "f7", self.on_footer_click)
        deleteButton = FooterButton("F8", "Remove", "f8", self.on_footer_click)
        editButton = FooterButton("F9", "Edit", "f9", self.on_footer_click)
        quitButton = FooterButton("Q", "Quit", "q", self.on_footer_click)
        # TODO keys that dont depend on selected node should be handled differently

        return urwid.GridFlow(
            [
                connectButton,
                mcButton,
                # TODO join add buttons to one
                addFolderButton,
                addButton,
                deleteButton,
                editButton,
                quitButton
            ],
            18,
            1,
            0,
            'center')
Esempio n. 20
0
    def show(self, loop):
        # Header
        header_text = urwid.Text('Remove Connection: ' + self.target.name,
                                 align='center')
        header = urwid.AttrMap(header_text, 'dialog')

        # Footer
        ok_btn = urwid.Button('Ok', self.on_ok)
        ok_btn = urwid.AttrWrap(ok_btn, 'dialog_button', 'dialog_button_focus')

        cancel_btn = urwid.Button('Cancel', self.on_cancel)
        cancel_btn = urwid.AttrWrap(cancel_btn, 'dialog_button',
                                    'dialog_button_focus')

        footer = urwid.GridFlow([ok_btn, cancel_btn], 12, 1, 1, 'center')

        body = urwid.Filler(
            urwid.Pile([urwid.Text("Are you sure?"),
                        urwid.Text(""), footer]))

        # Layout
        layout = urwid.Frame(body, header=header)

        w = DialogOverlay(on_close=lambda: self.on_close(self.target),
                          on_enter=lambda: self.on_ok(None),
                          top_w=urwid.AttrMap(urwid.LineBox(layout), "dialog"),
                          bottom_w=loop.widget,
                          align='center',
                          width=40,
                          valign='middle',
                          height=10)

        loop.widget = w
Esempio n. 21
0
 def msgBox(message):
     width = ('relative', 50)
     height = ('relative', 20)
     body = urwid.Filler(urwid.Divider(), 'top')
     frame = urwid.Frame(body, focus_part='footer')
     frame.header = urwid.Pile([urwid.Text(message), urwid.Divider()])
     w = frame
     w = urwid.Padding(w, ('fixed left', 2), ('fixed right', 2))
     w = urwid.Filler(w, ('fixed top', 1), ('fixed bottom', 1))
     w = urwid.AttrWrap(w, 'body')
     w = urwid.Columns([w, ('fixed', 2, urwid.AttrWrap(
         urwid.Filler(urwid.Text(('border', '  ')), "top"), 'shadow'))])
     w = urwid.Frame(w, footer=urwid.AttrWrap(urwid.Text(('border', '  ')), 'shadow'))
     w = urwid.Padding(w, 'center', width)
     w = urwid.Filler(w, 'middle', height)
     w = urwid.AttrWrap(w, 'border')
     l = []
     for name, exitcode in [("OK", 0)]:
         b = urwid.Button(name, CursesMessage.button_press)
         b.exitcode = exitcode
         b = urwid.AttrWrap(b, 'selectable', 'focus')
         l.append(b)
         buttons = urwid.GridFlow(l, 10, 3, 1, 'center')
         frame.footer = urwid.Pile([urwid.Divider(), buttons ], focus_item=1)
     loop = urwid.MainLoop(w, CursesMessage.palette)
     try:
         loop.run()
     except DialogExit, e:
         return CursesMessage.on_exit(e.args[0])
Esempio n. 22
0
    def buildFrame(self, board):
        '''returns the board widget'''

        threadButtonList = []

        for title, threadInfo in self.titles.items():
            if title == 'Next':
                if not self.uFilter:
                    subButton = urwid.Button(str(threadInfo[0]), self.changeStoryPage)
                    threadButtonList.append(urwid.LineBox(urwid.Pile([subButton, urwid.Divider('-'), urwid.Text(threadInfo[1])])))
                continue
            if self.uFilter:
                if re.search(self.uFilter.lower(), title.lower()):
                    threadButton = urwid.Button(str(threadInfo[0]), self.changeFrameThread)
                    threadInfo = urwid.Text(self.info_text.format(str(threadInfo[1]),str(threadInfo[2])))
                    threadList = [threadButton, urwid.Divider('-'), urwid.Divider(), urwid.Text(title), urwid.Divider(), urwid.Divider('-'), threadInfo]
                    threadButtonList.append(urwid.LineBox(urwid.Pile(threadList)))
            else:
                threadButton = urwid.Button(str(threadInfo[0]), self.changeFrameThread)
                threadInfo = urwid.Text(self.info_text.format(str(threadInfo[1]), str(threadInfo[2])))
                threadList = [threadButton, urwid.Divider('-'), urwid.Divider(), urwid.Text(title), urwid.Divider(), urwid.Divider('-'), threadInfo]
                threadButtonList.append(urwid.LineBox(urwid.Pile(threadList)))

        self.parsedItems = len(threadButtonList)
        catalogueButtons = urwid.GridFlow(threadButtonList, 30, 2, 2, 'center')
        listbox = urwid.ListBox(urwid.SimpleListWalker([catalogueButtons]))

        self.uvm.itemCount = len(threadButtonList)
        return [listbox]
Esempio n. 23
0
    def _popup_widget(self, header, body=None, footer=None):
        """
        Content of the Popup Widget.

        Args:
            header: title of the Popup
            body: content of the Popup. Leave empty for the placeholder.
            footer: footer of the Popup. Leave empty for the single Okay button.
        Returns:
            `urwid.LineBox` that hold the widget.
        """
        # Body
        if body is None:
            body = urwid.Text(
                ('This is a placeholder text that will only be displayed '
                 'when _popup_widget.body received None. If you see this '
                 'in a production version of ubuntuwsl, Please report the '
                 'bug to WSL team at Canonical.'),
                align='left')

        body = urwid.Padding(body, left=1, right=1)

        # Footer
        if footer is None:
            footer = urwid.Button('Okay', self._reload_ui)
            footer = urwid.AttrWrap(footer, 'selectable', 'focus')
            footer = urwid.GridFlow([footer], 8, 1, 1, 'center')

        # Layout
        return urwid.LineBox(urwid.Pile([blank, body, blank, footer]),
                             title=header.title(),
                             title_attr='header',
                             title_align='center')
Esempio n. 24
0
    def show(self, loop):
        # Header
        header_text = urwid.Text(
            'Edit Folder' if self.target.name else "Add Folder",
            align='center')
        header = urwid.AttrMap(header_text, 'dialog')

        # Footer
        save_btn = urwid.Button('Save', self.on_save)
        save_btn = urwid.AttrWrap(save_btn, 'dialog_button',
                                  'dialog_button_focus')

        cancel_btn = urwid.Button('Cancel', self.on_cancel)
        cancel_btn = urwid.AttrWrap(cancel_btn, 'dialog_button',
                                    'dialog_button_focus')

        footer = urwid.GridFlow([save_btn, cancel_btn], 12, 1, 1, 'center')

        body = urwid.Filler(urwid.Pile([self.folder_name, footer]))

        # Layout
        layout = urwid.Frame(body, header=header)

        w = DialogOverlay(on_close=lambda: self.on_close(self.target),
                          on_enter=self.on_save,
                          top_w=urwid.AttrMap(urwid.LineBox(layout), "dialog"),
                          bottom_w=loop.widget,
                          align='center',
                          width=40,
                          valign='middle',
                          height=10)

        loop.widget = w
Esempio n. 25
0
    def show(self, loop):
        # Header
        header_text = urwid.Text('Select Public SSH Key to Copy', align='center')
        header = urwid.AttrMap(header_text, 'dialog')

        cancel_btn = urwid.Button('Cancel', self.on_cancel)
        cancel_btn = urwid.AttrWrap(cancel_btn, 'dialog_button', 'dialog_button_focus')

        footer = urwid.GridFlow([cancel_btn], 12, 1, 1, 'center')

        list_box = urwid.BoxAdapter(SSHListBox(on_enter=self.on_copy, body=self.ssh_keys_walker), 5)

        body = urwid.Filler(
            urwid.Pile([list_box, footer])
        )

        # Layout
        layout = urwid.Frame(
            body=body,
            header=header)

        layout = urwid.AttrWrap(layout, 'dialog')

        w = DialogOverlay(
            on_close=lambda: self.on_close(),
            on_enter=self.on_copy,
            top_w=urwid.AttrMap(urwid.LineBox(layout), "dialog"),
            bottom_w=loop.widget,
            align='center',
            width=40,
            valign='middle',
            height=10
        )

        loop.widget = w
Esempio n. 26
0
    def _date_picker(self, btn, caller):
        """
        Date Picker widget creater. Caller refers to which button is
        calling the method: the game panel or game display.
        """
        on_press = getattr(caller, 'change_date')

        date_pick = DatePicker(highlight_prop=("dp_focus", "dp_no_focus"))
        cancel = SelectableText('Cancel', on_press=self.destroy)
        select = SelectableText('Select',
                                on_press=on_press,
                                user_data=date_pick)
        btn_grid = urwid.GridFlow([cancel, select], 10, 5, 1, 'center')

        base = urwid.Pile([
            urwid.Text(u'Use ctrl + "arrow key" to change the date.'),
            date_pick, btn_grid
        ])

        box = urwid.LineBox(base, title='Select a Date', title_align='center')

        fill = urwid.AttrMap(urwid.Filler(box), 'date_pick')

        overlay = urwid.Overlay(
            fill,
            self.frame,
            'center',
            44,
            'middle',
            7  # HACK to get the pop up to fit properly.
        )

        self.loop.widget = overlay
Esempio n. 27
0
    def _footer(self):
        """
        return a footer.

        Returns:
            `urwid.GridFlow` that contains footer.
        """
        return urwid.GridFlow((urwid.AttrWrap(
            TuiButton([('footerhlt', u'F1'), u'Save'], self._fun), 'footer'),
                               urwid.AttrWrap(
                                   TuiButton([('footerhlt', u'F2'), u'Reset'],
                                             self._fun), 'footer'),
                               urwid.AttrWrap(
                                   TuiButton([('footerhlt', u'F3'), u'Import'],
                                             self._fun), 'footer'),
                               urwid.AttrWrap(
                                   TuiButton([('footerhlt', u'F4'), u'Export'],
                                             self._fun), 'footer'),
                               urwid.AttrWrap(
                                   TuiButton([('footerhlt', u'F5'), u'Reload'],
                                             self._fun), 'footer'),
                               urwid.AttrWrap(
                                   TuiButton([('footerhlt', u'F6'), u'Help'],
                                             self._fun), 'footer'),
                               urwid.AttrWrap(
                                   TuiButton([('footerhlt', u'F7'), u'Exit'],
                                             self._fun), 'footer')), 10, 0, 0,
                              'left')
    def __init__(self, return_func, helm_repos_installed_dict):

        self.helm_repos_installed_dict = helm_repos_installed_dict
        self.selection_ch_box = [
            urwid.CheckBox("{:30}{}".format(repo['repo_name'],
                                            repo['repo_url']))
            for repo in helm_repos_installed_dict
        ]
        self.text_deletion_result = urwid.Text(u"")

        blank = urwid.Divider()
        listbox_content = [
            blank,
            urwid.WidgetWrap(urwid.Divider("=", 1)),
            urwid.Padding(urwid.Text(u"Helm Repositories Removal"),
                          left=2,
                          right=2,
                          min_width=20),
            urwid.WidgetWrap(urwid.Divider("*", 0, 1)),
            urwid.Padding(
                urwid.Text(u"Use space/enter to mark helm repo to remove"),
                left=2,
                right=2,
                min_width=20),
            blank,

            # Display helm repositories block
            urwid.Padding(urwid.Pile([
                urwid.Text("    {:30}{}".format("NAME", "URL")),
                urwid.Pile([
                    urwid.AttrWrap(chart, 'buttn', 'buttnf')
                    for chart in self.selection_ch_box
                ], ),
            ]),
                          left=2,
                          right=2,
                          min_width=10),
            blank,
            urwid.Padding(urwid.GridFlow([
                urwid.AttrWrap(urwid.Button("Cancel", on_press=self.on_cancel),
                               'buttn', 'buttnf'), blank,
                urwid.AttrWrap(
                    urwid.Button("Delete Selected Charts",
                                 on_press=self.on_delete), 'buttn', 'buttnf')
            ], 20, 1, 8, 'left'),
                          left=2,
                          right=2,
                          min_width=20,
                          align='left'),
            blank,
            urwid.Padding(self.text_deletion_result,
                          left=2,
                          right=2,
                          min_width=20),
        ]

        listbox = urwid.ListBox(urwid.SimpleListWalker(listbox_content))

        self.return_func = return_func
        self.main_window = urwid.LineBox(urwid.AttrWrap(listbox, 'body'))
Esempio n. 29
0
    def _content_validation(self):
        """
        Validate the content in current widget as the focus moved away.
        """
        if self.focus_content is None:
            self.focus_content = self.contentbox.focus_position
            return
        if self.focus_content > len(self.contentbox.walker):
            return
        realc = self.contentbox.walker[self.focus_content]
        #self._popup_constructor(u"Debug", urwid.Text(str(realc)))
        self.focus_content = self.contentbox.focus_position
        if not hasattr(realc, "get_source"):
            return
        k, l, m = realc.get_source()
        n = realc.get_core_value()
        a, b = self.handler.validate(k, l, m, n)
        if not a:

            def _better_reload(button):
                self._nav_update(forced_value=k)
                self.contentbox.set_focus(self.focus_content)

            footer = urwid.AttrWrap(urwid.Button('Okay', _better_reload),
                                    'selectable', 'focus')
            footer = urwid.GridFlow([footer], 8, 1, 1, 'center')
            self._popup_constructor(u"Validation Error", urwid.Text(b), footer)
    def __init__(self, return_func):

        self.create_namespace_edit_box = urwid.Edit(('editcp', u"Namespace to add: "), "set name", align='left', )
        self.create_namespace_result = urwid.Text(u"")

        blank = urwid.Divider()
        listbox_content = [
            blank,
            urwid.WidgetWrap(urwid.Divider("=", 1)),
            urwid.Padding(urwid.Text(u"Create Namespace"), left=2, right=2, min_width=20),
            urwid.WidgetWrap(urwid.Divider("*", 0, 1)),
            blank,

            blank,
            urwid.Padding(urwid.AttrWrap(self.create_namespace_edit_box, 'editbx', 'editfc'), left=2, right=2),
            blank,
            urwid.Padding(
                urwid.GridFlow(
                    [urwid.AttrWrap(urwid.Button("Cancel", on_press=self.on_cancel), 'buttn', 'buttnf'),
                     blank,
                     urwid.AttrWrap(urwid.Button("Create", on_press=self.on_create_namespace), 'buttn', 'buttnf')
                     ],
                    20, 1, 8, 'left'),
                left=2, right=2, min_width=20, align='left'),

            blank,
            urwid.Padding(self.create_namespace_result, left=2, right=2, min_width=20),
        ]

        listbox = urwid.ListBox(urwid.SimpleListWalker(listbox_content))

        self.return_func = return_func
        self.main_window = urwid.LineBox(urwid.AttrWrap(listbox, 'body'))