當前位置: 首頁>>代碼示例>>Python>>正文


Python urwid.Pile方法代碼示例

本文整理匯總了Python中urwid.Pile方法的典型用法代碼示例。如果您正苦於以下問題:Python urwid.Pile方法的具體用法?Python urwid.Pile怎麽用?Python urwid.Pile使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在urwid的用法示例。


在下文中一共展示了urwid.Pile方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: edit

# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import Pile [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 Pile [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: __init__

# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import Pile [as 別名]
def __init__(self, topics_btn_list: List[Any], view: Any,
                 stream_button: Any) -> None:
        self.view = view
        self.log = urwid.SimpleFocusListWalker(topics_btn_list)
        self.topics_btn_list = topics_btn_list
        self.stream_button = stream_button
        self.focus_index_before_search = 0
        self.list_box = urwid.ListBox(self.log)
        self.topic_search_box = PanelSearchBox(self,
                                               'SEARCH_TOPICS',
                                               self.update_topics)
        self.header_list = urwid.Pile([self.stream_button,
                                       urwid.Divider('─'),
                                       self.topic_search_box])
        super().__init__(self.list_box, header=urwid.LineBox(
            self.header_list, tlcorner='─', tline='', lline='',
            trcorner='─', blcorner='─', rline='',
            bline='─', brcorner='─'
        ))
        self.search_lock = threading.Lock() 
開發者ID:zulip,項目名稱:zulip-terminal,代碼行數:22,代碼來源:views.py

示例4: __init__

# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import Pile [as 別名]
def __init__(self, exit_code):
        self.exit_code = exit_code
        self.message = Text('Do you want to quit?', align='center')
        super().__init__(LineBox(Pile([
            Padding.line_break(""),
            self.message,
            Padding.line_break(""),
            Columns([
                Text(""),
                SubmitButton('Yes', lambda _: self.confirm()),
                Text(""),
                SubmitButton('No', lambda _: self.cancel()),
                Text(""),
            ]),
            Padding.line_break(""),
        ])))
        if events.Error.is_set():
            self.confirm() 
開發者ID:conjure-up,項目名稱:conjure-up,代碼行數:20,代碼來源:shutdown.py

示例5: _build_footer

# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import Pile [as 別名]
def _build_footer(self):
        no = menu_btn(on_press=self.cancel,
                      label="\n  NO\n")
        yes = menu_btn(on_press=self.submit,
                       label="\n  YES\n")
        self.buttons = Columns([
            ('fixed', 2, Text("")),
            ('fixed', 11, Color.menu_button(
                no,
                focus_map='button_primary focus')),
            Text(""),
            ('fixed', 11, Color.menu_button(
                yes,
                focus_map='button_primary focus')),
            ('fixed', 2, Text(""))
        ])

        self.footer = Pile([
            Padding.line_break(""),
            self.buttons
        ])
        return Color.frame_footer(self.footer) 
開發者ID:conjure-up,項目名稱:conjure-up,代碼行數:24,代碼來源:destroy_confirm.py

示例6: build_widget

# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import Pile [as 別名]
def build_widget(self):
        self.widgets = {}
        rows = [
            Columns([
                ('fixed', 3, Text('')),
                ('weight', 0.1, Text('Application')),
                ('weight', 0.4, Text('Result'))
            ], dividechars=5),
            HR(),
        ]
        for step in app.all_steps:
            if not step.has_after_deploy:
                continue
            widget = StepResult(step)
            self.widgets[step.name] = widget
            rows.extend([
                widget,
                HR(),
            ])
        self.pile = Pile(rows)
        return self.pile 
開發者ID:conjure-up,項目名稱:conjure-up,代碼行數:23,代碼來源:steps.py

示例7: build

# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import Pile [as 別名]
def build(self):
        environments = db.get_environment_names()
        reports = [None] + db.get_report_names()

        self._envsel = widgets.ListScrollSelector(environments)
        self._repsel = widgets.ListScrollSelector(reports)
        self._tclist = urwid.SimpleListWalker([])
        butcols = urwid.Columns([
                ("pack", urwid.Text("environment:")),
                AM(self._envsel, "selectable", "butfocus"),
                ("pack", urwid.Text("report:")),
                AM(self._repsel, "selectable", "butfocus"),
            ], dividechars=2)
        header = urwid.Pile([
        AM(urwid.Text("Select environment, report, and set options. Use Tab to switch to environment selector. Selected:"), "subhead"),
                urwid.BoxAdapter(urwid.ListBox(self._tclist), 2),
                butcols,
        ])
        body = self._build_test_selector(False)
        return urwid.Frame(body, header=header, focus_part="body") 
開發者ID:kdart,項目名稱:pycopia,代碼行數:22,代碼來源:runner.py

示例8: get_form_buttons

# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import Pile [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

示例9: build

# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import Pile [as 別名]
def build(self):
        header = urwid.Pile([
                urwid.AttrMap(urwid.Text("Create Equipment"), "formhead"),
                urwid.AttrMap(urwid.Text("Arrow keys navigate, Enter to select form button. Type into other fields."), "formhead"),
                urwid.Divider(),
                ])
        formstack = []
        for groupname, group in [
                (None, ("model", "name", "serno")),
                ("Localization", ("language",)),
                ("Asset management", ("owner", "location", "sublocation", "vendor")),
                ("Automation", ("account",)),
                ("structural relationship", ('parent',)),
                ("Addtional Info", ("comments",)),
                ]:
            if groupname:
                formstack.append(self.build_divider(groupname))
            for colname in group:
                colmd = self.metadata[colname]
                wid = self.build_input(colmd)
                formstack.append(wid)
        data = self.get_default_data(["active", "addeddate"])
        formstack.append(self.get_form_buttons(data, create=True))
        listbox = urwid.ListBox(urwid.SimpleListWalker(formstack))
        return urwid.Frame(urwid.AttrMap(listbox, 'body'), header=header) 
開發者ID:kdart,項目名稱:pycopia,代碼行數:27,代碼來源:widgets.py

示例10: __init__

# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import Pile [as 別名]
def __init__(self, user, typing=None, is_read_only=False):
        self.read_only_widget = urwid.Text('You have no power here!', align='center')
        if typing != None:
            top_separator = TextDivider(('is_typing', '{} {} is typing...'.format(
                get_icon('keyboard'),
                typing
            )))
        else:
            top_separator = urwid.Divider('─')
        self.prompt_widget = MessagePrompt(user)
        middle = urwid.WidgetPlaceholder(self.read_only_widget if is_read_only else self.prompt_widget)
        self.body = urwid.Pile([
            urwid.WidgetPlaceholder(top_separator),
            middle,
            urwid.Divider('─')
        ])
        self._typing = typing
        super(MessageBox, self).__init__(self.body, None, {'prompt': 'active_prompt'}) 
開發者ID:haskellcamargo,項目名稱:sclack,代碼行數:20,代碼來源:components.py

示例11: __init__

# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import Pile [as 別名]
def __init__(self, ts, channel_id, user, text, indicators, reactions=(), attachments=()):
        self.ts = ts
        self.channel_id = channel_id
        self.user_id = user.id
        self.markdown_text = text
        self.original_text = text.original_text
        self.text_widget = urwid.WidgetPlaceholder(text)
        main_column = [urwid.Columns([('pack', user), self.text_widget])]
        main_column.extend(attachments)
        self._file_index = len(main_column)
        if reactions:
            main_column.append(urwid.Columns([
                ('pack', reaction) for reaction in reactions
            ]))
        self.main_column = urwid.Pile(main_column)
        columns = [
            ('fixed', 7, Time(ts)),
            self.main_column,
            ('fixed', indicators.size, indicators)
        ]
        self.contents = urwid.Columns(columns)
        super(Message, self).__init__(self.contents, None, {
            None: 'active_message',
            'message': 'active_message'
        }) 
開發者ID:haskellcamargo,項目名稱:sclack,代碼行數:27,代碼來源:message.py

示例12: __init__

# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import Pile [as 別名]
def __init__(self, provider, date):

        self.game_date = date

        self.toolbar = Toolbar()
        urwid.connect_signal(
            self.toolbar, "provider_change",
            lambda w, p: self.set_provider(p)
        )

        self.table_placeholder = urwid.WidgetPlaceholder(urwid.Text(""))

        self.datebar = DateBar(self.game_date)
        # self.table = GamesDataTable(self.toolbar.sport_id, self.game_date) # preseason
        self.pile  = urwid.Pile([
            (1, self.toolbar),
            (1, self.datebar),
            ("weight", 1, self.table_placeholder)
        ])
        self.pile.focus_position = 2

        super(ScheduleView, self).__init__(self.pile)
        self.set_provider(provider) 
開發者ID:tonycpsu,項目名稱:mlbstreamer,代碼行數:25,代碼來源:__main__.py

示例13: set_y_label

# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import Pile [as 別名]
def set_y_label(self, y_label):
        if not y_label:
            text = urwid.Text("1")
            pile = urwid.Pile([urwid.ListBox([text])])
            self.y_label = ('fixed', 1, pile)
            return

        str_y_label = [str(i) for i in y_label]
        y_label_nums = str_y_label[1:]
        y_list_walker = [(1, urwid.ListBox([urwid.Text(str_y_label[0])]))]

        for num in y_label_nums:
            y_list_walker = [urwid.ListBox([urwid.Text(num)])] + y_list_walker

        y_list_walker = urwid.Pile(y_list_walker, focus_item=0)
        y_scale_len = len(max(str_y_label, key=len))

        self.y_label = ('fixed', y_scale_len, y_list_walker) 
開發者ID:amanusk,項目名稱:s-tui,代碼行數:20,代碼來源:complex_bar_graph.py

示例14: generate_content

# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import Pile [as 別名]
def generate_content(status_code):
    try:
        code_descriptions, num, status_code = get_yaml_dictionary(status_code)
        content = code_descriptions[status_code]
        pile = urwid.Pile([
            urwid.Text("STATCODE: The Manual for HTTP Status Codes and Headers\n", align="center"),
            urwid.Text(("title", "STATUS MESSAGE" if num else "HEADER INFO")),
            urwid.Padding(
                urwid.Text(''.join([str(status_code), ": " if num else ", Example= ", content["message"], '\n'])),
                left=5),
            urwid.Text(("title", "CATEGORY")),
            urwid.Padding(urwid.Text(''.join([content["category"], '\n'])), left=5),
            urwid.Text(("title", "DESCRIPTION")),
            urwid.Padding(urwid.Text(''.join([content["description"], '\n'])), left=5),
            urwid.Text(("title", "COPYRIGHT")),
            urwid.Padding(urwid.Text(''.join([__load_file_data(num), '\n'])), left=5),
        ])
        padding = urwid.Padding(Scrollable(pile), left=1, right=1)

        return padding
    except KeyError:  # None is used to print "not recognized", so KeyError. Other errors have nothing to do with it
        return None 
開發者ID:shobrook,項目名稱:statcode,代碼行數:24,代碼來源:statcode.py

示例15: _find_match_indexes

# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import Pile [as 別名]
def _find_match_indexes(self, size):
        phrase = self._search_phrase
        case_sensitive = self._case_sensitive

        def row_matches(row):
            for _,_,text in row:
                text_dec = text.decode()
                if case_sensitive and phrase in text_dec:
                    return True
                elif not case_sensitive and phrase in text_dec.casefold():
                    return True
            return False

        # Render the full Pile canvas because long lines can cause line breaks
        # and so we can't just get indexes from self._lines.
        full_canv = self._w.base_widget.render((size[0],), False)
        indexes = []
        for i,row in enumerate(full_canv.content()):
            if row_matches(row):
                indexes.append(i)
        self._match_indexes = indexes 
開發者ID:rndusr,項目名稱:stig,代碼行數:23,代碼來源:text.py


注:本文中的urwid.Pile方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。