Advertisement
Techpad

Settings 11

Apr 14th, 2021
267
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.81 KB | None | 0 0
  1. import tkinter as tk
  2. from tkinter import filedialog
  3. from tkinter import simpledialog as spd
  4. import os
  5. import sys
  6. import keyboard
  7. _root = frame1
  8. PROGRAMLIST_STARTUP = open("T:/TechOS/Virtual/Settings/PROGRAMLIST_STARTUP.set", "r").read()
  9. RANDOMIZE_WALLPAPERS = open("T:/TechOS/Virtual/Settings/RANDOMIZE_WALLPAPERS.set", "r").read()
  10. TECHMAIL_STARTUP = open("T:/TechOS/Virtual/Settings/TECHMAIL_STARTUP.set", "r").read()
  11. SET_WALLPAPER = open("T:/TechOS/Virtual/Settings/SET_WALLPAPER.set", "r").read()
  12. DARK_SYSTEM_APPS = open("T:/TechOS/Virtual/Settings/DARK_SYSTEM_APPS.set", "r").read()
  13. ACCENT_COLOR = open("T:/TechOS/Virtual/Settings/ACCENT_COLOR.set", "r").read()
  14. LARGER_BORDERS = open("T:/TechOS/Virtual/Settings/LARGER_BORDERS.set", "r").read()
  15. DISABLE_ANIMATIONS = open("T:/TechOS/Virtual/Settings/DISABLE_ANIMATIONS.set", "r").read()
  16.  
  17. slideroff = tk.PhotoImage(file="T:/TechOS/Virtual/Images/Slider Off.png")
  18. slideron = tk.PhotoImage(file="T:/TechOS/Virtual/Images/Slider On.png")
  19.  
  20. settingslabel = tk.Label(_root, text='Settings\n', font='TkDefaultFont 20', bg='white')
  21. settingslabel.pack(anchor='nw', padx=5, pady=5)
  22.  
  23. plsvar = tk.BooleanVar()
  24. if PROGRAMLIST_STARTUP == 'False':
  25. plsvar.set(False)
  26. elif PROGRAMLIST_STARTUP == 'True':
  27. plsvar.set(True)
  28.  
  29. def plsupdate():
  30. global plsvar
  31. global PROGRAMLIST_STARTUP
  32. if plsvar.get() == True:
  33. open("T:/TechOS/Virtual/Settings/PROGRAMLIST_STARTUP.set", "w").write("True")
  34. PROGRAMLIST_STARTUP = "True"
  35. elif plsvar.get() == False:
  36. open("T:/TechOS/Virtual/Settings/PROGRAMLIST_STARTUP.set", "w").write("False")
  37. PROGRAMLIST_STARTUP = "False"
  38.  
  39. plsbutton = tk.Checkbutton(_root, bg='white', activebackground='white', text=" Show Program List on startup", compound='left', bd=0, selectcolor='white', padx=0, pady=0, command=plsupdate, variable=plsvar, offvalue=False, onvalue=True)
  40. plsbutton.image = slideroff
  41. plsbutton.selectimage = slideron
  42. plsbutton.config(image=plsbutton.image, selectimage=plsbutton.selectimage, indicatoron=False)
  43. plsbutton.pack(anchor='nw', padx=5, pady=5)
  44.  
  45. tmsvar = tk.BooleanVar()
  46. if TECHMAIL_STARTUP == 'False':
  47. tmsvar.set(False)
  48. elif TECHMAIL_STARTUP == 'True':
  49. tmsvar.set(True)
  50.  
  51. def tmsupdate():
  52. global tmsvar
  53. global TECHMAIL_STARTUP
  54. if tmsvar.get() == True:
  55. open("T:/TechOS/Virtual/Settings/TECHMAIL_STARTUP.set", "w").write("True")
  56. TECHMAIL_STARTUP = "True"
  57. elif tmsvar.get() == False:
  58. open("T:/TechOS/Virtual/Settings/TECHMAIL_STARTUP.set", "w").write("False")
  59. TECHMAIL_STARTUP = "False"
  60.  
  61. tmsbutton = tk.Checkbutton(_root, bg='white', activebackground='white', text=" Run TechMail on startup", compound='left', bd=0, selectcolor='white', padx=0, pady=0, command=tmsupdate, variable=tmsvar, offvalue=False, onvalue=True)
  62. tmsbutton.image = slideroff
  63. tmsbutton.selectimage = slideron
  64. tmsbutton.config(image=tmsbutton.image, selectimage=tmsbutton.selectimage, indicatoron=False)
  65. tmsbutton.pack(anchor='nw', padx=5, pady=5)
  66.  
  67. dsavar = tk.BooleanVar()
  68. if DARK_SYSTEM_APPS == 'False':
  69. dsavar.set(False)
  70. elif DARK_SYSTEM_APPS == 'True':
  71. dsavar.set(True)
  72.  
  73. def dsaupdate():
  74. global dsavar
  75. global DARK_SYSTEM_APPS
  76. if dsavar.get() == True:
  77. open("T:/TechOS/Virtual/Settings/DARK_SYSTEM_APPS.set", "w").write("True")
  78. DARK_SYSTEM_APPS = "True"
  79. elif dsavar.get() == False:
  80. open("T:/TechOS/Virtual/Settings/DARK_SYSTEM_APPS.set", "w").write("False")
  81. DARK_SYSTEM_APPS = "False"
  82.  
  83. dsabutton = tk.Checkbutton(_root, bg='white', activebackground='white', text=" Dark mode for system apps", compound='left', bd=0, selectcolor='white', padx=0, pady=0, command=dsaupdate, variable=dsavar, offvalue=False, onvalue=True)
  84. dsabutton.image = slideroff
  85. dsabutton.selectimage = slideron
  86. dsabutton.config(image=dsabutton.image, selectimage=dsabutton.selectimage, indicatoron=False)
  87. dsabutton.pack(anchor='nw', padx=5, pady=5)
  88.  
  89. lwbvar = tk.BooleanVar()
  90. if LARGER_BORDERS == 'False':
  91. lwbvar.set(False)
  92. elif LARGER_BORDERS == 'True':
  93. lwbvar.set(True)
  94.  
  95. def lwbupdate():
  96. global lwbvar
  97. global LARGER_BORDERS
  98. if lwbvar.get() == True:
  99. open("T:/TechOS/Virtual/Settings/LARGER_BORDERS.set", "w").write("True")
  100. LARGER_BORDERS = "True"
  101. elif lwbvar.get() == False:
  102. open("T:/TechOS/Virtual/Settings/LARGER_BORDERS.set", "w").write("False")
  103. LARGER_BORDERS = "False"
  104.  
  105. lwbbutton = tk.Checkbutton(_root, bg='white', activebackground='white', text=" Make window borders larger for easier resizing", compound='left', bd=0, selectcolor='white', padx=0, pady=0, command=lwbupdate, variable=lwbvar, offvalue=False, onvalue=True)
  106. lwbbutton.image = slideroff
  107. lwbbutton.selectimage = slideron
  108. lwbbutton.config(image=lwbbutton.image, selectimage=lwbbutton.selectimage, indicatoron=False)
  109. lwbbutton.pack(anchor='nw', padx=5, pady=5)
  110.  
  111. rdwvar = tk.BooleanVar()
  112. if RANDOMIZE_WALLPAPERS == 'False':
  113. rdwvar.set(False)
  114. elif RANDOMIZE_WALLPAPERS == 'True':
  115. rdwvar.set(True)
  116.  
  117. def rdwupdate():
  118. global rdwvar
  119. global RANDOMIZE_WALLPAPERS
  120. if rdwvar.get() == True:
  121. open("T:/TechOS/Virtual/Settings/RANDOMIZE_WALLPAPERS.set", "w").write("True")
  122. RANDOMIZE_WALLPAPERS = "True"
  123. elif rdwvar.get() == False:
  124. open("T:/TechOS/Virtual/Settings/RANDOMIZE_WALLPAPERS.set", "w").write("False")
  125. RANDOMIZE_WALLPAPERS = "False"
  126.  
  127. rdwbutton = tk.Checkbutton(_root, bg='white', activebackground='white', text=" Randomize Wallpapers", compound='left', bd=0, selectcolor='white', padx=0, pady=0, command=rdwupdate, variable=rdwvar, offvalue=False, onvalue=True)
  128. rdwbutton.image = slideroff
  129. rdwbutton.selectimage = slideron
  130. rdwbutton.config(image=rdwbutton.image, selectimage=rdwbutton.selectimage, indicatoron=False)
  131. rdwbutton.pack(anchor='nw', padx=5, pady=5)
  132.  
  133. danvar = tk.BooleanVar()
  134. if DISABLE_ANIMATIONS == 'False':
  135. danvar.set(False)
  136. elif DISABLE_ANIMATIONS == 'True':
  137. danvar.set(True)
  138.  
  139. def danupdate():
  140. global danvar
  141. global DISABLE_ANIMATIONS
  142. if danvar.get() == True:
  143. open("T:/TechOS/Virtual/Settings/DISABLE_ANIMATIONS.set", "w").write("True")
  144. DISABLE_ANIMATIONS = "True"
  145. elif danvar.get() == False:
  146. open("T:/TechOS/Virtual/Settings/DISABLE_ANIMATIONS.set", "w").write("False")
  147. DISABLE_ANIMATIONS = "False"
  148.  
  149. danbutton = tk.Checkbutton(_root, bg='white', activebackground='white', text=" Disable Animations", compound='left', bd=0, selectcolor='white', padx=0, pady=0, command=danupdate, variable=danvar, offvalue=False, onvalue=True)
  150. danbutton.image = slideroff
  151. danbutton.selectimage = slideron
  152. danbutton.config(image=danbutton.image, selectimage=danbutton.selectimage, indicatoron=False)
  153. danbutton.pack(anchor='nw', padx=5, pady=5)
  154.  
  155. def setwallpaper():
  156. global filedialog
  157. global rdwbutton
  158. global rdwupdate
  159. global os
  160. nwppath = filedialog.askopenfilename(filetypes=[('Supported Files', '.png .jpg .jpeg'), ('Portable Network Graphics', '.png'), ('Joint Photographic Experts Group Images', '.jpg .jpeg')], title='Open Wallpaper')
  161. try:
  162. nwp = open(nwppath, 'rb')
  163. nwpconts = nwp.read()
  164. nwp.close()
  165. extension = os.path.splitext(nwppath)[1]
  166. nwpf = open('T:\TechOS\Virtual\Images\Wallpapers\Custom' + extension, 'wb')
  167. nwpf.write(nwpconts)
  168. nwpf.close()
  169. swpfile = open("T:/TechOS/Virtual/Settings/SET_WALLPAPER.set", "w")
  170. swpfile.write("Custom" + extension)
  171. rdwbutton.deselect()
  172. rdwupdate()
  173. except FileNotFoundError:
  174. pass
  175.  
  176. swpbutton = tk.Button(_root, bg='white', bd=0, activebackground='lightgray', text='Set Custom Background', command=setwallpaper)
  177. swpbutton.pack(anchor='nw', padx=5, pady=5)
  178.  
  179. def removecwp():
  180. try:
  181. os.remove('T:/TechOS/Virtual/Images/Wallpapers/Custom.png')
  182. except FileNotFoundError:
  183. pass
  184. try:
  185. os.remove('T:/TechOS/Virtual/Images/Wallpapers/Custom.jpg')
  186. except FileNotFoundError:
  187. pass
  188. try:
  189. os.remove('T:/TechOS/Virtual/Images/Wallpapers/Custom.jpeg')
  190. except FileNotFoundError:
  191. pass
  192.  
  193. rwpbutton = tk.Button(_root, bg='white', bd=0, activebackground='lightgray', text='Remove Custom Wallpapers', command=removecwp)
  194. rwpbutton.pack(anchor='nw', padx=5, pady=5)
  195.  
  196. def setaccentcolor():
  197. global spd
  198. newcolor = spd.askstring("Change Accent Color", "Type the accent color in 6-digit hexadecimal format (#0a1b2c):")
  199. if newcolor.startswith("#") and len(newcolor) == 7:
  200. open("T:/TechOS/Virtual/Settings/ACCENT_COLOR.set", "w").write(newcolor)
  201. else:
  202. pass
  203.  
  204. sacbutton = tk.Button(_root, bg='white', bd=0, activebackground='lightgray', text='Set Accent Color', command=setaccentcolor)
  205. sacbutton.pack(anchor='nw', padx=5, pady=5)
  206.  
  207. def rsaccentcolor():
  208. open("T:/TechOS/Virtual/Settings/ACCENT_COLOR.set", "w").write("#0090ff")
  209.  
  210. rsabutton = tk.Button(_root, bg='white', bd=0, activebackground='lightgray', text='Reset Accent Color', command=rsaccentcolor)
  211. rsabutton.pack(anchor='nw', padx=5, pady=5)
  212.  
  213. def restarttechos():
  214. global sys
  215. global keyboard
  216. keyboard.remove_all_hotkeys()
  217. root.destroy()
  218. exec(compile(open("T:/TechOS/Virtual/TechOS.py", "rb").read(), "T:/TechOS/Virtual/TechOS.py", 'exec'), {})
  219. sys.exit()
  220.  
  221. restartbutton = tk.Button(_root, bg='white', bd=0, activebackground='lightgray', text='Restart to apply changes', command=restarttechos)
  222. restartbutton.pack(side='bottom', anchor='sw', padx=5, pady=5)
  223.  
  224. if DARK_SYSTEM_APPS == "True":
  225. frame1.config(bg='gray10')
  226. settingslabel.config(bg='gray10', fg='gray90')
  227. plsbutton.config(bg='gray10', selectcolor='gray10', fg='gray90', activebackground='gray20', activeforeground='gray90')
  228. tmsbutton.config(bg='gray10', selectcolor='gray10', fg='gray90', activebackground='gray20', activeforeground='gray90')
  229. dsabutton.config(bg='gray10', selectcolor='gray10', fg='gray90', activebackground='gray20', activeforeground='gray90')
  230. rdwbutton.config(bg='gray10', selectcolor='gray10', fg='gray90', activebackground='gray20', activeforeground='gray90')
  231. danbutton.config(bg='gray10', selectcolor='gray10', fg='gray90', activebackground='gray20', activeforeground='gray90')
  232. lwbbutton.config(bg='gray10', selectcolor='gray10', fg='gray90', activebackground='gray20', activeforeground='gray90')
  233. swpbutton.config(bg='gray10', activebackground='gray20', fg='gray90', activeforeground='gray90')
  234. rwpbutton.config(bg='gray10', activebackground='gray20', fg='gray90', activeforeground='gray90')
  235. sacbutton.config(bg='gray10', activebackground='gray20', fg='gray90', activeforeground='gray90')
  236. rsabutton.config(bg='gray10', activebackground='gray20', fg='gray90', activeforeground='gray90')
  237. restartbutton.config(bg='gray10', activebackground='gray20', fg='gray90', activeforeground='gray90')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement