當前位置: 首頁>>代碼示例>>Python>>正文


Python urwid.Button方法代碼示例

本文整理匯總了Python中urwid.Button方法的典型用法代碼示例。如果您正苦於以下問題:Python urwid.Button方法的具體用法?Python urwid.Button怎麽用?Python urwid.Button使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在urwid的用法示例。


在下文中一共展示了urwid.Button方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: edit

# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import Button [as 別名]
def edit(title):
    try:
        text, verify = wiki.init_edit(title)
        wiki.login()

        newtext = runEditor(text)
        if newtext == text:
            ex.notify('Edit Canceled: No Change')
            return

        def submit(button):
            closeOverlay()
            wiki.commit_edit(newtext, summary.edit_text,
                             minor.get_state(), verify)
            openPage(title)
        def cancel(button):
            closeOverlay()
        summary = urwid.Edit('Summary: ')
        minor = urwid.CheckBox('Minor Edit')
        cancel_button = urwid.Button('Cancel', cancel)
        submit_button = urwid.Button('Submit', submit)
        pile = urwid.Pile([summary, minor, cancel_button, submit_button])
        openOverlay(pile, 'Edit', 'pack')
    except WikiError as e:
        ex.notify('Error: ' + str(e)) 
開發者ID:ids1024,項目名稱:wikicurses,代碼行數:27,代碼來源:main.py

示例2: __init__

# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import Button [as 別名]
def __init__(self, key=None, value=('', '')):
        self.trigger = key
        self.yn = value[0]
        self.yn_but = MyButton([('attention', 'Use proxy: '), self.yn], self.on_change)
        self.input_addr = urwid.Edit(('attention', u' \N{BULLET} Address  : '), edit_text=value[1], wrap='clip')
        self.input_port = urwid.IntEdit(('attention', u' \N{BULLET} Port     : '), default=value[2])
        self.input_port.set_wrap_mode('clip')
        exit_but = urwid.Padding(urwid.Button('OKay'.center(8), self.item_callback), 'center', 12)

        widgets = [self.yn_but] \
                  + [urwid.AttrMap(wid, None, 'popbgs') for wid in (self.input_addr, self.input_port, exit_but)]

        self.pile = urwid.Pile(widgets)
        fill = urwid.LineBox(urwid.Filler(self.pile))
        self.__super.__init__(urwid.AttrWrap(fill, 'popbg'))

        self.chosen = value 
開發者ID:Dragon2fly,項目名稱:vpngate-with-proxy,代碼行數:19,代碼來源:ui_elements.py

示例3: __init__

# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import Button [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

示例4: build

# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import Button [as 別名]
def build(self):
        wlist = []
        addnew = urwid.Button("Add")
        urwid.connect_signal(addnew, 'click', self._add_new_option)
        addnew = urwid.AttrWrap(addnew, 'selectable', 'butfocus')
        wlist.append(addnew)
        for attrib in getattr(self.row, self.metadata.colname): # list-like attribute
            entry = ListEntry(urwid.Columns(
                    [(30, urwid.Text(str(attrib.type))),
                     urwid.Text(unicode(attrib.value).encode("utf-8"))]))
            entry.attrname = attrib.type.name
            urwid.connect_signal(entry, 'activate', self._edit_option)
            urwid.connect_signal(entry, 'delete', self._delete)
            wlist.append(entry)
        listbox = urwid.ListBox(urwid.SimpleFocusListWalker(wlist))
        return urwid.BoxAdapter(urwid.LineBox(listbox), max(7, len(wlist)+2)) 
開發者ID:kdart,項目名稱:pycopia,代碼行數:18,代碼來源:widgets.py

示例5: _create_relation_input

# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import Button [as 別名]
def _create_relation_input(self):
        choices = dict(models.get_choices(self.session, self.modelclass, self.metadata.colname, None))
        addnew = urwid.Button("Add New")
        urwid.connect_signal(addnew, 'click', self._add_new_related)
        # Cancel
        canc = urwid.Button("Cancel")
        urwid.connect_signal(canc, 'click', self._cancel)
        butcol = urwid.Columns([AM(addnew, "buttn", "buttnf"), AM(canc, "buttn", "buttnf")])
        wlist = [butcol]
        if self.metadata.nullable:
            entry = ListEntry(urwid.Text("None (remove)"))
            urwid.connect_signal(entry, 'activate', self._single_select)
            wlist.append(entry)
        for pk, cname in choices.items():
            entry = ListEntry(urwid.Text(cname))
            urwid.connect_signal(entry, 'activate', self._single_select, pk)
            wlist.append(entry)
        listbox = urwid.ListBox(urwid.SimpleListWalker(wlist))
        return urwid.BoxAdapter(urwid.LineBox(listbox), 9) 
開發者ID:kdart,項目名稱:pycopia,代碼行數:21,代碼來源:widgets.py

示例6: build

# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import Button [as 別名]
def build(self):
        addnew = urwid.Button("Add")
        urwid.connect_signal(addnew, 'click', self._add_new_testequipment)
        addnew = urwid.AttrWrap(addnew, 'selectable', 'butfocus')
        wlist = [addnew]
        for te in getattr(self.environmentrow, self.metadata.colname): # list-like attribute
            entry = ListEntry( urwid.Text(self._stringify_te(te)))
            urwid.connect_signal(entry, 'activate', self._edit_testequipment)
            urwid.connect_signal(entry, 'delete', self._delete_testequipment)
            entry.testequipment = te
            if te.UUT:
                wlist.insert(1, entry)
            else:
                wlist.append(entry)
        listbox = urwid.ListBox(urwid.SimpleFocusListWalker(wlist))
        return urwid.BoxAdapter(urwid.LineBox(listbox), max(7, len(wlist)+2)) 
開發者ID:kdart,項目名稱:pycopia,代碼行數:18,代碼來源:widgets.py

示例7: get_form_buttons

# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import Button [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

示例8: __init__

# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import Button [as 別名]
def __init__(self, return_fn):

        self.return_fn = return_fn

        self.about_message = ABOUT_MESSAGE

        self.time_out_ctrl = urwid.Text(self.about_message)

        cancel_button = urwid.Button('Exit', on_press=self.on_cancel)
        cancel_button._label.align = 'center'

        if_buttons = urwid.Columns([cancel_button])

        title = urwid.Text(('bold text', u"  About Menu  \n"), 'center')

        self.titles = [title,
                       self.time_out_ctrl,
                       if_buttons]

        self.main_window = urwid.LineBox(ViListBox(self.titles)) 
開發者ID:amanusk,項目名稱:s-tui,代碼行數:22,代碼來源:about_menu.py

示例9: __init__

# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import Button [as 別名]
def __init__(self, return_fn):

        self.return_fn = return_fn

        self.help_message = HELP_MESSAGE

        self.time_out_ctrl = urwid.Text(self.help_message)

        cancel_button = urwid.Button(('Exit'), on_press=self.on_cancel)
        cancel_button._label.align = 'center'

        if_buttons = urwid.Columns([cancel_button])

        title = urwid.Text(('bold text', u"  Help Menu  \n"), 'center')

        self.titles = [title,
                       self.time_out_ctrl,
                       if_buttons]

        self.main_window = urwid.LineBox(ViListBox(self.titles)) 
開發者ID:amanusk,項目名稱:s-tui,代碼行數:22,代碼來源:help_menu.py

示例10: playlistitems

# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import Button [as 別名]
def playlistitems(title):
	global listitems
	bt_sv = urwid.Button("Save")
	urwid.connect_signal(bt_sv, 'click', showmenu)
	bt_ca = urwid.Button("Cancel")
	urwid.connect_signal(bt_ca, 'click', showmenu)
	bt_sa = urwid.Button("Select all")
	urwid.connect_signal(bt_sa, 'click', select_all)
	bt_da = urwid.Button("Deselect all")
	urwid.connect_signal(bt_da, 'click', deselect_all)
	footer = urwid.Columns([bt_sv, bt_sa, bt_da, bt_ca], 1)
	items = []
	for item in playlist_names:
		items.append(urwid.CheckBox(item['name'], is_selected(item['id']), on_state_change=checkbox_callback, user_data=item['id']))
	start.original_widget = TabFrame(urwid.ListBox(urwid.SimpleListWalker(items)), header=urwid.Text("Select Playlists"), footer=footer, focus_part='body')

# main menu button handler 
開發者ID:helpsterTee,項目名稱:spotify-playlists-2-deezer,代碼行數:19,代碼來源:spotify-restore.py

示例11: show_login

# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import Button [as 別名]
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)) 
開發者ID:vilmibm,項目名稱:tildemush,代碼行數:23,代碼來源:screens.py

示例12: start_screen

# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import Button [as 別名]
def start_screen(self):
        #Ovrlay top screen at start
        txt1_1=urwid.Button("New playlist [Enter URL]")
        urwid.connect_signal(txt1_1, 'click', self.input_screen)
        txt1 = urwid.AttrMap(txt1_1,None,focus_map='reversed')
        txt2_2=urwid.Button("Load saved playlist")
        urwid.connect_signal(txt2_2, 'click', self.load_list_screen)
        txt2 = urwid.AttrMap(txt2_2,None,focus_map='reversed')
        start_list=urwid.SimpleFocusListWalker([txt1,txt2])
        box=urwid.ListBox(start_list)
        selection=urwid.LineBox(
                                box, title='', title_align='center',
                                tlcorner='┌', tline='─', lline='│',
                                trcorner='┐', blcorner='└', rline='│',
                                bline='─', brcorner='┘'
                                )
        selection_with_padding=urwid.Padding(selection,left=2,right=2)
        return selection_with_padding 
開發者ID:TimeTraveller-San,項目名稱:yTermPlayer,代碼行數:20,代碼來源:ui.py

示例13: input_screen

# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import Button [as 別名]
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 
開發者ID:TimeTraveller-San,項目名稱:yTermPlayer,代碼行數:20,代碼來源:ui.py

示例14: load_list_screen

# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import Button [as 別名]
def load_list_screen(self,button):
        #overlay second screen after start case2
        txt=urwid.Text("Choose from the following:- ")
        _list=self.player_object.get_saved_lists()
        saved_list=[]
        for every_list in _list:
            b=urwid.Button(str(every_list).rstrip(),user_data=None)
            urwid.connect_signal(b, 'click', self.list_load)
            saved_list.append(urwid.AttrMap(b,None,focus_map='reversed'))
        box=urwid.ListBox(urwid.SimpleFocusListWalker(saved_list))
        list_box=urwid.LineBox(
                                box, title='', title_align='center',
                                tlcorner='┌', tline='─', lline='│',
                                trcorner='┐', blcorner='└', rline='│',
                                bline='─', brcorner='┘'
                                )
        list_box_padding=urwid.Padding(list_box,right=0,left=0)
        self.top.original_widget=list_box_padding 
開發者ID:TimeTraveller-San,項目名稱:yTermPlayer,代碼行數:20,代碼來源:ui.py

示例15: __init__

# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import Button [as 別名]
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')) 
開發者ID:wtheisen,項目名稱:TerminusBrowser,代碼行數:18,代碼來源:customUrwidClasses.py


注:本文中的urwid.Button方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。