Python urwid.CheckBox() Examples
The following are 11
code examples of urwid.CheckBox().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
urwid
, or try the search function
.
Example #1
Source File: main.py From wikicurses with MIT License | 6 votes |
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))
Example #2
Source File: widgets.py From pycopia with Apache License 2.0 | 6 votes |
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]))
Example #3
Source File: widgets.py From pycopia with Apache License 2.0 | 6 votes |
def build(self): showeq = urwid.Text(self._testequipment.equipment.name) maxlen = 0 uutcb = urwid.CheckBox("DUT/UUT", state=self._testequipment.UUT) 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) state = role in self._testequipment.roles but = urwid.CheckBox(str(role), state=state) 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) div = urwid.Divider() return urwid.ListBox(urwid.SimpleListWalker([AM(showeq, "flagged"), div, roleboxes, div, buts]))
Example #4
Source File: __main__.py From upass with BSD 3-Clause "New" or "Revised" License | 6 votes |
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))
Example #5
Source File: spotify-restore.py From spotify-playlists-2-deezer with MIT License | 6 votes |
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
Example #6
Source File: runner.py From pycopia with Apache License 2.0 | 5 votes |
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)])
Example #7
Source File: widgets.py From pycopia with Apache License 2.0 | 5 votes |
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))
Example #8
Source File: widgets.py From pycopia with Apache License 2.0 | 5 votes |
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))
Example #9
Source File: host_credentials.py From ceph-ansible-copilot with GNU Lesser General Public License v2.1 | 5 votes |
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
Example #10
Source File: settings.py From clay with GNU General Public License v3.0 | 5 votes |
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, ]))])
Example #11
Source File: sensors_menu.py From s-tui with GNU General Public License v2.0 | 4 votes |
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