当前位置: 首页>>代码示例>>Python>>正文


Python urwid.GridFlow方法代码示例

本文整理汇总了Python中urwid.GridFlow方法的典型用法代码示例。如果您正苦于以下问题:Python urwid.GridFlow方法的具体用法?Python urwid.GridFlow怎么用?Python urwid.GridFlow使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在urwid的用法示例。


在下文中一共展示了urwid.GridFlow方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import GridFlow [as 别名]
def __init__(self, controller: Any, question: Any,
                 success_callback: Callable[[], bool]):
        self.controller = controller
        self.success_callback = success_callback
        yes = urwid.Button('Yes', self.exit_popup_yes)
        no = urwid.Button('No', self.exit_popup_no)
        yes._w = urwid.AttrMap(urwid.SelectableIcon(
            'Yes', 4), None, 'selected')
        no._w = urwid.AttrMap(urwid.SelectableIcon(
            'No', 4), None, 'selected')
        display_widget = urwid.GridFlow([yes, no], 3, 5, 1, 'center')
        wrapped_widget = urwid.WidgetWrap(display_widget)
        prompt = urwid.LineBox(
            urwid.ListBox(
                urwid.SimpleFocusListWalker(
                    [question, urwid.Divider(), wrapped_widget]
                )))
        urwid.Overlay.__init__(self, prompt, self.controller.view,
                               align="left", valign="top",
                               width=self.controller.view.LEFT_WIDTH + 1,
                               height=8) 
开发者ID:zulip,项目名称:zulip-terminal,代码行数:23,代码来源:views.py

示例2: __init__

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import GridFlow [as 别名]
def __init__(self, model, metadata, value, legend=None):
        blist = []
        glist = []
        maxl = 0
        for num, name in types.ValueType.get_choices():
            maxl = max(maxl, len(name))
            b = urwid.RadioButton(blist, name, False, user_data=num)
            b.value = num
            glist.append(AM(b, 'enumbuttn','buttnf'))
        # set the right value
        for b in blist:
            if b.value == value:
                b.state = True
        self.wid = urwid.GridFlow(glist, maxl+4, 1, 0, 'left')
        self.blist = blist
        self.__super.__init__(self._col_creator(metadata, self.wid, legend)) 
开发者ID:kdart,项目名称:pycopia,代码行数:18,代码来源:widgets.py

示例3: build

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import GridFlow [as 别名]
def build(self):
        self._showeq = urwid.Text("")
        eqi = self._create_equipment_input()
        maxlen = 0
        uutcb = urwid.CheckBox("DUT/UUT", state=False)
        urwid.connect_signal(uutcb, 'change', self._uut_select)
        blist = [AM(uutcb, "important")]
        for role in self._roles:
            label = str(role)
            maxlen = max(len(label), maxlen)
            but = urwid.CheckBox(str(role), state=False)
            urwid.connect_signal(but, 'change', self._multi_select, role)
            blist.append(but)
        roleboxes = urwid.Padding(urwid.GridFlow(blist, maxlen+4, 1, 0, "left"))
        # buttons
        ok, cancel = self.get_form_buttons()
        buts = urwid.Columns([(10, ok), (10, cancel)], dividechars=1, focus_column=0)
        return urwid.ListBox(urwid.SimpleListWalker([eqi, AM(self._showeq, "flagged"), roleboxes, buts])) 
开发者ID:kdart,项目名称:pycopia,代码行数:20,代码来源:widgets.py

示例4: get_form_buttons

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import GridFlow [as 别名]
def get_form_buttons(self, defaultdata=None, create=False):
        ok = urwid.Button("OK")
        urwid.connect_signal(ok, 'click', self._ok, defaultdata)
        ok = AM(ok, 'selectable', 'butfocus')
        cancel = urwid.Button("Cancel")
        urwid.connect_signal(cancel, 'click', self._cancel)
        cancel = AM(cancel, 'selectable', 'butfocus')
        l = [ok, cancel]
        if create:
            ok_edit = urwid.Button("OK and Edit")
            urwid.connect_signal(ok_edit, 'click', self._ok_and_edit, defaultdata)
            ok_edit = AM(ok_edit, 'selectable', 'butfocus')
            l = [ok, ok_edit, cancel]
        else:
            l = [ok, cancel]
        butgrid = urwid.GridFlow(l, 15, 3, 1, 'center')
        return urwid.Pile([urwid.Divider(), butgrid ], focus_item=1) 
开发者ID:kdart,项目名称:pycopia,代码行数:19,代码来源:widgets.py

示例5: init_footer

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import GridFlow [as 别名]
def init_footer(listbox):
    connect_button = FooterButton(u"\u23ce", "Connect", "enter", lambda button: button.on_click(listbox.get_focus()))
    sshkey_button = FooterButton("F3", "Copy SSH Key", "f3", lambda button: button.on_click(listbox.get_focus()))
    mc_button = FooterButton("F5", "Browse", "f5", lambda button: button.on_click(listbox.get_focus()))
    add_folder_button = FooterButton("F6", "New Folder", "f6", lambda button: button.on_click(listbox.get_focus()))
    add_button = FooterButton("F7", "New Conn.", "f7", lambda button: button.on_click(listbox.get_focus()))
    delete_button = FooterButton("F8", "Remove", "f8", lambda button: button.on_click(listbox.get_focus()))
    edit_button = FooterButton("F9", "Edit", "f9", lambda button: button.on_click(listbox.get_focus()))
    quit_button = FooterButton("Q", "Quit", "q", lambda button: button.on_click(listbox.get_focus()))
    # TODO keys that dont depend on selected node should be handled differently

    return urwid.GridFlow([connect_button,
                           sshkey_button,
                           mc_button,
                           # TODO join add buttons to one
                           add_folder_button,
                           add_button,
                           delete_button,
                           edit_button,
                           quit_button], 18, 1, 0, 'center') 
开发者ID:taypo,项目名称:redial,代码行数:22,代码来源:footer.py

示例6: buildFrame

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import GridFlow [as 别名]
def buildFrame(self, board):
        '''returns the board widget'''

        threadButtonList = []

        for title, l, s, c, t  in self.titles.items():
            if self.uFilter:
                if re.search(self.uFilter.lower(), title.lower()):
                    threadButton = urwid.Button(str(l), self.changeFrameThread)
                    threadInfo = urwid.Text(self.info_text.format(str(s),str(c)))
                    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(l), self.changeFrameThread)
                threadInfo = urwid.Text(self.info_text.format(str(s),str(c)))
                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] 
开发者ID:wtheisen,项目名称:TerminusBrowser,代码行数:26,代码来源:storyFrame.py

示例7: buildFrame

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import GridFlow [as 别名]
def buildFrame(self):
        boardButtons = []
        for subreddit in self.subredditList:
            subreddit = '/r/' + subreddit if not subreddit.startswith('/r/') else subreddit
            if self.uFilter:
                if self.uFilter.lower() in subreddit.lower():
                    boardButtons.append(urwid.LineBox(urwid.AttrWrap(urwid.Button(subreddit, self.changeFrameBoard), 'center')))
            else:
                boardButtons.append(urwid.LineBox(urwid.AttrWrap(urwid.Button(subreddit, self.changeFrameBoard), 'center')))

        self.parsedItems = len(boardButtons)
        width = len(max(self.subredditList, 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)) 
开发者ID:wtheisen,项目名称:TerminusBrowser,代码行数:18,代码来源:indexFrame.py

示例8: buildFrame

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import GridFlow [as 别名]
def buildFrame(self, board):
        '''returns the board widget'''

        threadButtonList = []

        for threadNumber, threadInfo in self.threadsDict.items():
            title = str(threadInfo[0]).replace('-', ' ')
            if self.uFilter:
                if re.search(self.uFilter.lower(), title.lower()):
                    threadButton = urwid.Button(str(threadNumber), 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(threadNumber), 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 urwid.Pile([listbox]) 
开发者ID:wtheisen,项目名称:TerminusBrowser,代码行数:27,代码来源:chanBoardBuilder.py

示例9: test_focus_path

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import GridFlow [as 别名]
def test_focus_path(self):
        # big tree of containers
        t = urwid.Text(u'x')
        e = urwid.Edit(u'?')
        c = urwid.Columns([t, e, t, t])
        p = urwid.Pile([t, t, c, t])
        a = urwid.AttrMap(p, 'gets ignored')
        s = urwid.SolidFill(u'/')
        o = urwid.Overlay(e, s, 'center', 'pack', 'middle', 'pack')
        lb = urwid.ListBox(urwid.SimpleFocusListWalker([t, a, o, t]))
        lb.focus_position = 1
        g = urwid.GridFlow([t, t, t, t, e, t], 10, 0, 0, 'left')
        g.focus_position = 4
        f = urwid.Frame(lb, header=t, footer=g)

        self.assertEqual(f.get_focus_path(), ['body', 1, 2, 1])
        f.set_focus_path(['footer']) # same as f.focus_position = 'footer'
        self.assertEqual(f.get_focus_path(), ['footer', 4])
        f.set_focus_path(['body', 1, 2, 2])
        self.assertEqual(f.get_focus_path(), ['body', 1, 2, 2])
        self.assertRaises(IndexError, lambda: f.set_focus_path([0, 1, 2]))
        self.assertRaises(IndexError, lambda: f.set_focus_path(['body', 2, 2]))
        f.set_focus_path(['body', 2]) # focus the overlay
        self.assertEqual(f.get_focus_path(), ['body', 2, 1]) 
开发者ID:AnyMesh,项目名称:anyMesh-Python,代码行数:26,代码来源:test_container.py

示例10: __init__

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import GridFlow [as 别名]
def __init__(self, on_press_function):
        add_button = urwid.Button("Add", on_press=on_press_function)
        cancel_button = urwid.Button("X Cancel", on_press=lambda button:self._emit("close"))

        pile = urwid.Pile([urwid.Text(
            "^^  I'm attached to the widget that opened me. "
            "Try resizing the window!\n"),
            urwid.GridFlow([add_button, cancel_button],15, 3, 1, 'center')
            ])
        fill = urwid.Filler(pile)
        self.__super.__init__(urwid.AttrWrap(fill, 'popbg')) 
开发者ID:AlexisTM,项目名称:flyingros,代码行数:13,代码来源:urwid_app.py

示例11: initAll

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import GridFlow [as 别名]
def initAll(self):
    self.tasksWidget = list()
    self.taskWalker = urwid.SimpleListWalker(self.tasksWidget)
    self.taskListbox = urwid.ListBox(self.taskWalker)

    self.taskHeader = urwid.AttrWrap(urwid.Text(["Task list"],  align='center'), 'taskheader')
    self.taskView = urwid.Frame(urwid.AttrWrap(self.taskListbox, 'body'), header=self.taskHeader)

    ### Control widgets
    self.blank = urwid.Divider()

    self.spinningText = urwid.Text("SPINNING (is on automated task mode)", align='center')
    self.spinningButton = urwid.Button("Switch spinning OFF", self.spin_switch)


    self.control_content = [
        self.blank,
        self.spinningText,
        urwid.Text("This is another content"), self.blank,self.blank,

        urwid.GridFlow(
            [urwid.AttrWrap(urwid.Button("Update mission",  self.update_mission), 'button'),
            urwid.AttrWrap(self.spinningButton, 'button'),
            urwid.AttrWrap(urwid.Button("This is a button"), 'button'),
            urwid.AttrWrap(urwid.Button("This is a button"), 'button'),
            urwid.AttrWrap(urwid.Button("This is a button"), 'button')]
        ,15, 3, 1, 'center')]

    self.controlListBox = urwid.ListBox(self.control_content)
    self.controlHeader = urwid.AttrWrap(urwid.Text(["Controller"],  align='center'), 'header')
    self.controlView = urwid.Frame(urwid.AttrWrap(self.controlListBox, 'body'), header=self.controlHeader)
    #view = urwid.Frame(urwid.AttrWrap(columns, 'body'), header=header)

    self.columns = urwid.Columns([self.controlView, self.taskView]) 
开发者ID:AlexisTM,项目名称:flyingros,代码行数:36,代码来源:urwid_app.py

示例12: build

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import GridFlow [as 别名]
def build(self):
        bt = urwid.BigText("Test Case Manager", urwid.HalfBlock5x4Font())
        bt = urwid.Padding(bt, "center", None)
        # Primary functions
        menulist = [
                widgets.MenuItemWidget("Run Test Code", self.do_run),
                widgets.MenuItemWidget("Run Test Job", self.do_job),
        ]
        pmenu = urwid.GridFlow(menulist, 20, 2, 1, "left")
        # heading blurb
        subhead = urwid.AttrMap(urwid.Text("Choose your desired activity."), "subhead")
        divider = urwid.Divider(u"-", top=1, bottom=1)
        formlist = [bt, divider, subhead, pmenu]
        listbox = urwid.ListBox(urwid.SimpleListWalker(formlist))
        return urwid.Frame(listbox) 
开发者ID:kdart,项目名称:pycopia,代码行数:17,代码来源:main.py

示例13: __init__

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import GridFlow [as 别名]
def __init__(self, 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))
        self._grid = grid
        self._content = Scrollable(grid)

        super().__init__(urwid.AttrMap(
            ScrollBar(urwid.AttrMap(self._content, 'torrentdetails')),
            'torrentdetails.scrollbar'
        ))

        # Register new request in request pool
        keys = set(('name',)).union(key for w in sections for key in w.needed_keys)
        self._poller = objects.srvapi.create_poller(objects.srvapi.torrent.torrents, (tid,), keys=keys)
        self._poller.on_response(self._handle_response)
        self._poller.on_error(self._handle_error) 
开发者ID:rndusr,项目名称:stig,代码行数:36,代码来源:details.py

示例14: show

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import GridFlow [as 别名]
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 
开发者ID:taypo,项目名称:redial,代码行数:42,代码来源:dialog.py

示例15: buildFrame

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import GridFlow [as 别名]
def buildFrame(self):
        boardButtons = []
        for board in self.boardList:
            if self.uFilter:
                if self.uFilter.lower() in board.lower():
                    boardButtons.append(urwid.LineBox(urwid.AttrWrap(urwid.Button(board, self.changeFrameBoard), 'center')))
            else:
                boardButtons.append(urwid.LineBox(urwid.AttrWrap(urwid.Button(board, self.changeFrameBoard), 'center')))

        self.parsedItems = len(boardButtons)
        buttonGrid = urwid.GridFlow(boardButtons, 12, 2, 2, 'center')
        listbox_content = [buttonGrid]

        return urwid.ListBox(urwid.SimpleListWalker(listbox_content)) 
开发者ID:wtheisen,项目名称:TerminusBrowser,代码行数:16,代码来源:indexFrame.py


注:本文中的urwid.GridFlow方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。