Python urwid.Filler() Examples

The following are 30 code examples of urwid.Filler(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module urwid , or try the search function .
Example #1
Source File: customUrwidClasses.py    From TerminusBrowser with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def __init__(self, urwidViewManager):
        uvm = urwidViewManager
        close_button = urwid.Button("that's pretty cool")
        urwid.connect_signal(close_button, 'click',
            lambda button:self._emit("close"))

        historyButtonList = []
        for i in uvm.history:
            historyButtonList.append(urwid.Button(str(i), uvm.displayThread))

        pile = urwid.Pile(historyButtonList)
        # pile = urwid.Pile([urwid.Text(
        #     "^^  I'm attached to the widget that opened me. "
        #     "Try resizing the window!\n"), close_button])
        fill = urwid.Filler(pile)
        self.__super.__init__(urwid.AttrWrap(fill, 'popbg')) 
Example #2
Source File: host_definition.py    From ceph-ansible-copilot with GNU Lesser General Public License v2.1 6 votes vote down vote up
def render_page(self):

        host_widgets = urwid.Padding(self.host_panels,
                                    left=2, right=2)

        return urwid.AttrMap(
                 urwid.Filler(
                   urwid.Pile([
                               urwid.Padding(urwid.Text(self.text),
                                             left=2, right=2),
                               urwid.Divider(),
                               host_widgets,
                               urwid.Divider(),
                               self.next_btn]),
                   valign='top',top=1),
                 'active_step') 
Example #3
Source File: gui.py    From certstream-python with MIT License 6 votes vote down vote up
def setup_widgets(self):
        self.intro_frame = urwid.LineBox(
            urwid.Filler(
                urwid.Text(('body_text', self.INTRO_MESSAGE.format("")), align=urwid.CENTER),
                valign=urwid.MIDDLE,
            )
        )

        self.frame = urwid.Frame(
            body=self.intro_frame,
            footer=urwid.Text(
                [self.FOOTER_START, ('heartbeat_inactive', self.HEARTBEAT_ICON)],
                align=urwid.CENTER
            )
        )

        self.loop = urwid.MainLoop(
            urwid.AttrMap(self.frame, 'body_text'),
            unhandled_input=show_or_exit,
            palette=PALETTE,
        )

        self.list_walker = urwid.SimpleListWalker(self.message_list)
        self.list_box = urwid.ListBox(self.list_walker)
        urwid.connect_signal(self.list_walker, "modified", self.item_focused) 
Example #4
Source File: networking.py    From ceph-ansible-copilot with GNU Lesser General Public License v2.1 6 votes vote down vote up
def render_page(self):

        return urwid.AttrMap(
                 urwid.Filler(
                   urwid.Pile([
                     urwid.Padding(
                       urwid.Text(self.text),
                       left=2, right=2),
                     urwid.Divider(),
                     urwid.Columns([
                         urwid.Pile([
                             urwid.Text("Public Network", align="center"),
                             urwid.Padding(self.public_buttons,left=4)
                         ]),
                         urwid.Pile([
                             urwid.Text("Cluster Network", align="center"),
                             urwid.Padding(self.cluster_buttons, left=4)
                         ])
                     ]),
                     urwid.Divider(),
                     self.next_btn
                   ]),
                   valign='top', top=1),
                 'active_step') 
Example #5
Source File: has_modal.py    From Discurses with MIT License 6 votes vote down vote up
def open_confirm_prompt(self, callback, title="", content="",
                            yestxt="Yes", notxt="No", align="center"):
        def create_cb(bool):
            def res(*k, **a):
                callback(bool)
                self.close_pop_up()
            return res
        self.open_pop_up(
            urwid.Filler(urwid.Text(content, align=align)),
            header=urwid.Text(
                title, align='center'),
            footer=urwid.Columns([
                (urwid.Button(yestxt, create_cb(True))),
                (urwid.Button(notxt, create_cb(False))),
            ]),
            height=6,
            width=50)
        self._pop_up.set_focus("footer")
        logger.debug("Confirm prompt text: " + str(content)) 
Example #6
Source File: screens.py    From tildemush with GNU General Public License v3.0 6 votes vote down vote up
def show_login(self):
        un = self.client.config.get('username')
        pw = self.client.config.get('password')
        if un and pw:
            asyncio.wait_for(
                    asyncio.ensure_future(self.handle_login({'username':un, 'password':pw}), loop=self.loop),
                    60.0, loop=self.loop)
        else:
            un_field = FormField(caption='username: ', name='username')
            pw_field = FormField(caption='password: ', name='password', mask='~')
            submit_btn = urwid.Button('login! >')
            login_form = Form([un_field, pw_field], submit_btn)

            def wait_for_login(_):
                asyncio.wait_for(
                    asyncio.ensure_future(self.handle_login(login_form.data), loop=self.loop),
                    60.0, loop=self.loop)

            urwid.connect_signal(submit_btn, 'click', wait_for_login)

            self.open_box(urwid.Filler(login_form)) 
Example #7
Source File: view.py    From binch with MIT License 6 votes vote down vote up
def __init__(self, filename):
        self.header = urwid.Text(" BINCH: %s" % (filename))

        self.disasmblr = Disassembler(filename)

        items = self.setup_list(True)
        self.disasmlist = DisassembleList(items)
        start_index = self.find_index(self.disasmblr.entry)
        if start_index != -1:
            self.disasmlist.set_focus(start_index)

        self.history = list()

        self.body = urwid.Padding(self.disasmlist, 'center', 105)
        self.body = urwid.Filler(self.body, ('fixed top',1), ('fixed bottom',1))

        self.footer = StatusBar("HotKeys -> g: Go to a address | s: Save | d: Remove | enter: Modify | q: Quit", self)
        self.view = DisassembleWindow(self,
                urwid.AttrWrap(self.body, 'body'),
                urwid.AttrWrap(self.header, 'head'),
                self.footer)

        signals.call_delay.connect(self.sig_call_delay) 
Example #8
Source File: cui.py    From hypermax with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def __init__(self, optimizer):
        self.optimizer = optimizer
        self.guidanceOptions = copy.deepcopy(optimizer.humanGuidedATPEOptimizer.guidanceOptions)

        self.parameterLockedValueEdits = {}
        self.parameterMinEdits = {}
        self.parameterMaxEdits = {}
        self.statusLabels = {}

        self.listWalker = urwid.SimpleListWalker(self.generateGrid())
        listbox = urwid.ListBox(self.listWalker)

        close_button = urwid.Button("Close")
        urwid.connect_signal(close_button, 'click',lambda button: self.close())

        buttons = urwid.Filler(urwid.Columns([close_button]))

        super(HumanGuidancePopup, self).__init__(makeMountedFrame(urwid.Pile([(5, buttons), listbox]), 'Apply Human Guidance'))

        self.optimizer = optimizer 
Example #9
Source File: ui.py    From yTermPlayer with GNU General Public License v3.0 6 votes vote down vote up
def input_screen(self,button):
        #overlay second screen after start case1
        txt=urwid.Text("Enter the URL below: ")
        url_field=urwid.Edit(caption='', edit_text='', multiline=False,
                            align='left', wrap='space', allow_tab=False,
                            edit_pos=None, layout=None, mask=None)
        btn=urwid.Button("OK",user_data=None)
        url_button = urwid.AttrMap(btn,None,focus_map='reversed')
        urwid.connect_signal(btn, 'click', self.input_url,url_field)
        wid=urwid.Pile([txt,url_field,url_button])
        new=urwid.Filler(urwid.AttrMap(wid, None, focus_map=''))
        ok_screen_box=urwid.LineBox(
                                    new, title='', title_align='center',
                                    tlcorner='┌', tline='─', lline='│',
                                    trcorner='┐', blcorner='└', rline='│',
                                    bline='─', brcorner='┘'
                                    )
        self.top.original_widget=ok_screen_box 
Example #10
Source File: destroy_confirm.py    From conjure-up with MIT License 6 votes vote down vote up
def _build_widget(self):
        applications = self.app.juju.client.applications
        total_items = [Instruction("Deployment Information:"), HR()]
        tbl = Pile([
            Columns([('fixed', 15, Text("Name")),
                     Text(self.model['name'])]),
            Columns([('fixed', 15, Text("Cloud")),
                     Text(self.model['cloud'])]),
            Columns([('fixed', 15, Text("Status")),
                     Text(self.model['status']['current'])]),
            Columns([('fixed', 15, Text("Online")),
                     Text(self._sanitize_date(
                         self.model['status']['since']))]),
            Columns([('fixed', 15, Text("Applications")),
                     Text(", ".join(applications.keys()))]),
            Columns([('fixed', 15, Text("Machines")),
                     Text(str(self._total_machines(self.model)))])

        ])
        total_items.append(tbl)
        total_items.append(HR())
        return Padding.center_80(Filler(Pile(total_items), valign='top')) 
Example #11
Source File: app.py    From toot with GNU General Public License v3.0 6 votes vote down vote up
def build_intro(self):
        font = urwid.font.Thin6x6Font()

        # NB: Padding with width="clip" will convert the fixed BigText widget
        # to a flow widget so it can be used in a Pile.

        big_text = "Toot {}".format(__version__)
        big_text = urwid.BigText(("intro_bigtext", big_text), font)
        big_text = urwid.Padding(big_text, align="center", width="clip")

        intro = urwid.Pile([
            big_text,
            urwid.Divider(),
            urwid.Text([
                "Maintained by ",
                ("intro_smalltext", "@ihabunek"),
                " and contributors"
            ], align="center"),
            urwid.Divider(),
            urwid.Text(("intro_smalltext", "Loading toots..."), align="center"),
        ])

        return urwid.Filler(intro) 
Example #12
Source File: cui.py    From hypermax with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def create_pop_up(self):
        pop_up = self.type
        urwid.connect_signal(pop_up, 'close', lambda button: self.close_pop_up())
        return urwid.AttrWrap(urwid.Filler(urwid.Padding(pop_up, 'center', width=self.size[0]), height=self.size[1]), 'background') 
Example #13
Source File: gui.py    From wsstat with MIT License 5 votes vote down vote up
def __init__(self):
        self.top_string = urwid.Text('')
        self.bottom_string  = urwid.Text('')

        self.small_blinks = urwid.Filler(self.top_string, 'top')
        self.large_blinks = ('weight', 10, urwid.Filler(self.bottom_string, 'top'))

        self.default_widget = urwid.LineBox(
            urwid.Pile([
                self.large_blinks
            ]),
            title='Websockets'
        ) 
Example #14
Source File: test_container.py    From anyMesh-Python with MIT License 5 votes vote down vote up
def test_get_cursor_coords(self):
        self.assertEqual(urwid.Overlay(urwid.Filler(urwid.Edit()),
            urwid.SolidFill(u'B'),
            'right', 1, 'bottom', 1).get_cursor_coords((2,2)), (1,1)) 
Example #15
Source File: sncli.py    From sncli with MIT License 5 votes vote down vote up
def gui_clear(self):
        self.sncli_loop.widget = urwid.Filler(urwid.Text(''))
        self.sncli_loop.draw_screen() 
Example #16
Source File: app.py    From usolitaire with MIT License 5 votes vote down vote up
def main():
    import argparse
    parser = argparse.ArgumentParser(description=__doc__)
    parser.parse_args()

    app = GameApp()
    loop = urwid.MainLoop(
        urwid.Filler(app.main_layout, valign='top'),
        PALETTE,
        unhandled_input=exit_on_q,
    )
    loop.run() 
Example #17
Source File: cui.py    From hypermax with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def __init__(self, optimizer):
        header = urwid.Text("Where would you like to save?")

        self.edit = urwid.Edit(edit_text=os.path.join(os.getcwd(), "parameters.json"))

        save_button = urwid.Button("Save")
        close_button = urwid.Button("Cancel")
        urwid.connect_signal(close_button, 'click',lambda button: self._emit("close"))
        urwid.connect_signal(save_button, 'click',lambda button: self.saveResults())

        pile = urwid.Pile([header, urwid.Text('\n'), self.edit,urwid.Text(''), urwid.Columns([save_button, close_button])])
        fill = urwid.Filler(pile)
        super(ExportParametersPopup, self).__init__(makeMountedFrame(fill, 'Export File'))

        self.optimizer = optimizer 
Example #18
Source File: cui.py    From hypermax with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def __init__(self, optimizer):
        header = urwid.Text("Where would you like to save?")

        self.edit = urwid.Edit(edit_text=os.path.join(os.getcwd(), "results.csv"))

        save_button = urwid.Button("Save")
        close_button = urwid.Button("Cancel")
        urwid.connect_signal(close_button, 'click',lambda button: self._emit("close"))
        urwid.connect_signal(save_button, 'click',lambda button: self.saveResults())

        pile = urwid.Pile([header, urwid.Text('\n'), self.edit,urwid.Text(''), urwid.Columns([save_button, close_button])])
        fill = urwid.Filler(pile)
        super(ExportCSVPopup, self).__init__(makeMountedFrame(fill, 'Export File'))

        self.optimizer = optimizer 
Example #19
Source File: cui.py    From hypermax with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def makeMountedFrame(widget, header):
    content = urwid.Padding(urwid.Filler(widget, height=('relative', 100), top=1, bottom=1), left=1, right=1)
    body = urwid.Frame(urwid.AttrWrap(content, 'frame_body'), urwid.AttrWrap(urwid.Text('  ' + header), 'frame_header'))
    shadow = urwid.Columns(
        [body, ('fixed', 2, urwid.AttrWrap(urwid.Filler(urwid.Text(('background', '  ')), "top"), 'shadow'))])
    shadow = urwid.Frame(shadow, footer=urwid.AttrWrap(urwid.Text(('background', '  ')), 'shadow'))
    padding = urwid.AttrWrap(
        urwid.Padding(urwid.Filler(shadow, height=('relative', 100), top=1, bottom=1), left=1, right=1), 'background')
    return padding 
Example #20
Source File: cui.py    From hypermax with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def __init__(self, optimizer):

        matrix, labels = optimizer.resultsAnalyzer.computeCorrelations(optimizer)

        columns = [DataTableColumn('field', label='field', width=16, align="right", attr="body", padding=0)]
        for label in labels:
            column = DataTableColumn(label, label=label, width=16, align="right", attr="body", padding=0)
            columns.append(column)

        data = []
        for index, row in enumerate(matrix):
            rowData = {
                'field': labels[index]
            }

            for labelIndex, label in enumerate(labels):
                rowData[label] = row[labelIndex]

            data.append(rowData)

        self.data = data
        self.labels = labels

        table = ScrollableDataTable(columns = columns, data=data)

        close_button = urwid.Button("Cancel")
        urwid.connect_signal(close_button, 'click',lambda button: self._emit("close"))

        export_button = urwid.Button("Export")
        urwid.connect_signal(export_button, 'click',lambda button: self.exportCorrelations())

        buttons = urwid.Filler(urwid.Columns([close_button, export_button]))

        super(CorrelationGridPopup, self).__init__(makeMountedFrame(urwid.Pile([(5, buttons), table]), 'Export File'))

        self.optimizer = optimizer 
Example #21
Source File: host_credentials.py    From ceph-ansible-copilot with GNU Lesser General Public License v2.1 5 votes vote down vote up
def render_page(self):

        w = urwid.Pile([
                  urwid.Padding(urwid.Text(self.text),
                                left=1, right=1),
                  urwid.Divider(),
                  urwid.Padding(
                    urwid.Columns([
                        ("fixed", 20, self.enable_password),
                        ("fixed", 22, self.common_password)
                        ]),
                    left=1),
                  urwid.Divider(),
                  urwid.Padding(
                      urwid.Columns([
                          ("weight", 3, urwid.Pile([
                              self.pending_table_title,
                              urwid.BoxAdapter(
                                urwid.Frame(self.pending_table,
                                            header=self.pending_table_headings),
                                10),
                          ])),
                          ("weight", 1, urwid.Pile([
                              self.sshok_table_title,
                              urwid.BoxAdapter(
                                  urwid.Frame(self.sshok_table,
                                              header=self.sshok_table_headings),
                                  10),
                          ]))
                      ], dividechars=1),
                      left=1),
                  self.check_btn
              ])

        w.focus_position = 5                # the Check button widget

        return urwid.AttrMap(
                 urwid.Filler(w, valign='top', top=1),
                 "active_step") 
Example #22
Source File: has_modal.py    From Discurses with MIT License 5 votes vote down vote up
def open_text_prompt(self, callback, title="", content=""):
        self.open_pop_up(
            urwid.Filler(TextEditWidget(
                callback, content=content)),
            header=urwid.Text(
                title, align='center'),
            height=6,
            width=50) 
Example #23
Source File: defaultFrame.py    From TerminusBrowser with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def __init__(self, welcome=False, test=False):
        self.headerString = 'TerminusBrowser'
        self.footerStringRight = f''
        self.url = 'Welcome Screen'

        if welcome:
            welcomeText = pyfiglet.figlet_format('TerminusBrowser') + '\nRecent Commits:\n'

            if not test:
                r = requests.get('https://api.github.com/repos/wtheisen/TerminusBrowser/commits')
                data = r.json()

                count = 0
                for cData in data:
                    commit = cData['commit']
                    cleanMessage = commit['message'].replace('\r', '').replace('\n\n', '\n')
                    welcomeText += f'\n {commit["author"]["name"]}: {cleanMessage}'

                    if count < 4:
                        count += 1
                    else:
                        break

            self.contents = urwid.Text(welcomeText, 'center')
        else:
            self.contents = urwid.Text('')

        self.contents = urwid.Filler(self.contents)
        urwid.WidgetWrap.__init__(self, self.contents) 
Example #24
Source File: finished.py    From ceph-ansible-copilot with GNU Lesser General Public License v2.1 5 votes vote down vote up
def render_page(self):
        return urwid.AttrMap(
                 urwid.Filler(
                   urwid.Pile([
                     urwid.Padding(urwid.Text(self.title), left=2),
                     urwid.Divider(),
                     urwid.Padding(urwid.Text(self.text), left=2, right=2),
                     urwid.Divider(),
                     self.btn]),
                   valign='top', top=1),
                 'active_step') 
Example #25
Source File: base.py    From ceph-ansible-copilot with GNU Lesser General Public License v2.1 5 votes vote down vote up
def render_page(self):
        pb = urwid.Pile([
               urwid.AttrMap(
                 urwid.Filler(
                   urwid.LineBox(
                     urwid.ProgressBar('pg_normal', 'pg_complete',
                                       current=self.done, done=self.complete),
                     title="Probing hosts")),
                 'pg_normal')])

        w = urwid.Overlay(pb, self.bottom_w, align='center', valign='top',
                          width=60, height=5, top=5)
        return w 
Example #26
Source File: breadcrumbs.py    From ceph-ansible-copilot with GNU Lesser General Public License v2.1 5 votes vote down vote up
def breadcrumbs(self):
        return urwid.AttrMap(
                 urwid.Filler(
                   urwid.Pile(self._build_sections()),
                   valign='top', top=1),
                 'inactive_step') 
Example #27
Source File: welcome.py    From ceph-ansible-copilot with GNU Lesser General Public License v2.1 5 votes vote down vote up
def render_page(self):
        return urwid.AttrMap(
            urwid.Filler(urwid.Pile([urwid.Padding(urwid.Text(self.text),
                                                   left=2, right=2),
                                     urwid.Divider(),
                                     self.next_btn]),
                         valign='top', top=1),
            'active_step') 
Example #28
Source File: host_validation.py    From ceph-ansible-copilot with GNU Lesser General Public License v2.1 5 votes vote down vote up
def render_page(self):

        table_headings = [(3, urwid.Text('Sel')),
                          (4, urwid.Text('Role')),
                          (12, urwid.Text('Hostname')),
                          (4, urwid.Text('CPU ')),
                          (3, urwid.Text('RAM')),
                          (3, urwid.Text('NIC')),
                          (3, urwid.Text('HDD')),
                          (3, urwid.Text('SSD')),
                          (4, urwid.Text('Size')),
                          (8, urwid.Text('Status'))]

        table_header = urwid.Columns(table_headings, 1)

        self.table = urwid.ListBox(self.table_body)

        results = urwid.Padding(
                    urwid.BoxAdapter(
                        urwid.LineBox(
                            urwid.Frame(self.table,
                                        header=table_header,
                                        footer=self.table_footer),
                            title="Host Configuration"),
                        13),
                    left=1,
                    right=1)

        return urwid.AttrMap(
                 urwid.Filler(
                   urwid.Pile([
                               urwid.Padding(urwid.Text(self.text),
                                             left=2, right=2),
                               self.probe_btn,
                               urwid.Divider(),
                               results,
                               self.next_btn]),
                   valign='top', top=1),
                 'active_step') 
Example #29
Source File: deploy.py    From ceph-ansible-copilot with GNU Lesser General Public License v2.1 5 votes vote down vote up
def render_page(self):

        failure_lb = urwid.ListBox(self.failure_list_w)

        return urwid.AttrMap(
                 urwid.Filler(
                       urwid.Pile([
                         urwid.Padding(urwid.Text(self.text),
                                       left=2, right=2),
                         self.button_row,
                         urwid.Divider(),
                         urwid.Padding(
                             urwid.Pile([
                               urwid.Columns([
                                   (6, urwid.Text("Task:")),
                                   self.task_info_w
                               ]),
                               urwid.Columns([
                                 urwid.Text("\nProgress", align='left'),
                                 urwid.Pile([
                                   urwid.Text('Complete', align='center'),
                                   self.success_w]),
                                 urwid.Pile([
                                   urwid.Text("Skipped", align='center'),
                                   self.skipped_w]),
                                 urwid.Pile([
                                   urwid.Text("Failures", align='center'),
                                   self.failed_w]),
                                 urwid.Pile([
                                   urwid.Text("Unreachable", align='center'),
                                   self.unreachable_w])
                                 ])]), left=2, right=2),
                       urwid.Divider(),
                       urwid.Padding(self.failure_title_w, left=2),
                       urwid.Padding(
                           urwid.BoxAdapter(failure_lb, 10),
                           left=2)]),
                   valign='top', top=1),
                 'active_step') 
Example #30
Source File: gui.py    From TWchat with MIT License 5 votes vote down vote up
def createLoop(self):
        placeholder = urwid.SolidFill()
        urwid.set_encoding("UTF-8")
        self.loop = urwid.MainLoop(placeholder,self.palette,unhandled_input=exit_on_alt_q)
        self.loop.screen.set_terminal_properties(colors=256)
        self.loop.widget = urwid.AttrMap(placeholder, 'bg')
        self.loop.widget.original_widget = urwid.Filler(self.createLayout())
        self.loop.run()