當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。