Advertisement
Techpad

Settings 4

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