Advertisement
Techpad

Clock 10

Apr 3rd, 2021
262
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.61 KB | None | 0 0
  1. import os
  2. import sys
  3. import time
  4. import tkinter as tk
  5. from tkinter import messagebox as mb
  6. import keyboard
  7. from threading import Thread
  8. import datetime
  9.  
  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.  
  13. def color_variant(hex_color, brightness_offset=1):
  14. """ takes a color like #87c95f and produces a lighter or darker variant """
  15. if len(hex_color) != 7:
  16. raise Exception("Passed %s into color_variant(), needs to be in #87c95f format." % hex_color)
  17. rgb_hex = [hex_color[x:x+2] for x in [1, 3, 5]]
  18. new_rgb_int = [int(hex_value, 16) + brightness_offset for hex_value in rgb_hex]
  19. new_rgb_int = [min([255, max([0, i])]) for i in new_rgb_int] # make sure new values are between 0 and 255
  20. # hex() produces "0x88", we want just "88"
  21. return "#" + "".join(["{:02x}".format(i) for i in new_rgb_int])
  22.  
  23. BLACK_ACCENT_COLOR = color_variant(ACCENT_COLOR, -200)
  24. DIM_ACCENT_COLOR = color_variant(ACCENT_COLOR, -20)
  25. DARK_ACCENT_COLOR = color_variant(ACCENT_COLOR, -10)
  26. LIGHT_ACCENT_COLOR = color_variant(ACCENT_COLOR, 10)
  27. BRIGHT_ACCENT_COLOR = color_variant(ACCENT_COLOR, 20)
  28. WHITE_ACCENT_COLOR = color_variant(ACCENT_COLOR, 200)
  29.  
  30. global_bg_color = "white"
  31. global_fg_color = "black"
  32. global_ac_bg_color = "lightgray"
  33. global_sp_bg_color = WHITE_ACCENT_COLOR
  34.  
  35. if DARK_SYSTEM_APPS == "True":
  36. global_bg_color = "gray12"
  37. global_fg_color = "gray90"
  38. global_ac_bg_color = "gray20"
  39. global_sp_bg_color = BLACK_ACCENT_COLOR
  40.  
  41. _root = frame4
  42.  
  43. frame4.config(bg=global_bg_color, pady=20)
  44.  
  45. time_label = tk.Label(_root, text="??:??:?? ??", bg=global_bg_color, fg=global_fg_color, font="TkDefaultFont 40", anchor='nw')
  46. time_label.pack(anchor='nw', padx=20)
  47.  
  48. date_label = tk.Label(_root, text="Unknown Date", bg=global_bg_color, fg=ACCENT_COLOR, font="TkDefaultFont 15", anchor='nw')
  49. date_label.pack(anchor='nw', padx=25)
  50.  
  51. def clock():
  52. time1 = datetime.datetime.now().strftime("%H:%M:%S/%p")
  53. time2, time3 = time1.split('/')
  54. hour, minutes, seconds = time2.split(':')
  55. if int(hour) > 12 and int(hour) < 24:
  56. time = str(int(hour) - 12) + ':' + minutes + ':' + seconds + ' ' + time3
  57. else:
  58. time = str(int(hour)) + ':' + minutes + ':' + seconds + ' ' + time3
  59. time_label.config(text=time)
  60. time_label.after(1000, clock)
  61.  
  62. def date():
  63. date1 = datetime.datetime.now().strftime("%A, %B %d, %Y")
  64. date_label.config(text=date1)
  65. date_label.after(60000, date)
  66.  
  67. Thread(target=clock, daemon=True).start()
  68. Thread(target=date, daemon=True).start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement