Advertisement
Techpad

Settings 10

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