Advertisement
Techpad

ProgramList

Mar 15th, 2021 (edited)
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.66 KB | None | 0 0
  1. import os
  2. import tkinter as tk
  3. from tkinter import messagebox as mb
  4.  
  5. DARK_SYSTEM_APPS = open("T:/TechOS/Virtual/Settings/DARK_SYSTEM_APPS.set", "r").read()
  6. ACCENT_COLOR = open("T:/TechOS/Virtual/Settings/ACCENT_COLOR.set", "r").read()
  7.  
  8. def color_variant(hex_color, brightness_offset=1):
  9. """ takes a color like #87c95f and produces a lighter or darker variant """
  10. if len(hex_color) != 7:
  11. raise Exception("Passed %s into color_variant(), needs to be in #87c95f format." % hex_color)
  12. rgb_hex = [hex_color[x:x+2] for x in [1, 3, 5]]
  13. new_rgb_int = [int(hex_value, 16) + brightness_offset for hex_value in rgb_hex]
  14. new_rgb_int = [min([255, max([0, i])]) for i in new_rgb_int] # make sure new values are between 0 and 255
  15. # hex() produces "0x88", we want just "88"
  16. return "#" + "".join(["{:02x}".format(i) for i in new_rgb_int])
  17.  
  18. BLACK_ACCENT_COLOR = color_variant(ACCENT_COLOR, -200)
  19. DIM_ACCENT_COLOR = color_variant(ACCENT_COLOR, -20)
  20. DARK_ACCENT_COLOR = color_variant(ACCENT_COLOR, -10)
  21. LIGHT_ACCENT_COLOR = color_variant(ACCENT_COLOR, 10)
  22. BRIGHT_ACCENT_COLOR = color_variant(ACCENT_COLOR, 20)
  23. WHITE_ACCENT_COLOR = color_variant(ACCENT_COLOR, 200)
  24.  
  25. global_bg_color = "white"
  26. global_fg_color = "black"
  27. global_ac_bg_color = "lightgray"
  28. global_sp_bg_color = WHITE_ACCENT_COLOR
  29.  
  30. if DARK_SYSTEM_APPS == "True":
  31. global_bg_color = "gray10"
  32. global_fg_color = "gray90"
  33. global_ac_bg_color = "gray20"
  34. global_sp_bg_color = BLACK_ACCENT_COLOR
  35.  
  36. _root = frame3
  37.  
  38. frame3.config(bg=global_bg_color)
  39.  
  40. listlabel = tk.Label(_root, bg=global_bg_color, text='Programs\n', font='TkDefaultFont 20', fg=global_fg_color)
  41. listlabel.pack(anchor='nw', padx=5, pady=5)
  42. infofolder = os.listdir("T:/ProgramData/Info")
  43. infofiles = [file for file in infofolder if file.endswith('.info') and not file.endswith('ProgramList.info')]
  44. programnames = []
  45. for file in infofiles:
  46. programnames.append(os.path.basename(file)[:-5])
  47. for name in programnames:
  48. tk.Button(_root, text=name, command=lambda name=name: startprogram(name), bg=global_bg_color, activebackground=global_ac_bg_color, bd=0, fg=global_fg_color, activeforeground=global_fg_color).pack(anchor='nw', padx=5, pady=5)
  49.  
  50. def restarttechos():
  51. root.destroy()
  52. exec(compile(open("T:/TechOS/Virtual/TechOS.py", "rb").read(), "T:/TechOS/Virtual/TechOS.py", 'exec'), {})
  53. sys.exit()
  54.  
  55. def updatetechos():
  56. global mb
  57. if mb.askyesno("Update TechOS?","This process might take a while!") == True:
  58. root.destroy()
  59. exec(compile(open("T:/TechOS/Virtual/Update.py", "rb").read(), "T:/TechOS/Virtual/Update.py", 'exec'), {})
  60. sys.exit()
  61. else:
  62. pass
  63.  
  64. exitbutton = tk.Button(_root, text="Exit TechOS", command=exit, bg=global_bg_color, bd=0, fg=global_fg_color, activeforeground=ACCENT_COLOR, activebackground=global_sp_bg_color)
  65. exitbutton.pack(side='bottom', anchor='sw', padx=5, pady=5)
  66. restartbutton = tk.Button(_root, text="Restart TechOS", command=restarttechos, bg=global_bg_color, bd=0, fg=global_fg_color, activeforeground=ACCENT_COLOR, activebackground=global_sp_bg_color)
  67. restartbutton.pack(side='bottom', anchor='sw', padx=5, pady=5)
  68. updatebutton = tk.Button(_root, text="Check for updates", command=updatetechos, bg=global_bg_color, bd=0, fg=global_fg_color, activeforeground=ACCENT_COLOR, activebackground=global_sp_bg_color)
  69. updatebutton.pack(side='bottom', anchor='sw', padx=5, pady=5)
  70. settingsbutton = tk.Button(_root, text="Settings", command=lambda: startprogram("Settings"), bg=global_bg_color, bd=0, fg=global_fg_color, activeforeground=ACCENT_COLOR, activebackground=global_sp_bg_color)
  71. settingsbutton.pack(side='bottom', anchor='sw', padx=5, pady=5)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement