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


Python urwid.Edit方法代码示例

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


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

示例1: edit

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Edit [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 Edit [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: keypress

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Edit [as 别名]
def keypress(self, size, key):
        keyl = key.lower()
        if key == "enter":
            app.remove_overlays()
            self.callback(self.value(), *self.args)

        elif keyl in ("q", "esc", "ctrl g", "ctrl c"):
            app.remove_overlays()

        elif keyl in ("down", "ctrl n", "n", "j"):
            self.incr("down")

        elif keyl in ("up", "ctrl p", "p", "k"):
            self.incr("up")

        else: # dont use super because we want to allow zeros in this box
            urwid.Edit.keypress(self, (size[0],), key) 
开发者ID:bbj-dev,项目名称:bbj,代码行数:19,代码来源:main.py

示例4: run

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Edit [as 别名]
def run(self):
        """
        prompt for text input.
        """
        # set up widgets
        leftpart = urwid.Text(self.arguments.prompt_text, align='left')
        editpart = urwid.Edit(multiline=True, edit_text=self.arguments.initial_text)

        # build promptwidget
        edit = urwid.Columns([
            ('fixed', len(self.arguments.prompt_text), leftpart),
            ('weight', 1, editpart),
        ])
        self.ui.prompt_bar = urwid.AttrMap(edit, "main_list_dg")

        self.ui.reload_footer()
        self.ui.set_focus("footer")

        urwid.connect_signal(editpart, "change", run_command_callback,
                             user_args=[self.ui, self.docker_object]) 
开发者ID:TomasTomecek,项目名称:sen,代码行数:22,代码来源:ui.py

示例5: get_form_buttons

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Edit [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

示例6: build

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Edit [as 别名]
def build(self):
        header = urwid.Pile([
                urwid.AttrMap(urwid.Text("Edit {}".format(self.modelclass.__name__)), "formhead"),
                urwid.AttrMap(urwid.Text("Arrow keys navigate, "
                        "Enter to select form button. Tab to switch to header."
                        "Type into other fields."), "formhead"),
                AM(urwid.Button("Copy from...", on_press=self._create_copy_input), "selectable", "butfocus"),
                urwid.Divider(),
                ])
        formstack = []
        for colname in ("name", "owner"):
            colmd = self.metadata[colname]
            wid = self.build_input(colmd, getattr(self.row, colmd.colname))
            formstack.append(wid)
        colmd = self.metadata["attributes"]
        wid = self.build_attribute_input(colmd, getattr(self.row, colmd.colname))
        formstack.append(wid)
        # test equipment
        colmd = self.metadata["testequipment"]
        tewid = self.build_testequipment_input(colmd, getattr(self.row, "testequipment"))
        formstack.append(tewid)
        # common buttons
        formstack.append(self.get_form_buttons())
        listbox = urwid.ListBox(urwid.SimpleListWalker(formstack))
        return urwid.Frame(urwid.AttrMap(listbox, 'body'), header=header) 
开发者ID:kdart,项目名称:pycopia,代码行数:27,代码来源:widgets.py

示例7: setUp

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Edit [as 别名]
def setUp(self):
        self.size = (80, 20)
        self.content = [
            urwid.ListBox(urwid.SimpleFocusListWalker([
                urwid.Edit('Field 1'),
                urwid.Edit('Field 2'),
            ])),

            urwid.ListBox(urwid.SimpleFocusListWalker([
                SelectableText('Row 1'),
                urwid.Edit('', 'Edit field 2'),
                SelectableText('Row 3'),
            ]))
        ]
        self.editbox = self.content[1].body[1]
        self.editbox.edit_pos = 0
        self.tabs = Tabs((urwid.Text('Edit fields'), self.content[0]),
                         (urwid.Text('empty'),),
                         (urwid.Text('Text rows'), self.content[1])) 
开发者ID:rndusr,项目名称:stig,代码行数:21,代码来源:tabs_test.py

示例8: test_abort_chain_with_builtin_key

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Edit [as 别名]
def test_abort_chain_with_builtin_key(self):
        self.km.bind('alt-1 alt-2 alt-3', 'foo')

        self.widget.keypress((80,), 'alt-1')
        self.assert_status(keys_given=('alt-1',),
                           widget_text='Original Text',
                           active_keychains=((('alt-1', 'alt-2', 'alt-3'), 'foo'),))

        # This would usually append 'x' to the Edit widget text, but we want it
        # to abort the started chain instead.
        self.widget.keypress((80,), 'x')
        self.assert_status(keys_given=(),
                           widget_text='Original Text',
                           active_keychains=())

        # Now we can change the text again
        self.widget.keypress((80,), 'x')
        self.assert_status(keys_given=(),
                           widget_text='Original Textx',
                           active_keychains=()) 
开发者ID:rndusr,项目名称:stig,代码行数:22,代码来源:keymap_test.py

示例9: input_screen

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Edit [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

示例10: __init__

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Edit [as 别名]
def __init__(self, caption="",
                 edit_text="", multiline=False,
                 align='left', wrap='any', allow_tab=False,
                 valid_chars=string.printable,
                 width=0):

        self.max_width = width
        self.valid_chars = valid_chars

        urwid.Edit.__init__(self,
                            caption=caption,
                            edit_text=edit_text,
                            multiline=multiline,
                            align=align,
                            wrap=wrap,
                            allow_tab=allow_tab) 
开发者ID:pcuzner,项目名称:ceph-ansible-copilot,代码行数:18,代码来源:base.py

示例11: keypress

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Edit [as 别名]
def keypress(self, size, key):
        key = super(SetupListBox, self).keypress(size, key)
        if key == 'enter':
            if self.focus_position > 2 and len(self.body[self.focus_position].edit_text) == 0:
                device_name = self.body[2].edit_text
                device_listens = []
                for index, item in enumerate(self.body):
                    if index > 2:
                        device_listens.append(item.edit_text)
                start_anymesh(device_name, device_listens)
                load_msg_frame()

            else:
                self.body.insert(self.focus_position + 1, urwid.Edit("Enter a keyword to listen to: "))
                self.focus_position += 1
        elif key == 'esc':
            raise urwid.ExitMainLoop() 
开发者ID:AnyMesh,项目名称:anyMesh-Python,代码行数:19,代码来源:demo.py

示例12: test2_cursor

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Edit [as 别名]
def test2_cursor(self):
        T, E = urwid.Text, urwid.Edit

        l1 = [T(""),T(""),T("\n"),E("","\n\nX"),T("\n"),T(""),T("")]
        l2 = [T(""),T(""),T("\n"),E("","YY\n\n"),T("\n"),T(""),T("")]

        l2[3].set_edit_pos(2)

        self.cvtest( "plain cursor in view",
            l1, 3, 1, (0,1), 1, (1,3) )

        self.cvtest( "cursor off top",
            l2, 3, 0, (1,3), 0, (2, 0) )

        self.cvtest( "cursor further off top",
            l2, 3, 0, (2,3), 0, (2, 0) )

        self.cvtest( "cursor off bottom",
            l1, 3, 3, (0,1), 2, (1, 4) )

        self.cvtest( "cursor way off bottom",
            l1, 3, 100, (0,1), 2, (1, 4) ) 
开发者ID:AnyMesh,项目名称:anyMesh-Python,代码行数:24,代码来源:test_listbox.py

示例13: test_move_cursor

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Edit [as 别名]
def test_move_cursor(self):
        e, s, x = urwid.Edit("",""),SelectableText(""), urwid.Text("")
        self.mctest("nothing selectbl",[x,x,x],1,(20,),9,0,False,0,None)
        self.mctest("dead on",[x,s,x],1,(20,),9,0,True,1,9)
        self.mctest("l edge",[x,s,x],1,(20,),6,0,True,1,6)
        self.mctest("r edge",[x,s,x],1,(20,),13,0,True,1,13)
        self.mctest("l off",[x,s,x],1,(20,),2,0,True,1,2)
        self.mctest("r off",[x,s,x],1,(20,),17,0,True,1,17)
        self.mctest("l off 2",[x,x,s],1,(20,),2,0,True,2,2)
        self.mctest("r off 2",[s,x,x],1,(20,),17,0,True,0,17)

        self.mctest("l between",[s,s,x],1,(20,),6,0,True,0,6)
        self.mctest("r between",[x,s,s],1,(20,),13,0,True,1,13)
        self.mctest("l between 2l",[s,s,x],2,(22,),6,0,True,0,6)
        self.mctest("r between 2l",[x,s,s],2,(22,),14,0,True,1,14)
        self.mctest("l between 2r",[s,s,x],2,(22,),7,0,True,1,7)
        self.mctest("r between 2r",[x,s,s],2,(22,),15,0,True,2,15)

        # unfortunate pref_col shifting
        self.mctest("l e edge",[x,e,x],1,(20,),6,0,True,1,7)
        self.mctest("r e edge",[x,e,x],1,(20,),13,0,True,1,12)

        # 'left'/'right' special cases
        self.mctest("right", [e, e, e], 0, (12,), 'right', 0, True, 2, 'right')
        self.mctest("left", [e, e, e], 0, (12,), 'left', 0, True, 0, 'left') 
开发者ID:AnyMesh,项目名称:anyMesh-Python,代码行数:27,代码来源:test_container.py

示例14: __init__

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Edit [as 别名]
def __init__(self):
        edit = Edit('Search: ')
        super(SearchEdit, self).__init__(edit, 'header') 
开发者ID:leejaycoke,项目名称:ec2-gazua,代码行数:5,代码来源:widget.py

示例15: __init__

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Edit [as 别名]
def __init__(self, p_todolist):
        self._todolist = p_todolist

        self.titleedit = urwid.Edit("Title: ", "")
        self.sortedit = urwid.Edit("Sort expression: ", "")
        self.groupedit = urwid.Edit("Group expression: ", "")
        self.filteredit = urwid.Edit("Filter expression: ", "")

        radiogroup = []
        self.relevantradio = urwid.RadioButton(radiogroup, "Only show relevant todo items", True)
        self.allradio = urwid.RadioButton(radiogroup, "Show all todo items")

        self.pile = urwid.Pile([
            self.filteredit,
            self.titleedit,
            self.sortedit,
            self.groupedit,
            self.relevantradio,
            self.allradio,
            urwid.Button("Save", lambda _: urwid.emit_signal(self, 'save')),
            urwid.Button("Cancel", lambda _: self.close()),
        ])

        self.reset()

        super().__init__(self.pile)

        urwid.register_signal(ViewWidget, ['save', 'close']) 
开发者ID:bram85,项目名称:topydo,代码行数:30,代码来源:ViewWidget.py


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