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


Python urwid.connect_signal方法代码示例

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


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

示例1: _init_views

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import connect_signal [as 别名]
def _init_views(self):
        aws_names = list(self.manager.aws_names)
        self.aws_view = AWSView(aws_names)

        aws_name = self.aws_view.get_selected_name()
        group_names = list(self.manager.instances[aws_name].keys())
        self.group_view = GroupView(group_names)

        group_name = self.group_view.get_selected_name()
        init_instances = self.manager.instances[aws_name][group_name]
        self.instance_view = InstanceView(init_instances)

        urwid.connect_signal(self.aws_view.get_walker(), "modified",
                             self.on_aws_changed)
        urwid.connect_signal(self.group_view.get_walker(), "modified",
                             self.on_group_changed)

        self.view = Columns([
            (15, self.aws_view.get_widget()),
            (25, self.group_view.get_widget()),
            self.instance_view.get_widget()
        ]) 
开发者ID:leejaycoke,项目名称:ec2-gazua,代码行数:24,代码来源:gazua.py

示例2: on_aws_changed

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import connect_signal [as 别名]
def on_aws_changed(self):
        # aws
        self.aws_view.update_focus()

        # group
        urwid.disconnect_signal(self.group_view.get_walker(), "modified",
                                self.on_group_changed)
        aws_name = self.aws_view.get_selected_name()
        self.group_view.update_widgets(
            list(self.manager.instances[aws_name].keys()))
        urwid.connect_signal(self.group_view.get_walker(), "modified",
                             self.on_group_changed)

        # instance
        group_name = self.group_view.get_selected_name()
        self.instance_view.update_widgets(
            self.manager.instances[aws_name][group_name]) 
开发者ID:leejaycoke,项目名称:ec2-gazua,代码行数:19,代码来源:gazua.py

示例3: __init__

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import connect_signal [as 别名]
def __init__(self, controller: Any, caption: str,
                 show_function: Callable[..., Any], width: int,
                 prefix_character: Union[str, Tuple[Any, str]]='\N{BULLET}',
                 text_color: Optional[str]=None,
                 count: int=0) -> None:
        if isinstance(prefix_character, tuple):
            prefix = prefix_character[1]
        else:
            prefix = prefix_character
        assert len(prefix) in (0, 1)
        self._caption = caption
        self.prefix_character = prefix_character
        self.post_prefix_spacing = ' ' if prefix else ''
        self.count = count

        prefix_length = 0 if prefix == '' else 2
        # Space either side, at least one space between
        self.width_for_text_and_count = width - 3 - prefix_length

        self.text_color = text_color
        self.show_function = show_function
        super().__init__("")
        self.update_count(count)
        self.controller = controller
        urwid.connect_signal(self, 'click', self.activate) 
开发者ID:zulip,项目名称:zulip-terminal,代码行数:27,代码来源:buttons.py

示例4: run

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

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

示例6: _create_relation_input

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

示例7: build

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import connect_signal [as 别名]
def build(self):
        wlist = []
        addnew = urwid.Button("Add")
        urwid.connect_signal(addnew, 'click', self._add_new_attribute)
        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_attribute)
            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))

    # edit attrib 
开发者ID:kdart,项目名称:pycopia,代码行数:20,代码来源:widgets.py

示例8: _add_new_testequipment_ok

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import connect_signal [as 别名]
def _add_new_testequipment_ok(self, frm, data):
        eq, roles, uut = data
        dbrow = models.create(models.TestEquipment, environment=self.environmentrow, equipment=eq, UUT=uut, roles=roles)
        self.session.add(dbrow)
        try:
            self.session.commit()
        except:
            self.session.rollback()
            ex, val, tb = sys.exc_info()
            DEBUG(ex.__name__, val)
            self._emit("message", "{}: {}".format(ex.__name__, val))
        entry = ListEntry(urwid.Text(self._stringify_te(dbrow)))
        urwid.connect_signal(entry, 'activate', self._edit_testequipment)
        urwid.connect_signal(entry, 'delete', self._delete_testequipment)
        entry.testequipment = dbrow
        listbox = self._w.contents[1][0].base_widget
        listbox.body.append(entry)
        urwid.disconnect_signal(frm, 'ok', self._add_new_testequipment_ok)
        urwid.disconnect_signal(frm, 'cancel', self._add_new_testequipment_cancel)
        frm._emit("popform") 
开发者ID:kdart,项目名称:pycopia,代码行数:22,代码来源:widgets.py

示例9: _build_list

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import connect_signal [as 别名]
def _build_list(self):
        choices = get_related_choices(self.session, self.modelclass, self.metadata, None)

        #listbox.body.remove(listentry)

        #choices.update(self.currentvalue)
        wlist = []
#        current = self.currentvalue
#        for pk, cobj in choices.items():
#            if pk in current:
#                but = urwid.CheckBox(str(cobj), state=True)
#            else:
#                but = urwid.CheckBox(str(cobj), state=False)
#            urwid.connect_signal(but, 'change', self._multi_select, (pk, cobj))
#            wlist.append(but)
#        return urwid.ListBox(urwid.SimpleListWalker(wlist)) 
开发者ID:kdart,项目名称:pycopia,代码行数:18,代码来源:widgets.py

示例10: get_form_buttons

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

示例11: get_items

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import connect_signal [as 别名]
def get_items(self):
        q = self.session.query(self.modelclass).order_by(self._orderby)
        if self._filter:
            filt = []
            for name, value in self._filter.items():
                filt.append(getattr(self.modelclass, name).like("%{}%".format(value)))
            q = q.filter(*filt)
        items = []
        for row in q:
            disprow = []
            pk = getattr(row, str(self._pkname))
            disprow.append( ('fixed', 6, urwid.Text(str(pk))) )
            for colname in self._colnames:
                md = self.metadata[colname]
                fmt, width = self._FORMATS.get(md.coltype, ("{!s:10.10}", 10))
                disprow.append( ('fixed', width, urwid.Text(fmt.format(getattr(row, colname)))) )
            le = ListEntry(urwid.Columns(disprow, dividechars=1))
            urwid.connect_signal(le, 'activate', self._edit, pk)
            urwid.connect_signal(le, 'delete', self._delete, pk)
            items.append(le)
        return urwid.SimpleListWalker(items) 
开发者ID:kdart,项目名称:pycopia,代码行数:23,代码来源:widgets.py

示例12: mount_chatbox

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import connect_signal [as 别名]
def mount_chatbox(self, executor, channel):
        yield from asyncio.gather(
            loop.run_in_executor(executor, self.store.load_channel, channel),
            loop.run_in_executor(executor, self.store.load_messages, channel)
        )
        messages = self.render_messages(self.store.state.messages)
        header = self.render_chatbox_header()
        self._loading = False
        self.sidebar.select_channel(channel)
        self.message_box = MessageBox(
            user=self.store.state.auth['user'],
            is_read_only=self.store.state.channel.get('is_read_only', False)
        )
        self.chatbox = ChatBox(messages, header, self.message_box, self.urwid_loop)
        urwid.connect_signal(self.chatbox, 'set_insert_mode', self.set_insert_mode)
        urwid.connect_signal(self.chatbox, 'mark_read', self.handle_mark_read)
        urwid.connect_signal(self.chatbox, 'open_quick_switcher', self.open_quick_switcher)
        urwid.connect_signal(self.chatbox, 'open_set_snooze', self.open_set_snooze)

        urwid.connect_signal(self.message_box.prompt_widget, 'submit_message', self.submit_message)
        urwid.connect_signal(self.message_box.prompt_widget, 'go_to_last_message', self.go_to_last_message)

        self.real_time_task = loop.create_task(self.start_real_time()) 
开发者ID:haskellcamargo,项目名称:sclack,代码行数:25,代码来源:app.py

示例13: __init__

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import connect_signal [as 别名]
def __init__(self, caption, callback):
        super(MyButton, self).__init__(caption)
        urwid.connect_signal(self, 'click', callback)
        self._w = urwid.AttrMap(urwid.SelectableIcon([u' \N{BULLET} ', caption], 1), None, 'popbgs') 
开发者ID:Dragon2fly,项目名称:vpngate-with-proxy,代码行数:6,代码来源:ui_elements.py

示例14: create_pop_up

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import connect_signal [as 别名]
def create_pop_up(self):
        # this method must be exist due to its blank content in original class
        urwid.connect_signal(self.popup, 'close', self.close_pop)
        return self.popup 
开发者ID:Dragon2fly,项目名称:vpngate-with-proxy,代码行数:6,代码来源:ui_elements.py

示例15: __init__

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import connect_signal [as 别名]
def __init__(self, panel_view: Any, search_command: str,
                 update_function: Callable[..., None]) -> None:
        self.panel_view = panel_view
        self.search_command = search_command
        self.search_text = ("Search ["
                            + ", ".join(keys_for_command(search_command))
                            + "]: ")
        urwid.connect_signal(self, 'change', update_function)
        super().__init__(caption='', edit_text=self.search_text) 
开发者ID:zulip,项目名称:zulip-terminal,代码行数:11,代码来源:boxes.py


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