예제 #1
0
 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')
예제 #2
0
파일: boulder.py 프로젝트: ponty/abandi
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)
예제 #3
0
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)
예제 #4
0
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)
예제 #5
0
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)
예제 #6
0
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)
예제 #7
0
def singleChoiceDialog(parent=None, message='', title='', lst=[], style=21):
    return psidialogs.choice(message=message, title=title, choices=lst)
예제 #8
0
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)
예제 #9
0
    
    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()