def str_encode_decode(self): choice=psidialogs.choice(choices=['Encode','Decode'], message='Pick something.', default=None, title='Encode/Decode') if choice=='Encode': encode_list=psidialogs.choice(choices=['base64','bz2','hex','quopri','uu','zlib'], message='Pick something.', default=None, title='Encode choice') return self.val.encode(encode_list,'strict') else: decode_list=psidialogs.choice(choices=['base64','bz2','hex','quopri','uu','zlib'], message='Pick something.', default=None, title='Encode choice') return self.val.decode(decode_list,'strict')
def main(): games = search_games(where='name like "%boulder%"') dic = dict([(norm(x.name), x) for x in games]) name = choice(sorted(dic.keys())) if name: game = dic[name] run_game(game.source, game.id, auto_install=1)
def selectfunc(title='', function=None, **kwargs): if function: dialog(function, title, **kwargs) else: while 1: funcs = psidialogs.FUNCTION_NAMES funcs.sort() func = psidialogs.choice(funcs, 'Select function!', title=title) if not func: break dialog(func, title, **kwargs)
def remove_boards_gui(hwpack=""): """remove boards by GUI.""" if not hwpack: if len(hwpack_names()) > 1: hwpack = psidialogs.choice(hwpack_names(), "select hardware package to select board from!", title="select") else: hwpack = hwpack_names()[0] print("%s selected" % hwpack) if hwpack: sel = psidialogs.multi_choice( board_names(hwpack), "select boards to remove from %s!" % boards_txt(hwpack), title="remove boards" ) print("%s selected" % sel) if sel: for x in sel: remove_board(x) print("%s was removed" % x)
def selectbackend(backend=None, title='', **kwargs): if backend: BackendLoader().force(backend) selectfunc(title, **kwargs) else: while 1: #d = dict([(x.backend, x.name) for x in psidialogs.all_backends()]) #names=sorted(d.keys() names=sorted(BackendLoader().all_names) b = psidialogs.choice(names, 'Select backend!', title=title) if not b: break BackendLoader().force(b) try: BackendLoader().selected() except Exception, detail: BackendLoader().force(None) psidialogs.text('Exception:\n' + unicode(detail)) continue #psidialogs.set_backend(force_backend=d[b]) selectfunc(title, **kwargs)
def remove_boards_gui(hwpack=''): """remove boards by GUI.""" if not hwpack: if len(hwpack_names()) > 1: hwpack = psidialogs.choice( hwpack_names(), 'select hardware package to select board from!', title='select') else: hwpack = hwpack_names()[0] print('%s selected' % hwpack) if hwpack: sel = psidialogs.multi_choice(board_names(hwpack), 'select boards to remove from %s!' % boards_txt(hwpack), title='remove boards') print('%s selected' % sel) if sel: for x in sel: remove_board(x) print('%s was removed' % x)
def singleChoiceDialog(parent=None, message='', title='', lst=[], style=21): return psidialogs.choice(message=message, title=title, choices=lst)
def choicebox(message="Pick something.", title="", choices=["program logic error - no choices specified"]): """Original doc: Present the user with a list of choices. return the choice that he selects. return None if he cancels the selection selection. """ return psidialogs.choice(message=message, title=title, choices=choices)
def str_max(self): return max(self.val) def str_min(self): return min(self.val) if __name__ == "__main__": input_str=psidialogs.ask_string(message='Enter String.', default='', title='String Input') str_a1=STRING(input_str) while True: str_methods=psidialogs.choice(choices=['capital()','center()','count()',\ 'encode()_decode()','endswith()','expandtabs()','find()','index()',\ 'isalnum()','isalpha()','isdigit()','isnumeric()',\ 'isspace()','istitle()','isupper()',\ 'join()','len()','ljust()','lower()','maketrans()','max()','min()','Exit'], message='Make a choice.', default=None, title='Strings') if str_methods=='capital()': print str_a1.str_capital() elif str_methods=='center()': print str_a1.str_center() elif str_methods=='count()': print str_a1.str_count() elif str_methods=='encode()_decode()': print str_a1.str_encode_decode()