Python urwid 模块,connect_signal() 实例源码

我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用urwid.connect_signal()

项目:pytest-ui    作者:martinsmid    | 项目源码 | 文件源码
def init_main_screen(self):
        self.w_filter_edit = urwid.Edit('Filter ')
        aw_filter_edit = urwid.AttrMap(self.w_filter_edit, 'edit', 'edit_focus')
        self.w_status_line = urwid.AttrMap(StatusLine(self.store.get_test_stats), 'statusline', '')
        urwid.connect_signal(self.w_filter_edit, 'change', self.on_filter_change)
        self.init_test_listbox()
        self.w_main = urwid.Padding(
            urwid.Pile([
                ('pack', urwid.Text(u'Python Urwid Test Runner', align='center')),
                ('pack', urwid.Divider()),
                ('pack', aw_filter_edit),
                ('pack', urwid.Divider()),
                self.w_test_listbox,
                ('pack', urwid.Divider()),
                ('pack', self.w_status_line),
            ]),
            left=2, right=2
        )
项目:stellarmagnate    作者:abadger    | 项目源码 | 文件源码
def _sync_widget_lists(self):
        """
        Make sure the widget_list for each column contains the same
        commodities in the same order as the main commodity map
        """
        for column in self.auxiliary_cols:
            column.widget_list.clear()  # pylint: disable=no-member
            for commodity, value in column.data_map.items():
                if isinstance(value, int):
                    formatted_number = format_number(value)
                    if column.money:
                        button = IndexedMenuButton('${}'.format(formatted_number))
                    else:
                        button = IndexedMenuButton('{}'.format(formatted_number))
                else:
                    if value is None:
                        value = " "
                    button = IndexedMenuButton(value)
                urwid.connect_signal(button, 'click', partial(self.handle_commodity_select, commodity))
                column.widget_list.append(urwid.AttrMap(button, None))  # pylint: disable=no-member
项目:stellarmagnate    作者:abadger    | 项目源码 | 文件源码
def __init__(self, pubpen):
        self.free_space = 0
        self.filled_space = 0
        self.commodity_in_hold = 0
        self.free_warehouse = 0
        self.commodity_in_warehouse = 0

        self.hold_box = CheckBox('Hold:', state=True)
        self.warehouse_box = CheckBox('Warehouse:', state=True)
        super().__init__(pubpen, 'ui.urwid.cargo_order_info',
                         (self.hold_box, self.warehouse_box))

        urwid.connect_signal(self.hold_box, 'postchange', self.validate_storage_toggle)
        urwid.connect_signal(self.warehouse_box, 'postchange', self.validate_storage_toggle)

        self.pubpen.subscribe('ship.info', self.handle_ship_info)
        self.pubpen.subscribe('ship.cargo.update', self.handle_cargo_update)
        self.pubpen.subscribe('ship.equip.update', self.handle_equip_update)
项目:boartty    作者:openstack    | 项目源码 | 文件源码
def help(self):
        if not hasattr(self.frame.body, 'help'):
            return
        global_help = self.getGlobalHelp()
        parts = [('Global Keys', global_help),
                 ('This Screen', self.frame.body.help())]
        keylen = 0
        for title, items in parts:
            for cmd, 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 cmd, 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)
项目:boartty    作者:openstack    | 项目源码 | 文件源码
def __init__(self, app, title, prompt, button, text, ring=None):
        self.app = app
        save_button = FixedButton(button)
        cancel_button = FixedButton('Cancel')
        urwid.connect_signal(save_button, 'click',
                             lambda button:self._emit('save'))
        urwid.connect_signal(cancel_button, 'click',
                             lambda button:self._emit('cancel'))
        button_widgets = [('pack', save_button),
                          ('pack', cancel_button)]
        button_columns = urwid.Columns(button_widgets, dividechars=2)
        rows = []
        self.entry = MyEdit(edit_text=text, multiline=True, ring=ring)
        rows.append(urwid.Text(prompt))
        rows.append(self.entry)
        rows.append(urwid.Divider())
        rows.append(button_columns)
        pile = urwid.Pile(rows)
        fill = urwid.Filler(pile, valign='top')
        super(TextEditDialog, self).__init__(urwid.LineBox(fill, title))
项目:boartty    作者:openstack    | 项目源码 | 文件源码
def __init__(self, title, topics):
        button_widgets = []
        ok_button = mywid.FixedButton('OK')
        cancel_button = mywid.FixedButton('Cancel')
        urwid.connect_signal(ok_button, 'click',
                             lambda button:self._emit('ok'))
        urwid.connect_signal(cancel_button, 'click',
                             lambda button:self._emit('cancel'))
        button_widgets.append(('pack', ok_button))
        button_widgets.append(('pack', cancel_button))
        button_columns = urwid.Columns(button_widgets, dividechars=2)

        self.topic_buttons = []
        self.topic_keys = {}
        rows = []
        for key, name in topics:
            button = mywid.FixedRadioButton(self.topic_buttons, name)
            self.topic_keys[button] = key
            rows.append(button)

        rows.append(urwid.Divider())
        rows.append(button_columns)
        pile = urwid.Pile(rows)
        fill = urwid.Filler(pile, valign='top')
        super(TopicSelectDialog, self).__init__(urwid.LineBox(fill, title))
项目:boartty    作者:openstack    | 项目源码 | 文件源码
def renameTopic(self):
        pos = self.listbox.focus_position
        row = self.listbox.body[pos]
        if not isinstance(row, TopicRow):
            return
        with self.app.db.getSession() as session:
            topic = session.getTopic(row.topic_key)
            name = topic.name
            key = topic.key
        dialog = mywid.LineEditDialog(self.app, 'Topic', 'Rename a new topic.',
                                      'Topic: ', name, self.app.ring)
        urwid.connect_signal(dialog, 'save',
            lambda button: self.closeRenameTopic(dialog, True, key))
        urwid.connect_signal(dialog, 'cancel',
            lambda button: self.closeRenameTopic(dialog, False, key))
        self.app.popup(dialog)
项目:boartty    作者:openstack    | 项目源码 | 文件源码
def copyMoveToTopic(self, move):
        if move:
            verb = 'Move'
        else:
            verb = 'Copy'
        rows = self.getSelectedRows(ProjectRow)
        if not rows:
            return

        with self.app.db.getSession() as session:
            topics = [(t.key, t.name) for t in session.getTopics()]

        dialog = TopicSelectDialog('%s to Topic' % verb, topics)
        urwid.connect_signal(dialog, 'ok',
            lambda button: self.closeCopyMoveToTopic(dialog, True, rows, move))
        urwid.connect_signal(dialog, 'cancel',
            lambda button: self.closeCopyMoveToTopic(dialog, False, rows, move))
        self.app.popup(dialog)
项目:Drogo    作者:csrgxtu    | 项目源码 | 文件源码
def __init__(self, title, command_caption='Command:  (Tab to switch focus to upper frame, where you can scroll text)', cmd_cb=None, 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._cmd=cmd_cb
        self._output_styles=[s[0] for s in self.PALLETE]
        self.eloop=None
项目:Drogo    作者:csrgxtu    | 项目源码 | 文件源码
def __init__(self, title, command_caption='Command:  (Tab to switch focus to upper frame, where you can scroll text)', cmd_cb=None, 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._cmd=cmd_cb
        self._output_styles=[s[0] for s in self.PALLETE]
        self.eloop=None
项目:bbj    作者:desvox    | 项目源码 | 文件源码
def __init__(self, endpoint, **params):
        self.file_descriptor, self.path = tempfile.mkstemp()
        with open(self.path, "w") as _:
            if params.get("init_body"):
                init_body = params.pop("init_body")
            else:
                init_body = ""
            _.write(init_body)

        self.endpoint = endpoint
        self.params = params
        env = os.environ
        # barring this, programs will happily spit out unicode chars which
        # urwid+python3 seem to choke on. This seems to be a bug on urwid's
        # behalf. Users who take issue to programs trying to supress unicode
        # should use the options menu to switch to Overthrow mode.
        env.update({"LANG": "POSIX"})
        command = ["bash", "-c", "{} {}; echo Press any key to kill this window...".format(
            app.prefs["editor"], self.path)]
        super(ExternalEditor, self).__init__(command, env, app.loop, app.prefs["edit_escapes"]["abort"])
        urwid.connect_signal(self, "closed", self.exterminate)
项目:swarm    作者:3drobotics    | 项目源码 | 文件源码
def menu(title, SSID):
    body = [urwid.Text(title), urwid.Divider()]
    options = []
    for c in SSID:
        button = urwid.Button("[ ] " + c)
        options.append(button)
        #if SSID_DICT[c] == True:
        #    button.set_label(u"DH")
        urwid.connect_signal(button, 'click', item_chosen, c)
        body.append(urwid.AttrMap(button, None, focus_map='reversed'))

    swarmify_button = urwid.Button("Swarmify")
    options.append(swarmify_button)
    urwid.connect_signal(swarmify_button, 'click', swarm_chosen, c)
    body.append(urwid.AttrMap(swarmify_button, None, focus_map='reversed'))

    return urwid.ListBox(urwid.SimpleFocusListWalker(body))
项目:swarm    作者:3drobotics    | 项目源码 | 文件源码
def item_chosen(button, choice):
    if SSID_DICT[choice]:
        button.set_label(u"[ ] " + button.get_label()[4:])
        SSID_DICT[choice] = False
    else:
        button.set_label(u"[*] " + button.get_label()[4:])
        SSID_DICT[choice] = True



    ##response = urwid.Text([u'You chose ', str(SSID_DICT[choice]), u'\n'])
    ##done = urwid.Button(u'Ok')


    ##urwid.connect_signal(done, 'click', exit_program)
    ##main.original_widget = urwid.Filler(urwid.Pile([response,
    ##urwid.AttrMap(done, None, focus_map='reversed')]))
项目:PyAlertMe    作者:jamesleesaunders    | 项目源码 | 文件源码
def __init__(self, title,
                 command_caption='Command:  (Tab to switch focus to upper frame, where you can scroll text)',
                 cmd_cb=None, 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._cmd = cmd_cb
        self._output_styles = [s[0] for s in self.PALLETE]
        self.eloop = None
项目:YtbDwn    作者:praneet95    | 项目源码 | 文件源码
def menuAV(title, avail_stream_both):   ###menu displaying formats with both audio and video ######### 2nd loop
        body = [urwid.Text(title), urwid.Divider()]

        for c in avail_stream_both:
            button = urwid.Button(str(c) + " ----->" + str(c.resolution) + "----->" + str((float(c.get_filesize())/1024)/1024))
            urwid.connect_signal(button, 'click', chosen_URL, c)
            body.append(urwid.AttrMap(button, None, focus_map='reversed'))
        button = urwid.Button("Only Video/Audio Formats")
        urwid.connect_signal(button, 'click', menuVAOnly)
        body.append(urwid.AttrMap(button, None, focus_map='reversed'))

        button = urwid.Button("EXIT")
        urwid.connect_signal(button, 'click', exit_program)
        body.append(urwid.AttrMap(button, None, focus_map='reversed'))

        return urwid.ListBox(urwid.SimpleFocusListWalker(body))

    ##########################################################################333
项目:YtbDwn    作者:praneet95    | 项目源码 | 文件源码
def menuVAOnlyMenu(title, avail_stream_VideoO,avail_stream_audioO): ###menu displaying formats with only audio or video ## must handle cases with audio and video alone ## for 3rd loop
        body = [urwid.Text(title), urwid.Divider()]

        for x in avail_stream_VideoO:
            button = urwid.Button(str(x).split('@',1)[0]  + "---->" +x.resolution  + "----->" + str((float(x.get_filesize())/1024)/1024))
            urwid.connect_signal(button, 'click', chosen_URL, x)
            body.append(urwid.AttrMap(button, None, focus_map='reversed'))
        for x1 in avail_stream_audioO:
            button = urwid.Button(str(x1))
            urwid.connect_signal(button, 'click', chosen_URL, x1)
            body.append(urwid.AttrMap(button, None, focus_map='reversed'))

        button = urwid.Button("EXIT")
        urwid.connect_signal(button, 'click', exit_program)
        body.append(urwid.AttrMap(button, None, focus_map='reversed'))

        return urwid.ListBox(urwid.SimpleFocusListWalker(body))

    #################3333##################################################
项目:my_ros_tools    作者:groundmelon    | 项目源码 | 文件源码
def __init__(self, prompt_text=u"Input:", default_text=u""):
        close_button = urwid.Button("OK")
        prompt = urwid.Text(prompt_text)
        edit_field = CustomEdit(caption=u'',
                                edit_text=default_text,
                                multiline=False,
                                align='left',
                                wrap='space',
                                allow_tab=False,
                                edit_pos=None,
                                layout=None,
                                mask=None)

        prompt_wrap = urwid.AttrMap(prompt, 'header')
        close_button_wrap = urwid.AttrMap(close_button, 'buttn', 'buttnf')
        edit_field_wrap = urwid.AttrMap(edit_field, 'editcp')

        urwid.connect_signal(close_button, 'click', edit_field.on_finish)
        urwid.connect_signal(edit_field, 'done', self.on_close)

        pile = urwid.Pile([prompt_wrap,
                           edit_field_wrap,
                           urwid.Padding(close_button_wrap, 'center', 6)])
        fill = urwid.Filler(urwid.Padding(pile, 'center', left=1, right=1))
        self.__super.__init__(urwid.AttrWrap(fill, 'popbg'))
项目:GitChat    作者:shubhodeep9    | 项目源码 | 文件源码
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
项目:shirleytoolate    作者:trobanga    | 项目源码 | 文件源码
def __init__(self, *args, **kwargs):

        self.start = urwid.Edit('Start: ')
        self.end = urwid.Edit('End: ')

        self.server = kwargs["server"]
        self.calendar = kwargs["calendar"]

        del(kwargs['server'])
        del(kwargs["calendar"])

        print (self.server, self.calendar)


        div = urwid.Divider()
        self.msg = urwid.Edit(caption="Event message: ", edit_text='', multiline=True)
        button_save = urwid.Button('save')
        urwid.connect_signal(button_save, 'click', self.on_save)
        self.pile = urwid.Pile([self.start,
                                self.end,
                                div,
                                self.msg,
                                div,
                                button_save])

        super(EventWidget, self).__init__(self.pile, *args, **kwargs)
项目:pytest-ui    作者:martinsmid    | 项目源码 | 文件源码
def get_list_item(self, test_id, position):
        test_data = self.store.test_data[test_id]
        test_data.update({
            'widget': None,
            'lw_widget': None,
            'position': position,
            'id': test_id,
        })
        test_line = TestLine(test_data)
        test_data['widget'] = test_line
        # logger.debug('widget set for %s: %s', test_id, test_line)
        urwid.connect_signal(test_line, 'click', self.show_test_detail, test_id)
        test_line_attr = urwid.AttrMap(test_line, None, focus_map='reversed')
        test_data['lw_widget'] = test_line_attr
        return test_line_attr
项目:scum    作者:CCareaga    | 项目源码 | 文件源码
def __init__(self):
        close_button = urwid.Button("that's pretty cool")
        urwid.connect_signal(close_button, 'click',
            lambda button:self._emit("close"))
        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'))
项目:scum    作者:CCareaga    | 项目源码 | 文件源码
def __init__(self):
        self.__super.__init__(urwid.Button("click-me"))
        urwid.connect_signal(self.original_widget, 'click',
            lambda button: self.open_pop_up())
项目:scum    作者:CCareaga    | 项目源码 | 文件源码
def create_pop_up(self):
        pop_up = PopUpDialog()
        urwid.connect_signal(pop_up, 'close',
            lambda button: self.close_pop_up())
        return pop_up
项目:stellarmagnate    作者:abadger    | 项目源码 | 文件源码
def _construct_commodity_list(self, commodities):
        """
        Display the commodities that can be bought and sold

        :arg commodities: iterable of commodity names sold at this market
        """
        for commodity in commodities:
            if commodity not in self.commodity_col.data_map:
                idx = self.keypress_map.set_next(commodity)

                button = IndexedMenuButton('({}) {}'.format(idx, commodity))
                self.commodity_col.widget_list.append(urwid.AttrMap(button,  # pylint: disable=no-member
                                                                    None,
                                                                    focus_map='reversed'))
                urwid.connect_signal(button, 'click', partial(self.handle_commodity_select, commodity))

                self.commodity_col.data_map[commodity] = len(self.commodity_col.widget_list) - 1

        self._sync_data_maps()
        self._sync_widget_lists()

        self._highlight_focused_line()

    #
    # Handle updates to the displayed info
    #
项目:stellarmagnate    作者:abadger    | 项目源码 | 文件源码
def handle_new_destinations(self, locations):
        """Update the destination list when the ship can move to new places"""
        self.listwalker.clear()
        self.keypress_map = IndexedMenuEnumerator()
        #for idx, location in enumerate(locations):
        for location in locations:
            prefix = self.keypress_map.set_next(location)
            button = IndexedMenuButton('({}) {}'.format(prefix, location))
            self.listwalker.append(urwid.AttrMap(button, None, focus_map='reversed'))
            urwid.connect_signal(button, 'click', partial(self.handle_button_click, location))
项目:stellarmagnate    作者:abadger    | 项目源码 | 文件源码
def __init__(self, pubpen):
        self.pubpen = pubpen

        self.save_button = urwid.Button('(S)ave')
        self.load_button = urwid.Button('(L)oad')
        self.quit_button = urwid.Button('(Q)uit')
        self.continue_button = urwid.Button('(ESC) Continue Game')

        self.buttons = urwid.SimpleFocusListWalker((
            urwid.AttrMap(self.save_button, None, focus_map='reversed'),
            urwid.AttrMap(self.load_button, None, focus_map='reversed'),
            urwid.AttrMap(self.quit_button, None, focus_map='reversed'),
            urwid.AttrMap(self.continue_button, None, focus_map='reversed'),
            ))
        self.entrybox = urwid.ListBox(self.buttons)

        # Draw a box around the widget and constrain the widget's size
        linebox = urwid.LineBox(self.entrybox, tlcorner='\u2554',
                                tline='\u2550', trcorner='\u2557',
                                blcorner='\u255A', bline='\u2550',
                                brcorner='\u255D', lline='\u2551',
                                rline='\u2551')
        padding = urwid.Padding(linebox, align='center',
                                width=len(self.continue_button.get_label()) + 6)
        filler = urwid.Filler(padding, valign='middle',
                              height=len(self.buttons) + 2)

        outer_layout = LineBox(filler, lline=None, blcorner='?',
                               tlcorner='?', trcorner='\u252c',
                               brcorner='\u2524')
        super().__init__(outer_layout)

        urwid.connect_signal(self.save_button, 'click', self.save_game)
        urwid.connect_signal(self.load_button, 'click', self.load_game)
        urwid.connect_signal(self.quit_button, 'click', self.quit_client)
        urwid.connect_signal(self.continue_button, 'click', self.continue_game)
项目:stellarmagnate    作者:abadger    | 项目源码 | 文件源码
def __init__(self, pubpen, cli_args):
        super().__init__(pubpen, cli_args)

        # Note: We don't have any extra command line args

        # Windows

        self.title_card = TitleScreen(pubpen)
        self.login_screen = LoginScreen(pubpen)
        self.main_window = MainScreen(pubpen)
        self.root_win = urwid.Frame(urwid.SolidFill(' '))

        # Arrange the widgets

        self.show_title_card()

        # Connect to UI events

        urwid.connect_signal(self.title_card, 'close_title_card', self.show_login_screen)
        urwid.connect_signal(self.login_screen, 'logged_in', self.show_main_window)

        # Setup the main loop

        self.urwid_loop = urwid.MainLoop(self.root_win,
                                         event_loop=urwid.AsyncioEventLoop(loop=self.pubpen.loop),
                                         palette=(('reversed', 'standout', ''),),)
项目:ncTelegram    作者:Nanoseb    | 项目源码 | 文件源码
def __init__(self, widgetbase, widgetpop):
        self.__super.__init__(widgetbase)
        urwid.connect_signal(self.original_widget, 'click',
            lambda button: self.open_pop_up())
项目:ncTelegram    作者:Nanoseb    | 项目源码 | 文件源码
def create_pop_up(self):
        pop_up = PopUpDialog()
        urwid.connect_signal(pop_up, 'close',
            lambda button: self.close_pop_up())
        return pop_up
项目:ncTelegram    作者:Nanoseb    | 项目源码 | 文件源码
def __init__(self, caption, callback,arg=None):
        super(NewButton, self).__init__("")
        urwid.connect_signal(self, 'click', callback, arg)
        self._w = urwid.AttrMap(urwid.SelectableIcon(caption, 1),
                                None, focus_map='status_bar')
项目:boartty    作者:openstack    | 项目源码 | 文件源码
def __init__(self, app, default):
        self.app = app
        search_button = mywid.FixedButton('Search')
        cancel_button = mywid.FixedButton('Cancel')
        urwid.connect_signal(search_button, 'click',
                             lambda button:self._emit('search'))
        urwid.connect_signal(cancel_button, 'click',
                             lambda button:self._emit('cancel'))
        super(SearchDialog, self).__init__("Search",
                                           "Enter a change number or search string.",
                                           entry_prompt="Search: ",
                                           entry_text=default,
                                           buttons=[search_button,
                                                    cancel_button],
                                           ring=app.ring)
项目:boartty    作者:openstack    | 项目源码 | 文件源码
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)
项目:boartty    作者:openstack    | 项目源码 | 文件源码
def welcome(self):
        text = WELCOME_TEXT
        dialog = mywid.MessageDialog('Welcome', 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)

    #storyboard
项目:boartty    作者:openstack    | 项目源码 | 文件源码
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)
项目:boartty    作者:openstack    | 项目源码 | 文件源码
def newStory(self):
        if hasattr(self.frame.body, 'project_key'):
            project_key = self.frame.body.project_key
        else:
            project_key = None
        dialog = view_story.NewStoryDialog(self, project_key)
        urwid.connect_signal(dialog, 'save',
                             lambda button: self.saveNewStory(dialog))
        urwid.connect_signal(dialog, 'cancel',
                             lambda button: self.cancelNewStory(dialog))
        self.popup(dialog,
                   relative_width=50, relative_height=25,
                   min_width=60, min_height=8)
项目:boartty    作者:openstack    | 项目源码 | 文件源码
def __init__(self, app, title, message, entry_prompt=None,
                 entry_text='', ring=None):
        self.app = app
        save_button = FixedButton('Save')
        cancel_button = FixedButton('Cancel')
        urwid.connect_signal(save_button, 'click',
                             lambda button:self._emit('save'))
        urwid.connect_signal(cancel_button, 'click',
                             lambda button:self._emit('cancel'))
        super(LineEditDialog, self).__init__(title, message, entry_prompt,
                                             entry_text,
                                             buttons=[save_button,
                                                      cancel_button],
                                             ring=ring)
项目:boartty    作者:openstack    | 项目源码 | 文件源码
def __init__(self, title, message):
        ok_button = FixedButton('OK')
        urwid.connect_signal(ok_button, 'click',
                             lambda button:self._emit('close'))
        super(MessageDialog, self).__init__(title, message, buttons=[ok_button])
项目:boartty    作者:openstack    | 项目源码 | 文件源码
def __init__(self, title, message):
        yes_button = FixedButton('Yes')
        no_button = FixedButton('No')
        urwid.connect_signal(yes_button, 'click',
                             lambda button:self._emit('yes'))
        urwid.connect_signal(no_button, 'click',
                             lambda button:self._emit('no'))
        super(YesNoDialog, self).__init__(title, message, buttons=[yes_button,
                                                                   no_button])
项目:boartty    作者:openstack    | 项目源码 | 文件源码
def __init__(self, app, title, key, value, values):
        self.app = app
        self.title = title
        self.values = values
        urwid.connect_signal(self, 'click',
                             lambda button:self.onClick())
        super(SearchSelectButton, self).__init__(u'')
        self.update(key, value)
项目:boartty    作者:openstack    | 项目源码 | 文件源码
def onClick(self):
        dialog = SearchSelectDialog(self.app, self.title, self.key, self.values)
        urwid.connect_signal(dialog, 'save',
                             lambda d:self.onChanged(d))
        self.app.popup(dialog,
                       relative_width=30, relative_height=75,
                       min_width=30, min_height=20)
项目:boartty    作者:openstack    | 项目源码 | 文件源码
def replace(self, app, data):
        link = mywid.Link(self.text.format(**data), 'link', 'focused-link')
        urwid.connect_signal(link, 'selected',
            lambda link:self.activate(app, self.url.format(**data)))
        return link
项目:boartty    作者:openstack    | 项目源码 | 文件源码
def replace(self, app, data):
        link = mywid.Link(self.text.format(**data), 'link', 'focused-link')
        urwid.connect_signal(link, 'selected',
            lambda link:app.doSearch(self.query.format(**data)))
        return link
项目:boartty    作者:openstack    | 项目源码 | 文件源码
def __init__(self, app, project_key):
        self.app = app
        save_button = mywid.FixedButton(u'Save')
        cancel_button = mywid.FixedButton(u'Cancel')
        urwid.connect_signal(save_button, 'click',
            lambda button:self._emit('save'))
        urwid.connect_signal(cancel_button, 'click',
            lambda button:self._emit('cancel'))

        rows = []
        buttons = [('pack', save_button),
                   ('pack', cancel_button)]
        buttons = urwid.Columns(buttons, dividechars=2)

        if project_key:
            with self.app.db.getSession() as session:
                project = session.getProject(project_key)
                project_name = project.name
        else:
            project_name = None

        self.project_button = ProjectButton(self.app, project_key, project_name)
        self.title_field = mywid.MyEdit(u'', edit_text=u'', ring=app.ring)
        self.description_field = mywid.MyEdit(u'', edit_text='',
                                              multiline=True, ring=app.ring)

        for (label, w) in [
                (u'Title:', self.title_field),
                (u'Description:', self.description_field),
                (u'Project:', ('pack', self.project_button)),
                ]:
            row = urwid.Columns([(12, urwid.Text(label)), w])
            rows.append(row)

        rows.append(urwid.Divider())
        rows.append(buttons)
        pile = urwid.Pile(rows)
        fill = urwid.Filler(pile, valign='top')
        super(NewStoryDialog, self).__init__(urwid.LineBox(fill, 'New Story'))
项目:boartty    作者:openstack    | 项目源码 | 文件源码
def __init__(self, app):
        self.app = app
        save_button = mywid.FixedButton(u'Save')
        cancel_button = mywid.FixedButton(u'Cancel')
        urwid.connect_signal(save_button, 'click',
            lambda button:self._emit('save'))
        urwid.connect_signal(cancel_button, 'click',
            lambda button:self._emit('cancel'))

        rows = []
        buttons = [('pack', save_button),
                   ('pack', cancel_button)]
        buttons = urwid.Columns(buttons, dividechars=2)

        self.project_button = ProjectButton(self.app)
        self.status_button = StatusButton(self.app)
        self.assignee_button = AssigneeButton(self.app)
        self.title_field = mywid.MyEdit(u'', edit_text=u'', ring=app.ring)

        for (label, w) in [
                (u'Project:', ('pack', self.project_button)),
                (u'Title:', self.title_field),
                (u'Status:', ('pack', self.status_button)),
                (u'Assignee:', ('pack', self.assignee_button)),
                ]:
            row = urwid.Columns([(12, urwid.Text(label)), w])
            rows.append(row)

        rows.append(urwid.Divider())
        rows.append(buttons)
        pile = urwid.Pile(rows)
        fill = urwid.Filler(pile, valign='top')
        super(NewTaskDialog, self).__init__(urwid.LineBox(fill, 'New Task'))
项目:boartty    作者:openstack    | 项目源码 | 文件源码
def editNote(self, note_button):
        dialog = mywid.LineEditDialog(self.app, 'Edit Task Note', '',
                                      'Note: ', self._note,
                                      ring=self.app.ring)
        urwid.connect_signal(dialog, 'save',
            lambda button: self.updateNote(dialog, True))
        urwid.connect_signal(dialog, 'cancel',
            lambda button: self.updateNote(dialog, False))
        self.app.popup(dialog)
项目:boartty    作者:openstack    | 项目源码 | 文件源码
def delete(self):
        dialog = mywid.YesNoDialog(u'Delete Task',
                                   u'Are you sure you want to delete this task?')
        urwid.connect_signal(dialog, 'no', lambda d: self.app.backScreen())
        urwid.connect_signal(dialog, 'yes', self.finishDelete)
        self.app.popup(dialog)
项目:boartty    作者:openstack    | 项目源码 | 文件源码
def __init__(self, story_view, story_key, text):
        super(StoryButton, self).__init__('')
        self.set_label(text)
        self.story_view = story_view
        self.story_key = story_key
        urwid.connect_signal(self, 'click',
            lambda button: self.openStory())
项目:boartty    作者:openstack    | 项目源码 | 文件源码
def editDescription(self):
        with self.app.db.getSession() as session:
            story = session.getStory(self.story_key)
            dialog = mywid.TextEditDialog(self.app, u'Edit Description',
                                          u'Description:',
                                          u'Save', story.description)
        urwid.connect_signal(dialog, 'cancel', self.app.backScreen)
        urwid.connect_signal(dialog, 'save', lambda button:
                                 self.doEditDescription(dialog))
        self.app.popup(dialog,
                       relative_width=50, relative_height=75,
                       min_width=60, min_height=20)
项目:boartty    作者:openstack    | 项目源码 | 文件源码
def newTask(self):
        dialog = NewTaskDialog(self.app)
        urwid.connect_signal(dialog, 'save',
                             lambda button: self.saveNewTask(dialog))
        urwid.connect_signal(dialog, 'cancel',
                             lambda button: self.cancelNewTask(dialog))
        self.app.popup(dialog,
                       relative_width=50, relative_height=25,
                       min_width=60, min_height=8)
项目:boartty    作者:openstack    | 项目源码 | 文件源码
def editTitle(self):
        dialog = mywid.LineEditDialog(self.app, 'Edit Story Title', '',
                                      'Title: ', self.story_title,
                                      ring=self.app.ring)
        urwid.connect_signal(dialog, 'save',
            lambda button: self.updateTitle(dialog, True))
        urwid.connect_signal(dialog, 'cancel',
            lambda button: self.updateTitle(dialog, False))
        self.app.popup(dialog)