Techpad

TechOS 4

Mar 16th, 2021 (edited)
264
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
E 27.08 KB | None | 0 0
  1. import os
  2. import sys
  3. import tkinter as tk
  4. from tkinter import messagebox as mb
  5.  
  6. root = tk.Tk()
  7. root.minsize(1280, 720)
  8. root.attributes("-fullscreen", True)
  9.  
  10. try:
  11.  
  12.     import time
  13.     from threading import Thread
  14.     import datetime
  15.     try:
  16.         import ast
  17.     except ModuleNotFoundError:
  18.         os.system('pip install ast')
  19.         import ast
  20.     try:
  21.         import random
  22.     except ModuleNotFoundError:
  23.         os.system('pip install random')
  24.         import random
  25.     try:
  26.         from PIL import Image, ImageTk
  27.     except ModuleNotFoundError:
  28.         os.system('pip install pillow')
  29.         from PIL import Image, ImageTk
  30.  
  31.     PROGRAMLIST_STARTUP = open("T:/TechOS/Virtual/Settings/PROGRAMLIST_STARTUP.set", "r").read()
  32.     RANDOMIZE_WALLPAPERS = open("T:/TechOS/Virtual/Settings/RANDOMIZE_WALLPAPERS.set", "r").read()
  33.     TECHMAIL_STARTUP = open("T:/TechOS/Virtual/Settings/TECHMAIL_STARTUP.set", "r").read()
  34.     SET_WALLPAPER = open("T:/TechOS/Virtual/Settings/SET_WALLPAPER.set", "r").read()
  35.     DARK_SYSTEM_APPS = open("T:/TechOS/Virtual/Settings/DARK_SYSTEM_APPS.set", "r").read()
  36.     ACCENT_COLOR = open("T:/TechOS/Virtual/Settings/ACCENT_COLOR.set", "r").read()
  37.     LARGER_BORDERS = open("T:/TechOS/Virtual/Settings/LARGER_BORDERS.set", "r").read()
  38.  
  39.     def color_variant(hex_color, brightness_offset=1):
  40.         """ takes a color like #87c95f and produces a lighter or darker variant """
  41.         if len(hex_color) != 7:
  42.             raise Exception("Passed %s into color_variant(), needs to be in #87c95f format." % hex_color)
  43.         rgb_hex = [hex_color[x:x+2] for x in [1, 3, 5]]
  44.         new_rgb_int = [int(hex_value, 16) + brightness_offset for hex_value in rgb_hex]
  45.         new_rgb_int = [min([255, max([0, i])]) for i in new_rgb_int] # make sure new values are between 0 and 255
  46.         # hex() produces "0x88", we want just "88"
  47.         return "#" + "".join(["{:02x}".format(i) for i in new_rgb_int])
  48.  
  49.     try:
  50.         BLACK_ACCENT_COLOR = color_variant(ACCENT_COLOR, -200)
  51.         DIM_ACCENT_COLOR = color_variant(ACCENT_COLOR, -20)
  52.         DARK_ACCENT_COLOR = color_variant(ACCENT_COLOR, -10)
  53.         LIGHT_ACCENT_COLOR = color_variant(ACCENT_COLOR, 10)
  54.         BRIGHT_ACCENT_COLOR = color_variant(ACCENT_COLOR, 20)
  55.         WHITE_ACCENT_COLOR = color_variant(ACCENT_COLOR, 200)
  56.     except ValueError:
  57.         acfile = open("T:/TechOS/Virtual/Settings/ACCENT_COLOR.set", "w")
  58.         acfile.write("#0090ff")
  59.         acfile.close()
  60.         raise Exception("Bad color name: " + ACCENT_COLOR)
  61.  
  62.     sysappbg = 'white'
  63.     sysappfg = 'black'
  64.     sysappacbg = 'lightgray'
  65.  
  66.     if DARK_SYSTEM_APPS == "True":
  67.         sysappbg = 'gray10'
  68.         sysappfg = 'gray90'
  69.         sysappacbg = 'gray20'
  70.  
  71.     root.config(bg="white", cursor='@T:/TechOS/Virtual/Cursors/Arrow.ani')
  72.     root.title("TechOS Virtual")
  73.     root.resizable(False, False)
  74.  
  75.     root.update()
  76.  
  77.     wallpaperwidth = root.winfo_width()
  78.     wallpaperheight = root.winfo_height()
  79.  
  80.     wallpaperfolder = os.listdir("T:/TechOS/Virtual/Images/Wallpapers")
  81.     if RANDOMIZE_WALLPAPERS == "True":
  82.         wallpaperpath = "T:/TechOS/Virtual/Images/Wallpapers/" + random.choice(wallpaperfolder)
  83.     else:
  84.         wallpaperpath = "T:/TechOS/Virtual/Images/Wallpapers/" + SET_WALLPAPER
  85.     try:
  86.         wallpaper0 = Image.open(wallpaperpath)
  87.         wallpaper0 = wallpaper0.resize((wallpaperwidth, wallpaperheight), Image.ANTIALIAS)
  88.         wallpaper = ImageTk.PhotoImage(wallpaper0)
  89.         backgroundlabel = tk.Label(bg=ACCENT_COLOR)
  90.         backgroundlabel.image = wallpaper
  91.         backgroundlabel.config(image=backgroundlabel.image)
  92.         backgroundlabel.place(x=0, y=0, relwidth=1.0, relheight=1.0)
  93.         wallpaperloaded = True
  94.     except FileNotFoundError:
  95.         backgroundlabel = tk.Label(bg=ACCENT_COLOR)
  96.         backgroundlabel.place(x=0, y=0, relwidth=1.0, relheight=1.0)
  97.         wallpaperloaded = False
  98.  
  99.     def exit():
  100.         exitsure = mb.askyesno("Exit TechOS Virtual", "Are you sure you want to exit TechOS?")
  101.         if exitsure:
  102.             root.destroy()
  103.             sys.exit()
  104.         else:
  105.             pass
  106.  
  107.     neframe = tk.Frame(root, bg='white', bd=1, relief='solid')
  108.     neframe.pack(side='top', anchor='ne')
  109.  
  110.     tosimage = tk.PhotoImage(file='T:/TechOS/Virtual/Images/TechOS Logo Shaded.png')
  111.     smalltosimage = tosimage.subsample(2, 2)
  112.     toslogo = tk.Label(neframe, bg='white')
  113.     toslogo.image = smalltosimage
  114.     toslogo.config(image=toslogo.image)
  115.     toslogo.pack(side='top', anchor='ne', padx=5, pady=5)
  116.  
  117.     exitbutton = tk.Button(neframe, text="Exit Virtual", command=exit, bg='white', bd=0, fg='black', activeforeground=LIGHT_ACCENT_COLOR, activebackground=WHITE_ACCENT_COLOR)
  118.     exitbutton.pack(side='top', anchor='ne', padx=5, pady=5)
  119.  
  120.     taskbar = tk.Frame(root, height=30, bd=0, bg='gray10')
  121.     taskbar.pack(side='bottom', anchor='s', expand=True, fill='x')
  122.  
  123.     time_label = tk.Label(taskbar, text="??:?? ??", bg='gray10', width=10, fg='gray90')
  124.     time_label.pack(side='right', anchor='e', fill='y')
  125.  
  126.     def clock():
  127.         time1 = datetime.datetime.now().strftime("%H:%M/%p")
  128.         time2, time3 = time1.split('/')
  129.         hour, minutes = time2.split(':')
  130.         if int(hour) > 12 and int(hour) < 24:
  131.             time = str(int(hour) - 12) + ':' + minutes + ' ' + time3
  132.         else:
  133.             time = time2 + ' ' + time3
  134.         time_label.config(text=time)
  135.         time_label.after(1000, clock)
  136.  
  137.     Thread(target=clock, daemon=True).start()
  138.  
  139.     focused_window = None
  140.  
  141.     def create_window(x=100, y=100, width=400, height=300, title="Window", img="T:/TechOS/Virtual/Images/DefaultProgramIcon.png", program=None, code=None):
  142.         global focused_window
  143.         global LARGER_BORDERS
  144.         parentframe = tk.Frame(root, bd=1, relief='solid', cursor='@T:/TechOS/Virtual/Cursors/MoveTLBR.ani')
  145.         parentframe.place(x=x, y=y, width=width, height=height)
  146.         if LARGER_BORDERS == 'True':
  147.             parentframe.config(bd=2)
  148.         frame0 = tk.Frame(parentframe, bd=0, relief='solid', bg='white', height=30, cursor='@T:/TechOS/Virtual/Cursors/Arrow.ani')
  149.         frame0.pack(side='top', anchor='n', expand=False, fill='x')
  150.         frame0.pack_propagate(0)
  151.         frame1 = tk.Frame(parentframe, bd=0, relief='solid', bg='white', cursor='@T:/TechOS/Virtual/Cursors/Arrow.ani')
  152.         frame1.pack(side='bottom', anchor='n', expand=True, fill='both')
  153.         frame1.pack_propagate(0)
  154.         titleimg = tk.PhotoImage(file=img)
  155.         title = tk.Label(frame0, bg='white', text='  ' + title, justify='left', fg='gray50', compound='left')
  156.         title.image = titleimg
  157.         title.config(image=title.image)
  158.         title.pack(side='left', anchor='w', padx=5)
  159.  
  160.         restorex = x
  161.         restorey = y
  162.         minstorex = x
  163.         minstorey = y
  164.         restorew = width
  165.         restoreh = height
  166.         max = False
  167.         min = False
  168.  
  169.         closebutton = tk.Button(frame0, bg='white', text='⨉', fg='gray50', padx=15, bd=0, font='TkDefaultFont 12')
  170.         closebutton.pack(side='right', anchor='e', fill='y')
  171.         def clbhover(e):
  172.             closebutton.config(bg='red', fg='white')
  173.         def clbunhover(e):
  174.             closebutton.config(bg=ACCENT_COLOR)
  175.         def clbunhover2(e):
  176.             closebutton.config(bg='white', fg='gray50')
  177.         def clbpress(e):
  178.             closebutton.config(bg='darkred')
  179.             return "break"
  180.         def clbunpress(e):
  181.             px, py = root.winfo_pointerxy()
  182.             widget = root.winfo_containing(px, py)
  183.             if widget == closebutton:
  184.                 parentframe.destroy()
  185.                 try:
  186.                     tbutton.destroy()
  187.                 except:
  188.                     pass
  189.                 focused_window = None
  190.             else:
  191.                 pass
  192.         closebutton.bind("<Enter>", clbhover)
  193.         closebutton.bind("<Leave>", clbunhover2)
  194.         closebutton.bind("<Button-1>", clbpress)
  195.         closebutton.bind("<ButtonRelease-1>", clbunpress)
  196.  
  197.         maxbutton = tk.Button(frame0, bg='white', text='△', fg='gray50', padx=15, bd=0, font='TkDefaultFont 12')
  198.         maxbutton.pack(side='right', anchor='e', fill='y')
  199.         def maxhover(e):
  200.             maxbutton.config(bg=BRIGHT_ACCENT_COLOR)
  201.         def maxhover2(e):
  202.             maxbutton.config(bg='gray90')
  203.         def maxunhover(e):
  204.             maxbutton.config(bg=ACCENT_COLOR)
  205.         def maxunhover2(e):
  206.             maxbutton.config(bg='white')
  207.         def maxpress(e):
  208.             maxbutton.config(bg=DIM_ACCENT_COLOR)
  209.             return "break"
  210.         def maxpress2(e):
  211.             maxbutton.config(bg='gray80')
  212.             return "break"
  213.         def maxunpress(e):
  214.             nonlocal restorex
  215.             nonlocal restorey
  216.             nonlocal restorew
  217.             nonlocal restoreh
  218.             nonlocal minstorex
  219.             nonlocal minstorey
  220.             nonlocal max
  221.             px, py = root.winfo_pointerxy()
  222.             widget = root.winfo_containing(px, py)
  223.             if widget == maxbutton:
  224.                 if max == False:
  225.                     restorex = parentframe.winfo_x()
  226.                     restorey = parentframe.winfo_y()
  227.                     restorew = parentframe.winfo_width()
  228.                     restoreh = parentframe.winfo_height()
  229.                     parentframe.place_configure(x=0, y=0, w=root.winfo_width(), h=root.winfo_height() - 30)
  230.                     maxbutton.config(text='▽')
  231.                     max = True
  232.                     minstorex = 0
  233.                     minstorey = 0
  234.                 elif max == True:
  235.                     parentframe.place_configure(x=restorex, y=restorey, width=restorew, height=restoreh)
  236.                     maxbutton.config(text='△')
  237.                     max = False
  238.                     minstorex = parentframe.winfo_x()
  239.                     minstorey = parentframe.winfo_y()
  240.             else:
  241.                 pass
  242.             lift('')
  243.         maxbutton.bind("<Enter>", maxhover2)
  244.         maxbutton.bind("<Leave>", maxunhover2)
  245.         maxbutton.bind("<Button-1>", maxpress2)
  246.         maxbutton.bind("<ButtonRelease-1>", maxunpress)
  247.  
  248.         def lift(e):
  249.             global focused_window
  250.             parentframe.lift()
  251.             taskbar.lift()
  252.             focused_window = parentframe
  253.  
  254.         parentframe.bind("<ButtonPress>", lift)
  255.         frame0.bind("<ButtonPress>", lift)
  256.         title.bind("<ButtonPress>", lift)
  257.         for child in parentframe.winfo_children():
  258.             child.bind("<ButtonPress>", lift)
  259.  
  260.         minbutton = tk.Button(frame0, bg='white', text='—', fg='white', padx=15, bd=0)
  261.         minbutton.pack(side='right', anchor='e', fill='y')
  262.  
  263.         def minhover(e):
  264.             minbutton.config(bg=BRIGHT_ACCENT_COLOR)
  265.  
  266.         def minhover2(e):
  267.             minbutton.config(bg='gray90')
  268.  
  269.         def minunhover(e):
  270.             minbutton.config(bg=ACCENT_COLOR)
  271.  
  272.         def minunhover2(e):
  273.             minbutton.config(bg='white')
  274.  
  275.         def minpress(e):
  276.             minbutton.config(bg=DIM_ACCENT_COLOR)
  277.             return "break"
  278.  
  279.         def minpress2(e):
  280.             minbutton.config(bg='gray80')
  281.             return "break"
  282.  
  283.         def minunpress(e):
  284.             nonlocal minstorex
  285.             nonlocal minstorey
  286.             nonlocal min
  287.             global focused_window
  288.             px, py = root.winfo_pointerxy()
  289.             widget = root.winfo_containing(px, py)
  290.             if widget == minbutton:
  291.                 if min == False:
  292.                     minstorex = parentframe.winfo_x()
  293.                     minstorey = parentframe.winfo_y()
  294.                     parentframe.place_configure(x=minstorex, y=2000)
  295.                     min = True
  296.                 elif min == True:
  297.                     parentframe.place_configure(x=minstorex, y=minstorey)
  298.                     min = False
  299.             else:
  300.                 pass
  301.             focused_window = None
  302.  
  303.         minbutton.bind("<Enter>", minhover2)
  304.         minbutton.bind("<Leave>", minunhover2)
  305.         minbutton.bind("<Button-1>", minpress2)
  306.         minbutton.bind("<ButtonRelease-1>", minunpress)
  307.  
  308.         icon = tk.PhotoImage(file=img)
  309.         tbutton = tk.Button(taskbar, bg='gray10', width=35, bd=0)
  310.         tbutton.image = icon
  311.         tbutton.config(image=tbutton.image)
  312.         tbutton.pack(side='left', anchor='w', fill='y')
  313.  
  314.         def tbhover(e):
  315.             tbutton.config(bg='gray20')
  316.  
  317.         def tbunhover(e):
  318.             tbutton.config(bg='gray10')
  319.  
  320.         def tbpress(e):
  321.             tbutton.config(bg='gray30')
  322.             return "break"
  323.  
  324.         def tbunpress(e):
  325.             px, py = root.winfo_pointerxy()
  326.             widget = root.winfo_containing(px, py)
  327.             if widget == tbutton:
  328.                 nonlocal minstorex
  329.                 nonlocal minstorey
  330.                 nonlocal min
  331.                 parentframe.place_configure(x=minstorex, y=minstorey)
  332.                 lift('')
  333.                 min = False
  334.                 focused_window = parentframe
  335.             else:
  336.                 pass
  337.             tbutton.config(bg='gray20')
  338.  
  339.         tbutton.bind("<Enter>", tbhover)
  340.         tbutton.bind("<Leave>", tbunhover)
  341.         tbutton.bind("<Button-1>", tbpress)
  342.         tbutton.bind("<ButtonRelease-1>", tbunpress)
  343.  
  344.         def get_pos(event):
  345.             lift(event)
  346.             nonlocal restorex
  347.             nonlocal restorey
  348.             nonlocal restorew
  349.             nonlocal restoreh
  350.             nonlocal minstorex
  351.             nonlocal minstorey
  352.             nonlocal max
  353.             xwin = parentframe.winfo_x()
  354.             ywin = parentframe.winfo_y()
  355.             startx = event.x_root
  356.             starty = event.y_root
  357.  
  358.             ywin = ywin - starty
  359.             xwin = xwin - startx
  360.  
  361.             justmax = False
  362.  
  363.             def move(event):
  364.                 nonlocal restorew
  365.                 nonlocal restoreh
  366.                 nonlocal max
  367.                 nonlocal justmax
  368.                 middle = restorew / 2
  369.                 if max == False:
  370.                     if justmax == False:
  371.                         parentframe.place_configure(x=event.x_root + xwin, y=event.y_root + ywin)
  372.                     elif justmax == True:
  373.                         parentframe.place_configure(x=event.x_root - middle, y=event.y_root + ywin)
  374.                 elif max == True:
  375.                     parentframe.place_configure(x=event.x_root - middle, y=event.y_root + ywin, width=restorew, height=restoreh)
  376.                     maxbutton.config(text='△')
  377.                     max = False
  378.                     justmax = True
  379.  
  380.             def complete(e):
  381.                 nonlocal restorex
  382.                 nonlocal restorey
  383.                 nonlocal minstorex
  384.                 nonlocal minstorey
  385.                 nonlocal justmax
  386.                 def completethread():
  387.                     time.sleep(0.1)
  388.                     nonlocal restorex
  389.                     nonlocal restorey
  390.                     nonlocal minstorex
  391.                     nonlocal minstorey
  392.                     restorex = parentframe.winfo_x()
  393.                     restorey = parentframe.winfo_y()
  394.                     minstorex = parentframe.winfo_x()
  395.                     minstorey = parentframe.winfo_y()
  396.                     nonlocal justmax
  397.                     justmax = False
  398.                 Thread(target=completethread, daemon=True).start()
  399.  
  400.             startx = event.x_root
  401.             starty = event.y_root
  402.  
  403.             frame0.bind('<B1-Motion>', move)
  404.             title.bind('<B1-Motion>', move)
  405.  
  406.             frame0.bind('<ButtonRelease-1>', complete)
  407.             title.bind('<ButtonRelease-1>', complete)
  408.  
  409.         frame0.bind('<Button-1>', get_pos)
  410.         title.bind('<Button-1>', get_pos)
  411.  
  412.         def get_pos2(event):
  413.             lift(event)
  414.             nonlocal restorex
  415.             nonlocal restorey
  416.             nonlocal restorew
  417.             nonlocal restoreh
  418.             nonlocal minstorex
  419.             nonlocal minstorey
  420.             nonlocal max
  421.             xwin = parentframe.winfo_width()
  422.             ywin = parentframe.winfo_height()
  423.             startx = event.x_root
  424.             starty = event.y_root
  425.  
  426.             def resize(event):
  427.                 nonlocal startx
  428.                 nonlocal starty
  429.                 nonlocal xwin
  430.                 nonlocal ywin
  431.                 nonlocal max
  432.                 endx = event.x_root
  433.                 endy = event.y_root
  434.                 diffx = endx - startx
  435.                 diffy = endy - starty
  436.                 newwidth = xwin + diffx
  437.                 newheight = ywin + diffy
  438.                 if newwidth >= 230:
  439.                     parentframe.place_configure(width=newwidth)
  440.                 if newheight >= 34:
  441.                     parentframe.place_configure(height=newheight)
  442.                 if max == False:
  443.                     pass
  444.                 elif max == True:
  445.                     maxbutton.config(text='△')
  446.                     max = False
  447.  
  448.             def complete(e):
  449.                 nonlocal restorew
  450.                 nonlocal restoreh
  451.                 def completethread():
  452.                     time.sleep(0.1)
  453.                     nonlocal restorew
  454.                     nonlocal restorew
  455.                     restorew = parentframe.winfo_width()
  456.                     restoreh = parentframe.winfo_height()
  457.                 Thread(target=completethread, daemon=True).start()
  458.  
  459.             startx = event.x_root
  460.             starty = event.y_root
  461.  
  462.             parentframe.bind('<B1-Motion>', resize)
  463.  
  464.             parentframe.bind('<ButtonRelease-1>', complete)
  465.  
  466.         parentframe.bind('<Button-1>', get_pos2)
  467.  
  468.         def checkfocus():
  469.             if tbutton.winfo_exists() and parentframe.winfo_exists():
  470.                 global focused_window
  471.                 if focused_window == parentframe and tbutton.winfo_exists() and parentframe.winfo_exists():
  472.                     try:
  473.                         px, py = root.winfo_pointerxy()
  474.                         widget = root.winfo_containing(px, py)
  475.                         if not widget == tbutton:
  476.                             tbutton.config(bg='gray20')
  477.                         frame0.config(bg=ACCENT_COLOR)
  478.                         title.config(bg=ACCENT_COLOR, fg='white')
  479.                         if not widget == closebutton:
  480.                             closebutton.config(bg=ACCENT_COLOR, fg='white')
  481.                         if not widget == maxbutton:
  482.                             maxbutton.config(bg=ACCENT_COLOR, fg='white')
  483.                         if not widget == minbutton:
  484.                             minbutton.config(bg=ACCENT_COLOR, fg='white')
  485.                         closebutton.bind("<Leave>", clbunhover)
  486.                         maxbutton.bind("<Enter>", maxhover)
  487.                         maxbutton.bind("<Leave>", maxunhover)
  488.                         maxbutton.bind("<Button-1>", maxpress)
  489.                         minbutton.bind("<Enter>", minhover)
  490.                         minbutton.bind("<Leave>", minunhover)
  491.                         minbutton.bind("<Button-1>", minpress)
  492.                         time.sleep(0.05)
  493.                         return Thread(target=checkfocus, daemon=True).start()
  494.                     except:
  495.                         pass
  496.                 elif tbutton.winfo_exists() and parentframe.winfo_exists():
  497.                     try:
  498.                         px, py = root.winfo_pointerxy()
  499.                         widget = root.winfo_containing(px, py)
  500.                         if not widget == tbutton:
  501.                             tbutton.config(bg='gray10')
  502.                         frame0.config(bg='white')
  503.                         title.config(bg='white', fg='gray50')
  504.                         if not widget == closebutton:
  505.                             closebutton.config(bg='white', fg='gray50')
  506.                         if not widget == maxbutton:
  507.                             maxbutton.config(bg='white', fg='gray50')
  508.                         if not widget == minbutton:
  509.                             minbutton.config(bg='white', fg='gray50')
  510.                         closebutton.bind("<Leave>", clbunhover2)
  511.                         maxbutton.bind("<Enter>", maxhover2)
  512.                         maxbutton.bind("<Leave>", maxunhover2)
  513.                         maxbutton.bind("<Button-1>", maxpress2)
  514.                         minbutton.bind("<Enter>", minhover2)
  515.                         minbutton.bind("<Leave>", minunhover2)
  516.                         minbutton.bind("<Button-1>", minpress2)
  517.                         time.sleep(0.05)
  518.                         return Thread(target=checkfocus, daemon=True).start()
  519.                     except:
  520.                         pass
  521.  
  522.         Thread(target=checkfocus, daemon=True).start()
  523.  
  524.         def runprogram():
  525.             nonlocal program
  526.             if program == None:
  527.                 if code == None:
  528.                     tk.Label(frame1, bg='white', text='Unable to load code for this window.').pack(anchor='n', side='top', pady=50)
  529.                 else:
  530.                     codeobject = compile(code, 'Unknown', 'exec')
  531.                     exec(codeobject, {"root": root, "openfile": openfile, "create_window": create_window, "startprogram": startprogram}, {"frame1": frame1, "parentframe": parentframe})
  532.             else:
  533.                 f = open(program, 'r')
  534.                 code0 = f.read()
  535.                 f.close()
  536.                 codeobject0 = compile(code0, program, 'exec')
  537.                 exec(codeobject0, {"root": root, "openfile": openfile, "create_window": create_window, "startprogram": startprogram}, {"frame1": frame1, "parentframe": parentframe})
  538.  
  539.         Thread(target=runprogram, daemon=True).start()
  540.  
  541.         return parentframe
  542.  
  543.     def programmenu():
  544.         global frame3
  545.         try:
  546.             if frame3.winfo_exists():
  547.                 frame3.destroy()
  548.             else:
  549.                 raise(NameError)
  550.         except NameError:
  551.             frame3 = tk.Frame(root, width=500, height=600, bd=1, relief='solid', bg='white')
  552.             closebutton = tk.Button(frame3, bg=sysappbg, text='⨉', fg='gray50', padx=15, bd=0, font='TkDefaultFont 12')
  553.             closebutton.pack(side='right', anchor='ne')
  554.  
  555.             def clbhover(e):
  556.                 closebutton.config(bg='red', fg='white')
  557.  
  558.             def clbunhover2(e):
  559.                 closebutton.config(bg=sysappbg, fg='gray50')
  560.  
  561.             def clbpress(e):
  562.                 closebutton.config(bg='darkred')
  563.                 return "break"
  564.  
  565.             def clbunpress(e):
  566.                 px, py = root.winfo_pointerxy()
  567.                 widget = root.winfo_containing(px, py)
  568.                 if widget == closebutton:
  569.                     frame3.destroy()
  570.                 else:
  571.                     pass
  572.  
  573.             closebutton.bind("<Enter>", clbhover)
  574.             closebutton.bind("<Leave>", clbunhover2)
  575.             closebutton.bind("<Button-1>", clbpress)
  576.             closebutton.bind("<ButtonRelease-1>", clbunpress)
  577.  
  578.             frame3.place(x=0, y=root.winfo_height() - 630, width=500, height=600)
  579.  
  580.             f = open('T:/Programs/ProgramList/ProgramList.tep', 'r')
  581.             code0 = f.read()
  582.             f.close()
  583.             codeobject1 = compile(code0, 'T:/Programs/ProgramList/ProgramList.tep', 'exec')
  584.             exec(codeobject1)
  585.  
  586.     def openfile(path):
  587.         if path.endswith('.png') or path.endswith('.jpg') or path.endswith('.jpeg'):
  588.             codefile = open('T:/Programs/ImageViewer/ImageViewer.tep', 'r')
  589.             code1 = codefile.read()
  590.             code2 = code1 + '\nloadimage(r"' + path + '")'
  591.             create_window(width=600, height=400, title=os.path.basename(path), img="T:/Programs/ImageViewer/Attributes/Icon.png", code=code2)
  592.         elif path.endswith('.tep'):
  593.             programname = os.path.basename(path)[:-4]
  594.             create_window(title=programname, program=path)
  595.         else:
  596.             codefile = open('T:/Programs/TechNotes/TechNotes.tep', 'r')
  597.             code1 = codefile.read()
  598.             code2 = code1 + '\nopen_file(r"' + path + '")'
  599.             create_window(width=600, height=400, title="TechNotes", img="T:/Programs/TechNotes/Attributes/Icon.png", code=code2)
  600.  
  601.     def startprogram(name):
  602.         infopath = 'T:/ProgramData/Info/' + name + '.info'
  603.         try:
  604.             infofile = open(infopath, 'r')
  605.             infotext = infofile.read()
  606.             info = ast.literal_eval(infotext)
  607.             _title = info["TITLE"]
  608.             _icon = info["ICONPATH"]
  609.             _width = info["WINWIDTH"]
  610.             _height = info["WINHEIGHT"]
  611.             _program = info["PROGRAMPATH"]
  612.             return create_window(title=_title, img=_icon, width=_width, height=_height, program=_program)
  613.         except FileNotFoundError:
  614.             return create_window(title=name)
  615.         finally:
  616.             global frame3
  617.             if frame3.winfo_exists():
  618.                 programmenu()
  619.             else:
  620.                 pass
  621.  
  622.     techpadicon1 = tk.PhotoImage(file='T:/TechOS/Virtual/Images/TechpadLogoWhite16px.png')
  623.     techpadicon2 = tk.PhotoImage(file='T:/TechOS/Virtual/Images/TechpadLogoBlue16px.png')
  624.     techpadbutton = tk.Button(taskbar, bg='gray10', width=35, bd=0)
  625.     techpadbutton.image = techpadicon1
  626.     techpadbutton.config(image=techpadbutton.image)
  627.     techpadbutton.pack(side='left', anchor='w', fill='y')
  628.  
  629.     def tpbhover(e):
  630.         techpadbutton.config(bg='gray20')
  631.         techpadbutton.image = techpadicon2
  632.         techpadbutton.config(image=techpadbutton.image)
  633.  
  634.     def tpbunhover(e):
  635.         techpadbutton.config(bg='gray10')
  636.         techpadbutton.image = techpadicon1
  637.         techpadbutton.config(image=techpadbutton.image)
  638.  
  639.     def tpbpress(e):
  640.         techpadbutton.config(bg='gray30')
  641.         return "break"
  642.  
  643.     def tpbunpress(e):
  644.         px, py = root.winfo_pointerxy()
  645.         widget = root.winfo_containing(px, py)
  646.         if widget == techpadbutton:
  647.             programmenu()
  648.         else:
  649.             pass
  650.         techpadbutton.config(bg='gray20')
  651.  
  652.     techpadbutton.bind("<Enter>", tpbhover)
  653.     techpadbutton.bind("<Leave>", tpbunhover)
  654.     techpadbutton.bind("<Button-1>", tpbpress)
  655.     techpadbutton.bind("<ButtonRelease-1>", tpbunpress)
  656.  
  657.     tpbseparator = tk.Frame(taskbar, bg='gray90', width=1, height=20)
  658.     tpbseparator.pack(anchor='w', side='left', padx=5, pady=5)
  659.  
  660.     if PROGRAMLIST_STARTUP == "True":
  661.         programmenu()
  662.     else:
  663.         pass
  664.  
  665.     if TECHMAIL_STARTUP == "True":
  666.         startprogram("TechMail")
  667.     else:
  668.         pass
  669.  
  670.     if wallpaperloaded == False:
  671.         mb.showinfo("Failed to load image", "We were unable to find your custom wallpaper. Please try setting the wallpaper again or turn on \"Randomize Wallpapers\" in settings.")
  672.  
  673.     root.mainloop()
  674.  
  675. except Exception as err:
  676.     root.config(bg='#00afff')
  677.     tk.Label(bg='#00afff', fg='white', text=f'Fatal Error\n\nTechOS has crashed for the following reason:\n\n{err}\n\nIf the problem persists, contact Techpad.\nPress any key to exit', font='tkDefaultFont 20', anchor='nw', padx=10, pady=10, justify='left', cursor='none').pack(expand=True, fill='both')
  678.     def tosexit(e):
  679.         root.destroy()
  680.         sys.exit()
  681.     root.bind("<Key>", tosexit)
  682.     root.mainloop()
Add Comment
Please, Sign In to add comment