def get_local_apps(category=CATEGORY_ALL): """Returns a list of apps that can be found in the apps folder""" apps = [ App(folder_name) for folder_name in os.listdir("apps") if filesystem.is_dir("apps/" + folder_name) ] return [app for app in apps if app.matches_category(category)]
def install(app): clear() connect() with dialogs.WaitingMessage(text="Installing %s" % app, title="TiLDA App Library") as message: if not app.files: app.fetch_api_information() if not filesystem.is_dir(app.folder_path): os.mkdir(app.folder_path) download_app(app, message)
def get_local_apps(category=CATEGORY_ALL): """Returns a list of apps that can be found in the apps folder""" apps = [App(folder_name) for folder_name in os.listdir("apps") if filesystem.is_dir("apps/" + folder_name)] return [app for app in apps if app.matches_category(category)]
def file_loader(): width = ugfx.width() height = ugfx.height() buttons.disable_menu_reset() # Create visual elements win_header = ugfx.Container(0,0,width,30) win_files = ugfx.Container(0,33,int(width/2),height-33) win_preview = ugfx.Container(int(width/2)+2,33,int(width/2)-2,height-33) components = [win_header, win_files, win_preview] ugfx.set_default_font(ugfx.FONT_TITLE) components.append(ugfx.Label(3,3,width-10,29,"Choose App",parent=win_header)) ugfx.set_default_font(ugfx.FONT_MEDIUM) options = ugfx.List(0,30,win_files.width(),win_files.height()-30,parent=win_files) btnl = ugfx.Button(5,3,20,20,"<",parent=win_files) btnr = ugfx.Button(win_files.width()-7-20,3,20,20,">",parent=win_files) btnr.attach_input(ugfx.JOY_RIGHT,0) btnl.attach_input(ugfx.JOY_LEFT,0) components.append(options) components.append(btnr) components.append(btnl) ugfx.set_default_font(ugfx.FONT_MEDIUM_BOLD) l_cat = ugfx.Label(30,3,100,20,"Built-in",parent=win_files) components.append(l_cat) components.append(ugfx.Button(10,win_preview.height()-25,20,20,"A",parent=win_preview)) components.append(ugfx.Label(35,win_preview.height()-25,50,20,"Run",parent=win_preview)) components.append(ugfx.Button(80,win_preview.height()-25,20,20,"B",parent=win_preview)) components.append(ugfx.Label(105,win_preview.height()-25,100,20,"Back",parent=win_preview)) components.append(ugfx.Button(10,win_preview.height()-50,20,20,"M",parent=win_preview)) components.append(ugfx.Label(35,win_preview.height()-50,100,20,"Pin/Unpin",parent=win_preview)) ugfx.set_default_font(ugfx.FONT_SMALL) author = ugfx.Label(1,win_preview.height()-78,win_preview.width()-3,20,"by: ",parent=win_preview) desc = ugfx.Label(3,1,win_preview.width()-10,win_preview.height()-83,"",parent=win_preview,justification=ugfx.Label.LEFTTOP) components.append(author) components.append(desc) pinned = database_get("pinned_apps", []) catergories = get_local_app_categories() c_ptr = 0 try: win_header.show() win_files.show() win_preview.show() pinned = database_get("pinned_apps", []) # apps = [] apps_path = [] if is_dir("apps"): for app in os.listdir("apps"): path = "apps/" + app if is_dir(path) and is_file(path + "/main.py"): apps_path.append(path + "/main.py") if is_dir("examples"): for app in os.listdir("examples"): path = "examples/" + app if is_file(path) and path.endswith(".py"): apps_path.append(path) displayed_apps = update_options(options, catergories[c_ptr], pinned) index_prev = -1; while True: pyb.wfi() ugfx.poll() if index_prev != options.selected_index(): if options.selected_index() < len(displayed_apps): author.text("by: %s" % displayed_apps[options.selected_index()].user) desc.text(displayed_apps[options.selected_index()].description) index_prev = options.selected_index() if buttons.is_triggered("JOY_LEFT"): if c_ptr > 0: c_ptr -= 1 btnl.set_focus() l_cat.text(catergories[c_ptr]) displayed_apps = update_options(options, catergories[c_ptr], pinned) index_prev = -1 if buttons.is_triggered("JOY_RIGHT"): if c_ptr < len(catergories)-1: c_ptr += 1 btnr.set_focus() l_cat.text(catergories[c_ptr]) displayed_apps = update_options(options, catergories[c_ptr], pinned) index_prev = -1 if buttons.is_triggered("BTN_MENU"): app = displayed_apps[options.selected_index()] if app.folder_name in pinned: pinned.remove(app.folder_name) else: pinned.append(app.folder_name) update_options(options, catergories[c_ptr], pinned) database_set("pinned_apps", pinned) if buttons.is_triggered("BTN_B"): return None if buttons.is_triggered("BTN_A"): return displayed_apps[options.selected_index()] finally: for component in components: component.destroy()
def file_loader(): width = ugfx.width() height = ugfx.height() buttons.disable_menu_reset() # Create visual elements win_header = ugfx.Container(0, 0, width, 30) win_files = ugfx.Container(0, 33, int(width / 2), height - 33) win_preview = ugfx.Container( int(width / 2) + 2, 33, int(width / 2) - 2, height - 33) components = [win_header, win_files, win_preview] ugfx.set_default_font(ugfx.FONT_TITLE) components.append( ugfx.Label(3, 3, width - 10, 29, "Choose App", parent=win_header)) ugfx.set_default_font(ugfx.FONT_MEDIUM) options = ugfx.List(0, 30, win_files.width(), win_files.height() - 30, parent=win_files) btnl = ugfx.Button(5, 3, 20, 20, "<", parent=win_files) btnr = ugfx.Button(win_files.width() - 7 - 20, 3, 20, 20, ">", parent=win_files) btnr.attach_input(ugfx.JOY_RIGHT, 0) btnl.attach_input(ugfx.JOY_LEFT, 0) components.append(options) components.append(btnr) components.append(btnl) ugfx.set_default_font(ugfx.FONT_MEDIUM_BOLD) l_cat = ugfx.Label(30, 3, 100, 20, "Built-in", parent=win_files) components.append(l_cat) components.append( ugfx.Button(10, win_preview.height() - 25, 20, 20, "A", parent=win_preview)) components.append( ugfx.Label(35, win_preview.height() - 25, 50, 20, "Run", parent=win_preview)) components.append( ugfx.Button(80, win_preview.height() - 25, 20, 20, "B", parent=win_preview)) components.append( ugfx.Label(105, win_preview.height() - 25, 100, 20, "Back", parent=win_preview)) components.append( ugfx.Button(10, win_preview.height() - 50, 20, 20, "M", parent=win_preview)) components.append( ugfx.Label(35, win_preview.height() - 50, 100, 20, "Pin/Unpin", parent=win_preview)) ugfx.set_default_font(ugfx.FONT_SMALL) author = ugfx.Label(1, win_preview.height() - 78, win_preview.width() - 3, 20, "by: ", parent=win_preview) desc = ugfx.Label(3, 1, win_preview.width() - 10, win_preview.height() - 83, "", parent=win_preview, justification=ugfx.Label.LEFTTOP) components.append(author) components.append(desc) pinned = database_get("pinned_apps", []) catergories = get_local_app_categories() c_ptr = 0 try: win_header.show() win_files.show() win_preview.show() pinned = database_get("pinned_apps", []) # apps = [] apps_path = [] if is_dir("apps"): for app in os.listdir("apps"): path = "apps/" + app if is_dir(path) and is_file(path + "/main.py"): apps_path.append(path + "/main.py") if is_dir("examples"): for app in os.listdir("examples"): path = "examples/" + app if is_file(path) and path.endswith(".py"): apps_path.append(path) displayed_apps = update_options(options, catergories[c_ptr], pinned) index_prev = -1 while True: pyb.wfi() ugfx.poll() if index_prev != options.selected_index(): if options.selected_index() < len(displayed_apps): author.text("by: %s" % displayed_apps[options.selected_index()].user) desc.text( displayed_apps[options.selected_index()].description) index_prev = options.selected_index() if buttons.is_triggered("JOY_LEFT"): if c_ptr > 0: c_ptr -= 1 btnl.set_focus() l_cat.text(catergories[c_ptr]) displayed_apps = update_options(options, catergories[c_ptr], pinned) index_prev = -1 if buttons.is_triggered("JOY_RIGHT"): if c_ptr < len(catergories) - 1: c_ptr += 1 btnr.set_focus() l_cat.text(catergories[c_ptr]) displayed_apps = update_options(options, catergories[c_ptr], pinned) index_prev = -1 if buttons.is_triggered("BTN_MENU"): app = displayed_apps[options.selected_index()] if app.folder_name in pinned: pinned.remove(app.folder_name) else: pinned.append(app.folder_name) update_options(options, catergories[c_ptr], pinned) database_set("pinned_apps", pinned) if buttons.is_triggered("BTN_B"): return None if buttons.is_triggered("BTN_A"): return displayed_apps[options.selected_index()] finally: for component in components: component.destroy()