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


Python urwid.connect_signal函数代码示例

本文整理汇总了Python中urwid.connect_signal函数的典型用法代码示例。如果您正苦于以下问题:Python connect_signal函数的具体用法?Python connect_signal怎么用?Python connect_signal使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: __init__

    def __init__(self, revert_order, remove_bash_prefix, remove_zsh_prefix, regexp, case_sensitive,
                 remove_duplicates, show_hits, infile):

        self.show_hits = show_hits
        self.regexp_modifier = regexp
        self.case_modifier = case_sensitive
        self.remove_bash_prefix = remove_bash_prefix

        self.list_items = []

        if revert_order:
            lines = reversed(infile.readlines())
        else:
            lines = infile

        for line in lines:
            if remove_bash_prefix:
                line = line.split(None, 1)[1].strip()

            if remove_zsh_prefix:
                line = re.split('\s+', line, maxsplit=4)[-1]

            if 'selecta <(history)' not in line:
                if not remove_duplicates or line not in self.list_items:
                    self.list_items.append(line)

        self.list_item_widgets = []

        self.line_count_display = LineCountWidget('')
        self.search_edit = SearchEdit(edit_text='')

        self.modifier_display = urwid.Text('')

        urwid.connect_signal(self.search_edit, 'done', self.edit_done)
        urwid.connect_signal(self.search_edit, 'toggle_case_modifier', self.toggle_case_modifier)
        urwid.connect_signal(self.search_edit, 'toggle_regexp_modifier', self.toggle_regexp_modifier)
        urwid.connect_signal(self.search_edit, 'change', self.edit_change)

        header = urwid.AttrMap(urwid.Columns([
            urwid.AttrMap(self.search_edit, 'input', 'input'),
            self.modifier_display,
            ('pack', self.line_count_display),
        ], dividechars=1, focus_column=0), 'head', 'head')

        self.item_list = urwid.SimpleListWalker(self.list_item_widgets)
        self.listbox = ResultList(self.item_list)

        urwid.connect_signal(self.listbox, 'resize', self.list_resize)

        self.view = urwid.Frame(body=self.listbox, header=header)

        self.loop = urwid.MainLoop(self.view, palette, unhandled_input=self.on_unhandled_input)
        self.loop.screen.set_terminal_properties(colors=256)

        self.line_count_display.update(self.listbox.last_size, len(self.item_list))

        # TODO workaround, when update_list is called directly, the linecount widget gets not updated
        self.loop.set_alarm_in(0.01, lambda *loop: self.update_list(''))

        self.loop.run()
开发者ID:vindolin,项目名称:selecta,代码行数:60,代码来源:__init__.py

示例2: searchDialog

 def searchDialog(self, default):
     dialog = SearchDialog(self, default)
     urwid.connect_signal(dialog, 'cancel',
         lambda button: self.backScreen())
     urwid.connect_signal(dialog, 'search',
         lambda button: self._searchDialog(dialog))
     self.popup(dialog, min_width=76, min_height=8)
开发者ID:ahnan4arch,项目名称:gertty,代码行数:7,代码来源:app.py

示例3: editTopic

 def editTopic(self):
     dialog = view_change.EditTopicDialog(self.app, '')
     urwid.connect_signal(dialog, 'save',
         lambda button: self.closeEditTopic(dialog, True))
     urwid.connect_signal(dialog, 'cancel',
         lambda button: self.closeEditTopic(dialog, False))
     self.app.popup(dialog)
开发者ID:BruceZu,项目名称:gertty,代码行数:7,代码来源:change_list.py

示例4: _build_table

    def _build_table(self, ui_table):
        children = []

        for key, label in ui_table.items:
            c = self._build_tableitem(ui_table, key, label)
            children.append(c)
        widget = uw.TableWidget(ui_table.label(), ui_table.header,
                                children, ui_table.multi,
                                ui_table.height, ui_table.enabled())

        for c in children:
            c._table = widget

        if ui_table.multi:
            widget.selection(ui_table.selection())
        else:
            widget.focus(ui_table.selection())

        def on_change_cb(w, d=None):
            if ui_table.multi:
                ui_table.selection(widget.selection())
            else:
                ui_table.selection(w._key)

            ui_table.on_change({ui_table.path: w._key})

        urwid.connect_signal(widget, "changed", on_change_cb)

        def on_item_value_change_cb(p, v):
            # Update the selection in the ui.Element
            widget.selection(v)

        ui_table.on_value_change.connect(on_item_value_change_cb)

        return widget
开发者ID:Zealsathish,项目名称:ovirt-node,代码行数:35,代码来源:urwid_builder.py

示例5: quit

    def quit(self):
        dialog = mywid.YesNoDialog(u'Quit',
                                   u'Are you sure you want to quit?')
        urwid.connect_signal(dialog, 'no', self.backScreen)
        urwid.connect_signal(dialog, 'yes', self._quit)

        self.popup(dialog)
开发者ID:ahnan4arch,项目名称:gertty,代码行数:7,代码来源:app.py

示例6: __init__

    def __init__(self, notes_dir, editor, extension):

        self.editor = editor
        self.notebook = notebook.PlainTextNoteBook(notes_dir, extension)

        # Don't filter the note list when the text in the search box changes.
        self.suppress_filter = False

        # Don't change the focused note when normally it would change
        # (e.g. when the text in the search box changes)
        self.suppress_focus = False

        self._selected_note = None

        self.search_box = AutocompleteWidget(wrap="clip")
        self.list_box = NoteFilterListBox(on_changed=self.on_list_box_changed)

        urwid.connect_signal(self.search_box, "change",
                self.on_search_box_changed)

        super(MainFrame, self).__init__(
                header=urwid.LineBox(self.search_box),
                body=None,
                focus_part="body")

        # Add all the notes to the listbox.
        self.filter(self.search_box.edit_text)
开发者ID:dialelo,项目名称:terminal_velocity,代码行数:27,代码来源:urwid_ui.py

示例7: __init__

 def __init__(
         self, title, login,
         command_caption='Command: (Tab to switch focus to upper '
         'frame, where you can scroll text)\nType exit or quit '
         'to close', max_size=1000):
     self.header = urwid.Text(title)
     self.model = urwid.SimpleListWalker([])
     self.body = ListView(
         self.model, lambda: self._update_focus(False), max_size=max_size)
     self.input = Input(lambda: self._update_focus(True))
     foot = urwid.Pile([
         urwid.AttrMap(
             urwid.Text(command_caption),
             'reversed'),
         urwid.AttrMap(self.input, 'normal')])
     urwid.Frame.__init__(self,
                          urwid.AttrWrap(self.body, 'normal'),
                          urwid.AttrWrap(self.header, 'reversed'),
                          foot)
     self.set_focus_path(['footer', 1])
     self._focus = True
     urwid.connect_signal(self.input,
                          'line_entered',
                          self.on_line_entered)
     self._output_styles = [s[0] for s in self.PALLETE]
     self.eloop = None
     self.login = login
开发者ID:shubhodeep9,项目名称:GitChat,代码行数:27,代码来源:gitchat_ui.py

示例8: login

 def login(self):
     self.foot = LoginWidget('username: ')
     self.view.set_footer(self.foot)
     self.view.set_focus('footer')
     urwid.connect_signal(
         self.foot, 'login_authenticate', self.login_authenticate)
     urwid.connect_signal(self.foot, 'login_escaped', self.login_escaped)
开发者ID:eartsar,项目名称:malsnakes,代码行数:7,代码来源:malsnakes.py

示例9: query_username

 def query_username(self):
     self.foot = QueryWidget('username: ')
     self.view.set_footer(self.foot)
     self.view.set_focus('footer')
     urwid.connect_signal(
         self.foot, 'username_entered', self.username_entered)
     urwid.connect_signal(self.foot, 'query_escaped', self.query_escaped)
开发者ID:eartsar,项目名称:malsnakes,代码行数:7,代码来源:malsnakes.py

示例10: handle_trees

    def handle_trees(self):
        # Reset the focus and the last directory since we're viewing trees and not a single directory
        self.QGH.focus    = '/'
        self.QGH.last_dir = '' # Otherwise, we wouldn't be able to jump to dir view

        # Wipe all the elements and populate with trees only.
        self.QGH.elements = []
        all_trees = self.QGH.Parser.all_trees();

        # Construct an itemlist
        i = 0
        for directory in sorted(all_trees):
            element  = ItemWidget(i, directory + '/', self.QGH)
            self.QGH.elements.append(element)
            i = i+1

        # Set up the walker
        self.QGH.walker  = urwid.SimpleListWalker(self.QGH.elements)
        self.QGH.listbox = urwid.ListBox(self.QGH.walker)

        # Connect the signal so that we can update the header/footer later.
        urwid.connect_signal(self.QGH.walker, 'modified', self.QGH.update)

        # Fix the header
        self.QGH.view.set_header(urwid.AttrWrap(urwid.Columns([
            urwid.Text('/', align='left'), # fakeroot
            urwid.Text('%s item(s)' % (len(self.QGH.elements)), align='right')
        ]), 'head'))

        self.QGH.view.set_body(self.QGH.listbox)
开发者ID:infyhr,项目名称:qgh,代码行数:30,代码来源:tree.py

示例11: main

def main():
    term = urwid.Terminal(None)

    mainframe = urwid.LineBox(
        urwid.Pile([
            ('weight', 70, term),
            ('fixed', 1, urwid.Filler(urwid.Edit('focus test edit: '))),
        ]),
    )

    def set_title(widget, title):
        mainframe.set_title(title)

    def quit(*args, **kwargs):
        raise urwid.ExitMainLoop()

    def handle_key(key):
        if key in ('q', 'Q'):
            quit()

    urwid.connect_signal(term, 'title', set_title)
    urwid.connect_signal(term, 'closed', quit)

    loop = urwid.MainLoop(
        mainframe,
        handle_mouse=False,
        unhandled_input=handle_key)

    term.main_loop = loop
    loop.run()
开发者ID:andy-z,项目名称:urwid,代码行数:30,代码来源:terminal.py

示例12: build_widgets

    def build_widgets(self):
        title_text = Text([("body", self.name)],
                          align="center")

        desc_text = Text(["\n", strip_solo_dots(self.description)])

        self.reset_button = PlainButton("Reset to Default", self.do_reset)
        if self.optype == OptionType.BOOLEAN:
            self.control = CheckBox(self.name, state=bool(self.current_value))

        elif self.optype == OptionType.INT:
            self.control = IntEdit(caption="{}: ".format(self.name),
                                   default=self.current_value)
        elif self.optype == OptionType.STRING:
            edit_text = self.current_value or ""
            self.control = StringEditor(
                caption="{}: ".format(self.name),
                edit_text=edit_text)
        else:
            raise Exception("Unknown option type")

        if self.optype == OptionType.STRING:
            connect_signal(self.control._edit, 'change',
                           self.handle_value_changed)
        else:
            connect_signal(self.control, 'change',
                           self.handle_value_changed)

        button_grid = GridFlow([self.reset_button],
                               36, 1, 0, 'right')

        return Pile([Divider(), title_text, desc_text, self.control,
                     button_grid])
开发者ID:battlemidget,项目名称:conjure-up,代码行数:33,代码来源:options_column.py

示例13: help

 def help(self):
     if not hasattr(self.loop.widget, 'help'):
         return
     global_help = [(self.config.keymap.formatKeys(k), t)
                    for (k, t) in mywid.GLOBAL_HELP]
     for d in self.config.dashboards.values():
         global_help.append((keymap.formatKey(d['key']), d['name']))
     parts = [('Global Keys', global_help),
              ('This Screen', self.loop.widget.help())]
     keylen = 0
     for title, items in parts:
         for keys, text in items:
             keylen = max(len(keys), keylen)
     text = ''
     for title, items in parts:
         if text:
             text += '\n'
         text += title+'\n'
         text += '%s\n' % ('='*len(title),)
         for keys, cmdtext in items:
             text += '{keys:{width}} {text}\n'.format(
                 keys=keys, width=keylen, text=cmdtext)
     dialog = mywid.MessageDialog('Help for %s' % version(), text)
     lines = text.split('\n')
     urwid.connect_signal(dialog, 'close',
         lambda button: self.backScreen())
     self.popup(dialog, min_width=76, min_height=len(lines)+4)
开发者ID:bradleyjones,项目名称:gertty,代码行数:27,代码来源:app.py

示例14: main_insta

def main_insta(engine):
	"""
	Instant 'as-you-type' search.
	"""
	palette = [('I say', 'default,bold', 'default', 'bold'),]
	ask = urwid.Edit(('I say', u"Search: "))
	reply = urwid.Text(u"")
	button = urwid.Button(u'Exit')
	div = urwid.Divider()
	pile = urwid.Pile([ask, div, reply, div, button])
	top = urwid.Filler(pile, valign='top')

	def on_ask_change(edit, new_edit_text):
	    if len(new_edit_text) == 0:
	    	reply.set_text(('I say', 'Hey! Just start typing to get some answers.'))
	    	return

	    reply.set_text(('I say', u"Searching...\n")) 
	    results = engine.search(new_edit_text)
	    if len(results) > 0:
	    	reply.set_text(('I say', format_results(results)))
	    else:
	    	reply.set_text(('I say', u'No results for "{}"'.format(new_edit_text)))


	def on_exit_clicked(button):
	    raise urwid.ExitMainLoop()

	urwid.connect_signal(ask, 'change', on_ask_change)
	urwid.connect_signal(button, 'click', on_exit_clicked)

	urwid.MainLoop(top, palette).run()
开发者ID:mion,项目名称:def,代码行数:32,代码来源:main.py

示例15: __init__

    def __init__(self, caption=u'',
                 width_cap=conf.sizes['wgtFieldBoxDb1'][0], bindf=None, enterIsTab=False,readonly=False,cor=None):

        self._lastvalue = ''
        self._value = ''
        self.dirty = False
        self.caption = caption
        self._enterIsTab = enterIsTab
        self.capField = cap = urwid.Text(nisk.util.asUnicode((u'', caption)))
        # self.capField = urwid.Text([('key', caption[:1]), caption[1:]])
        self.textField = urwid.Edit('')
        self.textField.multiline = not enterIsTab
        urwid.connect_signal(self.textField, 'change', self.edit_changed)

        if not cor:
            cor = ('field', 'field_of')
        if len(cor) == 3:
            cap = urwid.AttrWrap(cap,cor[2])
        if len(cor) == 4:
            cap = urwid.AttrWrap(cap,cor[2],cor[3])
        
        self.readonly = readonly
        self.readonlyField = Text('')
        if readonly:
            field = urwid.AttrWrap(self.readonlyField,cor[0],cor[1])
        else:
            field = urwid.AttrWrap(self.textField,cor[0],cor[1])

        x = urwid.Columns([('fixed',  2, urwid.Text('* ')),('fixed',  width_cap,cap),
            field]
            , dividechars=0, focus_column=2)

        self.__super.__init__(x,cor[0])
开发者ID:thubaichaves,项目名称:pygestor,代码行数:33,代码来源:widgets.py


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