From 4f5f7104e537ad6dd736b61ba697f9e61d83ba8b Mon Sep 17 00:00:00 2001 From: Shikiryu Date: Tue, 23 May 2023 19:36:15 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Add=20button=20to=20open=20current?= =?UTF-8?q?=20folder?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Works on windows Fix #3 --- app.py | 2 +- image.py | 14 +++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/app.py b/app.py index 3912c61..0aa46d8 100644 --- a/app.py +++ b/app.py @@ -46,7 +46,7 @@ class App: self.launch_button.pack(side="bottom") def lets_draw(self): - self.image_window = ImageWindow(self.root) + self.image_window = ImageWindow(self) self.image_window.lets_draw(self.found_images.copy(), self.timer) def select_folder(self): diff --git a/image.py b/image.py index b9a3e38..1fbe170 100644 --- a/image.py +++ b/image.py @@ -1,3 +1,4 @@ +import os import random from tkinter import * from PIL import ImageTk, Image, ImageOps @@ -5,8 +6,9 @@ from util import Util class ImageWindow: - def __init__(self, window): - self.window = Toplevel(window) + def __init__(self, app): + self.app = app + self.window = Toplevel(app.root) self.window.title("Image") self.window.geometry("1280x1024") self.option = { @@ -32,6 +34,10 @@ class ImageWindow: self.mirror_button = Button(toolbar, relief=FLAT, compound=LEFT, command=self.toggle_mirror, text="mirror") self.mirror_button.pack(side=LEFT, padx=0, pady=0) + self.open_folder_button = Button(toolbar, relief=FLAT, compound=LEFT, command=self.open_folder + , text="open folder") + self.open_folder_button.pack(side=LEFT, padx=0, pady=0) + self.timer_button = Button(toolbar, relief=FLAT, compound=LEFT, command=self.toggle_timer, text="timer") self.timer_button.pack(side=LEFT, padx=0, pady=0) @@ -74,7 +80,9 @@ class ImageWindow: self.timer_label.pack_forget() except TclError: self.timer_label.pack(side=RIGHT, ipadx=20) - # self.timer_label.config() + + def open_folder(self): + os.startfile(self.app.selected_folder) def lets_draw(self, images, timer): random.shuffle(images)