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