def add_group(): group = GetTextFromUser(_("Please enter a group name:"), _("Add Group")) if group is None or not group.strip(): return protos = [acct.connection for acct in profile.account_manager.connected_accounts] for proto in protos: with traceguard: proto.add_group(group)
def show(email = None): val = GetTextFromUser(_('Enter an email address:'), _('Edit Account Email: {username}').format(username=oscar.self_buddy.name), default_value = email or '') if val is None or not val.strip(): return log.info('setting new account email %r', val) return set(val)
def add_group(): group = GetTextFromUser(_('Please enter a group name:'), _('Add Group')) if group is None or not group.strip(): return protos = [ acct.connection for acct in profile.account_manager.connected_accounts ] for proto in protos: with traceguard: proto.add_group(group)
def getinput(obj, parent, needs, callback, **k): diag = None if hasattr(needs, 'Prompt'): diag = needs(parent, obj) elif isinstance(needs, basestring) and needs.startswith('@'): diag = import_function(needs[1:])(parent, obj) if diag is not None: diag.Prompt(callback) diag.Destroy() else: if callable(needs): needs = needs(obj) from pprint import pprint pprint(needs) if len(needs) == 1 and issubclass(needs[0][0], basestring): type, name, default = needs[0] val = GetTextFromUser(name, caption=name, default_value=default) if val is not None: return callback(val) return FormFrame(obj, parent, needs, callback, **k)
def change_password(protocol, cb): val = GetTextFromUser(_('Enter a new password for {username}:'.format( username=protocol.username)), _('Change Password'), default_value=protocol.password, password=True) if val: cb(val)
def format_screenname(oscar, set): oldval = str(oscar.self_buddy.nice_name) while True: line1 = _('Enter a formatted screenname for {username}').format(username=oscar.username) line2 = _('The new screenname must be the same as the old one, except for changes in capitalization and spacing.') val = GetTextFromUser(u'%s\n\n%s' % (line1, line2), caption = _('Edit Formatted Screenname'), default_value = oldval) if val is None: return elif val.lower().replace(' ', '') == oldval.lower().replace(' ', ''): print 'setting new formatted name', val return set(str(val))
def rename_gui(self): from gui.toolbox import GetTextFromUser localalias = self.alias if localalias is None: localalias = '' s = GetTextFromUser(_('Enter an alias for %s:') % self.name, caption = _('Rename %s') % self.name, default_value = localalias ) if s is not None: if s == '' or s.strip(): # dialog returns None if "Cancel" button is pressed -- that means do nothing # rename expects None to mean "no alias" and anything else to mean an alias--so # do the bool check to turn '' into None here. self.rename(s if s else None) return s
def rename_gui(self): from gui.toolbox import GetTextFromUser localalias = self.alias if localalias is None: localalias = '' s = GetTextFromUser(_('Enter an alias for %s:') % self.name, caption=_('Rename %s') % self.name, default_value=localalias) if s is not None: if s == '' or s.strip(): # dialog returns None if "Cancel" button is pressed -- that means do nothing # rename expects None to mean "no alias" and anything else to mean an alias--so # do the bool check to turn '' into None here. self.rename(s if s else None) return s
def set_priority(jabber, set): val = GetTextFromUser(_('Enter a priority for %s:' % jabber.username), caption=_('Set Jabber Priority'), default_value=str(jabber.priority)) if val is not None: try: set(int(val)) except ValueError: pass
def rename_gui(self, callback=None): from gui.toolbox import GetTextFromUser new_name = GetTextFromUser(_( 'Enter a new name for {name}:'.format(name=self.name)), caption=_('Rename Group'), default_value=self.name) if not new_name: return callback.success() else: return self._rename(new_name, callback)
def join_chat_room(irc, join): val = GetTextFromUser(_('Enter a room name:'), caption=_('Join IRC Room')) if val is not None: join(val)