Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Dark mode #2

Merged
merged 10 commits into from
Nov 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added assets/images/dark/dark_theme.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/dark/info.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/light/dark_theme.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/light/info.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/light/pause.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/light/play.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed assets/images/pause_bars.jpeg
Binary file not shown.
Binary file removed assets/images/pause_bars.jpg
Binary file not shown.
Binary file removed assets/images/play_arrow.jpeg
Binary file not shown.
Binary file removed assets/images/play_arrow.jpg
Binary file not shown.
68 changes: 48 additions & 20 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,28 @@
# TimerX v1.3.0 by sumeshir26
# IMPORTS
from time import sleep
from tkinter import ttk, Tk, PhotoImage, Frame
from tkinter import Image, ttk, Tk, PhotoImage, Frame
from tkinter.constants import SE, SW
from playsound import playsound
import threading
import configurator
import darkdetect
import platform

# TKINTER WINDOW
app = Tk()
app.title('TimerX')
app.geometry('300x200')
app.geometry('300x210')
app.resizable(False, False)

print(platform.system())
if platform.system() == "Linux":
logo_img = PhotoImage(file = 'assets/images/logo.png')
app.iconphoto(False, logo_img)
elif platform.system() == "Darwin":
if platform.system() == "darwin":
app.iconbitmap(r'assets/logo.icns')
elif platform.system() == "Windows":
elif platform.system() == "win":
app.iconphoto(r'assets/logo.ico')
else:
logo_img = PhotoImage(file = 'assets/images/logo.png')
app.iconphoto(False, logo_img)

# VARIABLES
app_on = True
Expand All @@ -42,10 +45,8 @@ def startstopButtonPressed():
if timer_on:
timer_on = False
timer_paused = True
# play_button.configure(image = play_button_img)
play_button.configure(text = "Play")
elif timer_paused == False and timer_on == False:
#play_button.configure(image = pause_button_img)
play_button.configure(text = "Pause")
timer_thread = threading.Thread(target=runTimer, daemon=True)
timer_thread.start()
Expand All @@ -62,7 +63,6 @@ def saveTimer(timer_sec_input, timer_min_input, timer_hr_input, manager_window,
timer_hours = int(timer_hr_input.get())
time_selected_display.configure(text = f'Time Selected : {timer_seconds} Seconds')
time_display.configure(text = f'{timer_hours} : {timer_seconds} : {timer_seconds}')
print('DESTRUCTION MODE')
manager_app.destroy()
except ValueError:
time_selected_display.configure(text = "Please enter a number!")
Expand Down Expand Up @@ -97,19 +97,40 @@ def runTimer():

timer_on = False
time_display.configure(text = f'{hours_left} : {minutes_left} : {seconds_left}')
#play_button.config(image = play_button_img)
play_button.config(text = "Pause")
playBuzzer()

# IMAGES
# APP THEME

app.tk.call("source", "sun-valley.tcl")
theme = 'light'

if darkdetect.theme() == "Dark":
app.tk.call("set_theme", "dark")
theme = 'dark'
else:
app.tk.call("set_theme", "light")

def switchTheme():
global theme, app, info_button, switch_theme_button
if theme == 'light':
theme = 'dark'
app.tk.call("set_theme", "dark")
switch_theme_button.configure(image=switch_theme_image_dark)
info_button.configure(image=info_image_dark)
else:
theme = 'light'
app.tk.call("set_theme", "light")
info_button.configure(image=info_image_light)
switch_theme_button.configure(image=switch_theme_image_light)

# IMAGES

# play_button_img = PhotoImage(file = 'assets/images/play_arrow.png')
# pause_button_img = PhotoImage(file = 'assets/images/pause_bars.png')
switch_theme_image_light = PhotoImage(file=f"./assets/images/light/dark_theme.png")
switch_theme_image_dark = PhotoImage(file=f"./assets/images/dark/dark_theme.png")

# APP THEME
app.tk.call("source", "sun-valley.tcl")
app.tk.call("set_theme", "light")
info_image_light = PhotoImage(file=f"./assets/images/light/info.png")
info_image_dark = PhotoImage(file=f"./assets/images/dark/info.png")

# WINDOW FRAME
window = Frame(app)
Expand All @@ -122,15 +143,22 @@ def runTimer():
time_display = ttk.Label(master = window, text = f'{timer_hours} : {timer_minutes} : {timer_seconds}', font = ("any", 30))
time_display.pack(pady = 5)

# play_button = ttk.Button(master = window, image = play_button_img, width = 20, command = startstopButtonPressed, style="Accent.TButton")
play_button = ttk.Button(master = window, text = "Play", width = 25, command = startstopButtonPressed, style="Accent.TButton")
play_button.pack()

manager_button = ttk.Button(master =window, text = 'Edit Timer', command = lambda: configurator.createManagerWindow(saveTimer, timer_minutes, timer_seconds, timer_hours), width = 25)
manager_button.pack(pady = 5)

about_button = ttk.Button(master =window, text = 'About', command = configurator.createAboutWindow, width = 25)
about_button.pack()
switch_theme_button = ttk.Button(master=window, image=switch_theme_image_light, command=switchTheme)
switch_theme_button.pack(anchor=SW, padx=5, pady=(5, 5))

info_button = ttk.Button(master=window, image=switch_theme_image_light, command = configurator.createAboutWindow)
#info_button.pack(anchor=SE, padx=50)

# THEMED IMAGES
if darkdetect.theme() == "Dark":
switch_theme_button.configure(image=switch_theme_image_dark)
info_button.configure(image=info_image_dark)

# TKINTER MAINLOOP
window.mainloop()