Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import tkinter as tk
- import requests
- import os
- import ast
- import errno
- from tkinter import messagebox as mb
- try:
- import shutil
- except ModuleNotFoundError:
- os.system("pip install shutil")
- import shutil
- __root = frame1
- def mkdir_p(path):
- global os
- global errno
- try:
- os.makedirs(path)
- except OSError as exc:
- if exc.errno == errno.EEXIST and os.path.isdir(path):
- pass
- else: raise
- def sow(path):
- global mkdir_p
- mkdir_p(os.path.dirname(path))
- return open(path, 'w')
- def sowb(path):
- global mkdir_p
- mkdir_p(os.path.dirname(path))
- return open(path, 'wb')
- def uninstall_app(name):
- global mb
- global ast
- global homescreen
- global os
- global shutil
- infofile = open(f"T:/ProgramData/Store/Apps/{name}/.info", "r")
- appinfo = ast.literal_eval(infofile.read())
- infofile.close()
- if mb.askyesno("Uninstall App", "Are you sure you want to uninstall " + appinfo["NAME"] + "?"):
- try:
- try:
- shutil.rmtree(appinfo["LOCATION"])
- os.remove(appinfo["INFOLOCATION"])
- except:
- mb.showinfo("App already uninstalled", f"{appinfo['NAME']} has already been uninstalled. Press OK to continue and remove app data.")
- finally:
- ins_file = open("T:/ProgramData/Store/Installed.info", "r")
- installed = ast.literal_eval(ins_file.read())
- ins_file.close()
- ins_file = open("T:/ProgramData/Store/Installed.info", "w")
- installed.remove(name)
- ins_file.write(str(installed))
- ins_file.close()
- homescreen()
- mb.showinfo("App Uninstalled", f"{appinfo['NAME']} has successfully been uninstalled.")
- except:
- mb.showinfo("Could not uninstall", f"The uninstallation process of {appinfo['NAME']} did not complete. Please try again or contact Techpad for help.")
- else:
- pass
- def install_app(name):
- global mb
- global ast
- global os
- global requests
- global sow
- global sowb
- global show_app
- infofile = open(f"T:/ProgramData/Store/Apps/{name}/.info", "r")
- appinfo = ast.literal_eval(infofile.read())
- infofile.close()
- if mb.askyesno("Install App", f"Are you sure you want to install {appinfo['NAME']}?"):
- try:
- codepage = requests.get(f"https://pastebin.com/raw/{appinfo['PROGRAMID']}")
- rawcode = codepage.text
- infopage = requests.get(f"https://pastebin.com/raw/{appinfo['INFOID']}")
- rawinfo = infopage.text
- fullinfo = ast.literal_eval(rawinfo)
- programfile = sowb(appinfo["PROGRAMLOCATION"])
- programfile.write(bytes(rawcode, "UTF-8"))
- programfile.close()
- infofile = sow(appinfo["INFOLOCATION"])
- infofile.write(rawinfo)
- infofile.close()
- icon = open(f"T:/ProgramData/Store/Apps/{name}/Icon.png", "rb")
- iconconts = icon.read()
- icon.close()
- newicon = sowb(fullinfo["ICONPATH"])
- newicon.write(iconconts)
- newicon.close()
- ins_file = open("T:/ProgramData/Store/Installed.info", "r")
- installed = ast.literal_eval(ins_file.read())
- ins_file.close()
- ins_file = open("T:/ProgramData/Store/Installed.info", "w")
- installed.append(name)
- ins_file.write(str(installed))
- ins_file.close()
- mb.showinfo("App Installed", f"{appinfo['NAME']} has been successfully installed.")
- show_app(name, True)
- except:
- mb.showinfo("Could not install", f"The installation process of {appinfo['NAME']} did not complete. Please try again or contact Techpad for help.")
- else:
- pass
- def update_app(name):
- uninstall_app(name)
- install_app(name)
- def show_app(name, installed):
- global __root
- global ast
- global homescreen
- global uninstall_app
- global install_app
- global update_app
- infofile = open(f"T:/ProgramData/Store/Apps/{name}/.info", "r")
- appinfo = ast.literal_eval(infofile.read())
- infofile.close()
- for child in __root.winfo_children():
- child.destroy()
- back = tk.Button(__root, bd=0, bg='white', activebackground='lightgray', font='TkDefaultFont 20', width=30,
- height=30, command=homescreen)
- back.image = tk.PhotoImage(file='T:/TechOS/Virtual/Images/Back.png')
- back.config(image=back.image)
- back.pack(side='top', anchor='nw')
- iconlabel = tk.Label(__root, text=" " + appinfo["NAME"], compound='left', bg='white', anchor='nw', justify='left', font="TkDefaultFont 20", fg=appinfo["ACCENTCOLOR"])
- iconlabel.image = tk.PhotoImage(file=f"T:/ProgramData/Store/Apps/{name}/Icon64.png")
- iconlabel.config(image=iconlabel.image)
- iconlabel.pack(anchor='nw', side='top', padx=5)
- desclabel = tk.Label(__root, text=appinfo["DESCRIPTION"], bg='white', justify='left', wraplength=200)
- desclabel.pack(side='top', anchor='nw', padx=5, pady=5)
- if appinfo["UNINSTALL"] == True and installed == True:
- uninstall_button = tk.Button(__root, bg='white', bd=1, relief='solid', text='Uninstall', font='TkDefaultFont 15', command=lambda name=name: uninstall_app(name))
- uninstall_button.pack(padx=5, anchor='nw', side='top', pady=5)
- update_button = tk.Button(__root, bg='white', bd=1, relief='solid', text='Update',
- font='TkDefaultFont 15', command=lambda name=name: update_app(name))
- update_button.pack(padx=5, anchor='nw', side='top', pady=5)
- elif installed == True:
- runbutton = tk.Button(__root, text="Open", bg='white', bd=1, relief='solid', font='TkDefaultFont 15',
- command=lambda name=name: startprogram(name))
- runbutton.pack(padx=5, anchor='nw', side='top', pady=5)
- elif installed == False:
- install_button = tk.Button(__root, bg='white', bd=1, relief='solid', text='Install', font='TkDefaultFont 15', command=lambda name=name: install_app(name))
- install_button.pack(padx=5, anchor='nw', side='top', pady=5)
- def homescreen():
- global __root
- global ast
- global show_app
- global tk
- for child in __root.winfo_children():
- child.destroy()
- ins_file = open("T:/ProgramData/Store/Installed.info", "r")
- ins_text = ins_file.read()
- ins_file.close()
- ins_list = ast.literal_eval(ins_text)
- ins_frame = tk.Frame(__root, bd=0, bg='white')
- ins_label = tk.Label(ins_frame, text='Installed', bg='white', font='TkDefaultFont 12 bold')
- ins_label.pack(anchor='nw', side='top', padx=5)
- for element in ins_list:
- tempfile = open(f"T:/ProgramData/Store/Apps/{element}/.info", "r")
- tempinfo = ast.literal_eval(tempfile.read())
- tempfile.close()
- tempbutton = tk.Button(ins_frame, bd=0, text=tempinfo["NAME"], bg='white', relief='solid', compound='top', command=lambda name=element: show_app(name, True), activebackground='lightgray', width=70, wraplength=70)
- tempbutton.image = tk.PhotoImage(file=f"T:/ProgramData/Store/Apps/{element}/Icon64.png")
- tempbutton.config(image=tempbutton.image)
- tempbutton.pack(side="left", padx=5, pady=5, anchor='nw')
- ins_frame.pack(fill='x')
- rec_file = open("T:/ProgramData/Store/Recommended.info", "r")
- rec_text = rec_file.read()
- rec_file.close()
- rec_list = ast.literal_eval(rec_text)
- rec_frame = tk.Frame(__root, bd=0, bg='white')
- rec_label = tk.Label(rec_frame, text='Recommended', bg='white', font='TkDefaultFont 12 bold')
- rec_label.pack(anchor='nw', side='top', padx=5)
- for element in rec_list:
- if element in ins_list:
- ins = True
- else:
- ins = False
- tempfile = open(f"T:/ProgramData/Store/Apps/{element}/.info", "r")
- tempinfo = ast.literal_eval(tempfile.read())
- tempfile.close()
- tempbutton = tk.Button(rec_frame, bd=0, text=tempinfo["NAME"], bg='white', relief='solid', compound='top',
- command=lambda name=element, ins=ins: show_app(name, ins), activebackground='lightgray', width=70, wraplength=70)
- tempbutton.image = tk.PhotoImage(file=f"T:/ProgramData/Store/Apps/{element}/Icon64.png")
- tempbutton.config(image=tempbutton.image)
- tempbutton.pack(side="left", padx=5, pady=5, anchor='nw')
- rec_frame.pack(fill='x')
- aps_file = open("T:/ProgramData/Store/Apps.info", "r")
- aps_text = aps_file.read()
- aps_file.close()
- aps_list = ast.literal_eval(aps_text)
- aps_frame = tk.Frame(__root, bd=0, bg='white')
- aps_label = tk.Label(aps_frame, text='Apps', bg='white', font='TkDefaultFont 12 bold')
- aps_label.pack(anchor='nw', side='top', padx=5)
- for element in aps_list:
- if element in ins_list:
- ins = True
- else:
- ins = False
- tempfile = open(f"T:/ProgramData/Store/Apps/{element}/.info", "r")
- tempinfo = ast.literal_eval(tempfile.read())
- tempfile.close()
- tempbutton = tk.Button(aps_frame, bd=0, text=tempinfo["NAME"], bg='white', relief='solid', compound='top',
- command=lambda name=element, ins=ins: show_app(name, ins), activebackground='lightgray', width=70, wraplength=70)
- tempbutton.image = tk.PhotoImage(file=f"T:/ProgramData/Store/Apps/{element}/Icon64.png")
- tempbutton.config(image=tempbutton.image)
- tempbutton.pack(side="left", padx=5, pady=5, anchor='nw')
- aps_frame.pack(fill='x')
- gms_file = open("T:/ProgramData/Store/Games.info", "r")
- gms_text = gms_file.read()
- gms_file.close()
- gms_list = ast.literal_eval(gms_text)
- gms_frame = tk.Frame(__root, bd=0, bg='white')
- gms_label = tk.Label(gms_frame, text='Games', bg='white', font='TkDefaultFont 12 bold')
- gms_label.pack(anchor='nw', side='top', padx=5)
- for element in gms_list:
- if element in ins_list:
- ins = True
- else:
- ins = False
- tempfile = open(f"T:/ProgramData/Store/Apps/{element}/.info", "r")
- tempinfo = ast.literal_eval(tempfile.read())
- tempfile.close()
- tempbutton = tk.Button(gms_frame, bd=0, text=tempinfo["NAME"], bg='white', relief='solid', compound='top',
- command=lambda name=element, ins=ins: show_app(name, ins), activebackground='lightgray', width=70, wraplength=70)
- tempbutton.image = tk.PhotoImage(file=f"T:/ProgramData/Store/Apps/{element}/Icon64.png")
- tempbutton.config(image=tempbutton.image)
- tempbutton.pack(side="left", padx=5, pady=5, anchor='nw')
- gms_frame.pack(fill='x')
- homescreen()
Add Comment
Please, Sign In to add comment