✨ Add sessions
This commit is contained in:
@@ -12,6 +12,7 @@ from src.window.session import SessionWindow
|
||||
class App:
|
||||
def __init__(self, root):
|
||||
super().__init__()
|
||||
self.list_in_session = None
|
||||
self.custom = False
|
||||
self.config = Config()
|
||||
self.session = None
|
||||
@@ -79,6 +80,7 @@ class App:
|
||||
self.launch_button.config(state="disabled")
|
||||
|
||||
def set_timer_in_seconds(self, user_data):
|
||||
self.custom = False
|
||||
self.timer = user_data
|
||||
for button in self.buttons:
|
||||
if button['text'] == Util.format_seconds(self.timer):
|
||||
@@ -90,3 +92,7 @@ class App:
|
||||
def set_custom(self, list_in_session):
|
||||
self.custom = True
|
||||
self.list_in_session = list_in_session
|
||||
self.check_lets_draw()
|
||||
for button in self.buttons:
|
||||
button.config(bg="gray85")
|
||||
self.buttons[-1].config(bg="blue")
|
||||
|
@@ -47,8 +47,17 @@ class ImageWindow:
|
||||
|
||||
def lets_draw(self, images, timer):
|
||||
random.shuffle(images)
|
||||
timers = []
|
||||
if self.app.custom:
|
||||
for element in self.app.list_in_session:
|
||||
for number in range(int(element.number_of_drawings)):
|
||||
timers.append(int(element.timer))
|
||||
else:
|
||||
for i in images:
|
||||
timers.append(timer)
|
||||
|
||||
self.image.images = images
|
||||
self.toolbar.timer = timer
|
||||
self.toolbar.timers = timers
|
||||
self.next_image()
|
||||
|
||||
def play_countdown(self):
|
||||
|
@@ -32,6 +32,9 @@ class SessionWindow:
|
||||
self.list_in_session = []
|
||||
|
||||
def open(self):
|
||||
list = Config._CONFIG['session']
|
||||
if list:
|
||||
self.list_in_session = [DrawingElement(e) for e in list]
|
||||
self.update_session_list()
|
||||
|
||||
def update_session_list(self):
|
||||
@@ -155,6 +158,7 @@ class SessionWindow:
|
||||
self.window.destroy()
|
||||
|
||||
def save_session(self):
|
||||
Config._CONFIG['session'] = []
|
||||
for element in self.list_in_session:
|
||||
Config._CONFIG['session'].append(element.__dict__)
|
||||
Config.save()
|
||||
|
Reference in New Issue
Block a user