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


Python urwid.CheckBox方法代碼示例

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


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

示例1: edit

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

# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import CheckBox [as 別名]
def build(self):
        self._showeq = urwid.Text("")
        eqi = self._create_equipment_input()
        maxlen = 0
        uutcb = urwid.CheckBox("DUT/UUT", state=False)
        urwid.connect_signal(uutcb, 'change', self._uut_select)
        blist = [AM(uutcb, "important")]
        for role in self._roles:
            label = str(role)
            maxlen = max(len(label), maxlen)
            but = urwid.CheckBox(str(role), state=False)
            urwid.connect_signal(but, 'change', self._multi_select, role)
            blist.append(but)
        roleboxes = urwid.Padding(urwid.GridFlow(blist, maxlen+4, 1, 0, "left"))
        # buttons
        ok, cancel = self.get_form_buttons()
        buts = urwid.Columns([(10, ok), (10, cancel)], dividechars=1, focus_column=0)
        return urwid.ListBox(urwid.SimpleListWalker([eqi, AM(self._showeq, "flagged"), roleboxes, buts])) 
開發者ID:kdart,項目名稱:pycopia,代碼行數:20,代碼來源:widgets.py

示例3: generate_password

# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import CheckBox [as 別名]
def generate_password(self, originator, args=None):
        self.mode = 'generate'
        if args:
            path, length, symbols, force = args
        else:
            path, length, symbols, force = '', 16, True, False
        if not path and self.current != '.':
            path = self.current + '/'
        self.set_header('GENERATE PASSWORD')
        self._clear_box()
        self.generate_password_path = EditWithEnter(
            ("highlight", "Password Name: "), path, multiline=False,
            enter_handler=self.call_generate)
        self.generate_password_length = urwid.IntEdit("Length: ", default=length)
        self.generate_password_symbols = urwid.CheckBox("Symbols", state=symbols)
        self.generate_password_force = urwid.CheckBox("Overwrite existing passwords with that name", state=force)
        self.box.body.append(self.generate_password_path)
        self.box.body.append(self.generate_password_length)
        self.box.body.append(self.generate_password_symbols)
        self.box.body.append(self.generate_password_force)
        self.box.body.append(ActionButton('GENERATE', self.call_generate))
        self.box.body.append(BackButton('BACK', self.load_dispatch, self.current, self)) 
開發者ID:Kwpolska,項目名稱:upass,代碼行數:24,代碼來源:__main__.py

示例4: playlistitems

# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import CheckBox [as 別名]
def playlistitems(title):
	global listitems
	bt_sv = urwid.Button("Save")
	urwid.connect_signal(bt_sv, 'click', showmenu)
	bt_ca = urwid.Button("Cancel")
	urwid.connect_signal(bt_ca, 'click', showmenu)
	bt_sa = urwid.Button("Select all")
	urwid.connect_signal(bt_sa, 'click', select_all)
	bt_da = urwid.Button("Deselect all")
	urwid.connect_signal(bt_da, 'click', deselect_all)
	footer = urwid.Columns([bt_sv, bt_sa, bt_da, bt_ca], 1)
	items = []
	for item in playlist_names:
		items.append(urwid.CheckBox(item['name'], is_selected(item['id']), on_state_change=checkbox_callback, user_data=item['id']))
	start.original_widget = TabFrame(urwid.ListBox(urwid.SimpleListWalker(items)), header=urwid.Text("Select Playlists"), footer=footer, focus_part='body')

# main menu button handler 
開發者ID:helpsterTee,項目名稱:spotify-playlists-2-deezer,代碼行數:19,代碼來源:spotify-restore.py

示例5: _build_test_selector

# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import CheckBox [as 別名]
def _build_test_selector(self, include_testcases):
        cb = AM(urwid.CheckBox("Include test cases", False, on_state_change=self._refresh_cb), "selectable", "butfocus")
        gobut = urwid.Button("Go")
        urwid.connect_signal(gobut, 'click', self._runtest)
        gobut = urwid.AttrWrap(gobut, 'selectable', 'butfocus')
        tb = self._get_testtree(include_testcases)
        return urwid.Pile([(1, urwid.Filler(cb)), tb, urwid.Filler(gobut)]) 
開發者ID:kdart,項目名稱:pycopia,代碼行數:9,代碼來源:runner.py

示例6: __init__

# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import CheckBox [as 別名]
def __init__(self, model, metadata, value, legend=None):
        self.wid = urwid.CheckBox(metadata.colname, state=value)
        self.__super.__init__(self._col_creator(metadata, self.wid, legend)) 
開發者ID:kdart,項目名稱:pycopia,代碼行數:5,代碼來源:widgets.py

示例7: _build_list

# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import CheckBox [as 別名]
def _build_list(self):
        choices = get_related_choices(self.session, self.modelclass, self.metadata, None)
        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,代碼行數:15,代碼來源:widgets.py

示例8: __init__

# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import CheckBox [as 別名]
def __init__(self, app):
        self.app = app
        self.username = urwid.Edit(
            edit_text=settings.get('username', 'play_settings') or ''
        )
        self.password = urwid.Edit(
            mask='*', edit_text=settings.get('password', 'play_settings') or ''
        )
        self.device_id = urwid.Edit(
            edit_text=settings.get('device_id', 'play_settings') or ''
        )
        self.download_tracks = urwid.CheckBox(
            'Download tracks before playback',
            state=settings.get('download_tracks', 'play_settings') or False
        )
        self.equalizer = Equalizer()
        super(SettingsPage, self).__init__([urwid.ListBox(urwid.SimpleListWalker([
            urwid.Text('Settings'),
            urwid.Divider(' '),
            urwid.Text('Username'),
            urwid.AttrWrap(self.username, 'input', 'input_focus'),
            urwid.Divider(' '),
            urwid.Text('Password'),
            urwid.AttrWrap(self.password, 'input', 'input_focus'),
            urwid.Divider(' '),
            urwid.Text('Device ID'),
            urwid.AttrWrap(self.device_id, 'input', 'input_focus'),
            urwid.Divider(' '),
            self.download_tracks,
            urwid.Divider(' '),
            urwid.AttrWrap(urwid.Button(
                'Save', on_press=self.on_save
            ), 'input', 'input_focus'),
            urwid.Divider(u'\u2500'),
            self.equalizer,
        ]))]) 
開發者ID:and3rson,項目名稱:clay,代碼行數:38,代碼來源:settings.py

示例9: __init__

# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import CheckBox [as 別名]
def __init__(self, return_fn, source_list, default_source_conf):

        self.return_fn = return_fn

        # create the cancel and apply buttons, and put the in an urwid column
        cancel_button = urwid.Button('Cancel', on_press=self.on_cancel)
        cancel_button._label.align = 'center'
        apply_button = urwid.Button('Apply', on_press=self.on_apply)
        apply_button._label.align = 'center'

        if_buttons = urwid.Columns([apply_button, cancel_button])

        self.sensor_status_dict = {}
        sensor_column_list = []
        self.sensor_button_dict = {}
        self.active_sensors = {}
        for source in source_list:
            source_name = source.get_source_name()

            # get the saves sensor visibility list
            if default_source_conf[source_name]:
                # print(str(default_source_conf[source_name]))
                self.sensor_status_dict[source_name] =\
                    copy.deepcopy(default_source_conf[source_name])
            else:
                self.sensor_status_dict[source_name] =\
                    [True] * len(source.get_sensor_list())

            self.sensor_button_dict[source_name] = []
            self.active_sensors[source_name] = []

            # add the title at the head of the checkbox column
            sensor_title_str = source_name
            sensor_title = urwid.Text(
                ('bold text', sensor_title_str), 'center')

            # create the checkbox buttons with the saved visibility
            for sensor, s_tatus in \
                    zip(source.get_sensor_list(),
                        self.sensor_status_dict[source_name]):
                cb = urwid.CheckBox(sensor, s_tatus)
                self.sensor_button_dict[source_name].append(cb)
                self.active_sensors[source_name].append(s_tatus)

            sensor_title_and_buttons = \
                [sensor_title] + self.sensor_button_dict[source_name]
            listw = urwid.SimpleFocusListWalker(sensor_title_and_buttons)

            sensor_column_list.append(urwid.Pile(listw))

        sensor_select_widget = urwid.Columns(sensor_column_list)

        list_temp = [sensor_select_widget, if_buttons]
        listw = urwid.SimpleFocusListWalker(list_temp)
        self.main_window = urwid.LineBox(ViListBox(listw))

        max_height = 6
        for sensor, s_tatus in self.active_sensors.items():
            max_height = max(max_height, len(s_tatus) + 6)

        self.size = max_height, self.MAX_TITLE_LEN 
開發者ID:amanusk,項目名稱:s-tui,代碼行數:63,代碼來源:sensors_menu.py

示例10: __init__

# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import CheckBox [as 別名]
def __init__(self, parent=None):

        self.text = (
            "{}\n\nClick 'Check' to confirm passwordless is setup. For hosts "
            "that have an AUTHFAIL/NOPASSWD status, enter the root password "
            "and check again.".format(self.title))

        self.check_btn = ui_button(label='Check', align='right',
                                   callback=self.check_access)

        self.enable_password = urwid.CheckBox("Common Password",
                                              state=False,
                                              on_state_change=self.common_pswd_toggle)

        self.common_password = urwid.AttrMap(
                    FixedEdit(edit_text="",
                              multiline=False, width=self.password_length),
                    "title")

        urwid.connect_signal(self.common_password.base_widget,
                             'change',
                             callback=self.common_pswd_change)

        # pending access table elements
        self.pending_table_headings = urwid.Columns([
            (12, urwid.Text('Hostname')),
            (10, urwid.Text('Status')),
            (self.password_length, urwid.Text('Password'))
            ], dividechars=1)
        self.pending_table_title = urwid.Text("Access Pending",
                                              align='center')
        self.pending_table_body = urwid.SimpleListWalker([])
        self.pending_table = urwid.ListBox(self.pending_table_body)

        # ssh ok table elements
        self.sshok_table_title = urwid.Text("Access OK",
                                            align='left')
        self.sshok_table_headings = urwid.Columns([
            (12, urwid.Text('Hostname'))
            ])
        self.sshok_table_body = urwid.SimpleListWalker([])
        self.sshok_table = urwid.ListBox(self.sshok_table_body)

        self.debug = None                   # Unused

        # instance uses a mutex to control updates to the screen when the
        # ssh setup method is called in parallel across each host
        self.table_mutex = threading.Lock()

        UIBaseClass.__init__(self, parent)
        # self.widget_in_focus = 4 
開發者ID:pcuzner,項目名稱:ceph-ansible-copilot,代碼行數:53,代碼來源:host_credentials.py


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