parent
8087d326ef
commit
d8b6e7bd8c
2
main.py
2
main.py
@ -16,7 +16,7 @@ def main():
|
||||
|
||||
root = customtkinter.CTk()
|
||||
root.title("Drawing Training!")
|
||||
root.geometry("300x600")
|
||||
root.geometry("300x300")
|
||||
icon = PhotoImage(file="assets/icons/logo-dt.png")
|
||||
root.iconphoto(True, icon)
|
||||
|
||||
|
@ -47,4 +47,4 @@ class Util:
|
||||
|
||||
@staticmethod
|
||||
def get_default_active_button_color():
|
||||
return "gray29", "gray29"
|
||||
return "green", "green"
|
||||
|
@ -1,3 +1,4 @@
|
||||
import tkinter
|
||||
from pathlib import Path
|
||||
from tkinter import *
|
||||
from tkinter import filedialog
|
||||
@ -33,8 +34,8 @@ class App:
|
||||
self.images_len = customtkinter.CTkLabel(root, text="Found : " + str(len(self.found_images)))
|
||||
self.images_len.pack()
|
||||
|
||||
self.button_frame = Frame(root)
|
||||
self.button_frame.pack(fill=X)
|
||||
self.button_frame = Frame(root, bg=root.cget("bg"))
|
||||
self.button_frame.pack(fill=X, expand=True)
|
||||
|
||||
timers = [
|
||||
Util.format_seconds(30),
|
||||
@ -45,14 +46,15 @@ class App:
|
||||
Util.format_seconds(600),
|
||||
"Custom"
|
||||
]
|
||||
self.buttons = customtkinter.CTkSegmentedButton(
|
||||
root, values=timers,
|
||||
command=self.set_timer_in_seconds
|
||||
)
|
||||
self.buttons.pack(fill=X)
|
||||
|
||||
self.buttons = []
|
||||
for i, timer in enumerate(timers):
|
||||
new_button = customtkinter.CTkButton(self.button_frame, width=10, text=timer, command=lambda t=timer: self.set_timer_in_seconds(t))
|
||||
new_button.pack(side=tkinter.LEFT, fill=X, expand=True)
|
||||
self.buttons.append(new_button)
|
||||
|
||||
self.launch_button = customtkinter.CTkButton(root, text="Let's draw!", command=self.lets_draw, state="disabled")
|
||||
self.launch_button.pack(side="bottom")
|
||||
self.launch_button.pack(side=tkinter.BOTTOM)
|
||||
|
||||
self.read_config()
|
||||
|
||||
@ -73,7 +75,9 @@ class App:
|
||||
self.session_window.open()
|
||||
|
||||
def select_folder(self):
|
||||
self.selected_folder = filedialog.askdirectory()
|
||||
new_directory = filedialog.askdirectory()
|
||||
if new_directory:
|
||||
self.selected_folder = new_directory
|
||||
self.folder_name.configure(text="Folder : " + self.selected_folder)
|
||||
Config.set_config_var("default_folder", self.selected_folder).save()
|
||||
self.find_images_in_folder()
|
||||
@ -93,6 +97,10 @@ class App:
|
||||
self.launch_button.configure(state="disabled")
|
||||
|
||||
def set_timer_in_seconds(self, user_data):
|
||||
# resetting buttons states
|
||||
for button in self.buttons:
|
||||
button.configure(fg_color=(Util.get_default_button_color() if user_data != button.cget("text") else Util.get_default_active_button_color()))
|
||||
|
||||
self.custom = False
|
||||
if user_data == "Custom":
|
||||
return self.custom_session()
|
||||
|
@ -45,14 +45,14 @@ class SessionWindow:
|
||||
text=session.number_of_drawings + " drawings of " + Util.format_seconds(int(session.timer)) + " each",
|
||||
command=partial(self.edit_element, i),
|
||||
fg_color=(
|
||||
Util.get_default_button_color() if i == self.selected_element_index else Util.get_default_active_button_color())
|
||||
Util.get_default_active_button_color() if i == self.selected_element_index else Util.get_default_button_color())
|
||||
)
|
||||
elif isinstance(session, BreakElement):
|
||||
new_session = CTkButton(self.left_column,
|
||||
text="Break of " + Util.format_seconds(int(session.timer)) + " each",
|
||||
command=partial(self.edit_element, i),
|
||||
fg_color=(
|
||||
Util.get_default_button_color() if i == self.selected_element_index else Util.get_default_active_button_color())
|
||||
Util.get_default_active_button_color() if i == self.selected_element_index else Util.get_default_button_color())
|
||||
)
|
||||
else:
|
||||
raise Exception("unknown type.")
|
||||
|
Loading…
Reference in New Issue
Block a user