Add button to open current folder #21

Merged
Shikiryu merged 1 commits from feature/open_folder into main 2023-05-23 21:36:57 +02:00
2 changed files with 12 additions and 4 deletions
Showing only changes of commit 4f5f7104e5 - Show all commits

2
app.py
View File

@ -46,7 +46,7 @@ class App:
self.launch_button.pack(side="bottom") self.launch_button.pack(side="bottom")
def lets_draw(self): 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) self.image_window.lets_draw(self.found_images.copy(), self.timer)
def select_folder(self): def select_folder(self):

View File

@ -1,3 +1,4 @@
import os
import random import random
from tkinter import * from tkinter import *
from PIL import ImageTk, Image, ImageOps from PIL import ImageTk, Image, ImageOps
@ -5,8 +6,9 @@ from util import Util
class ImageWindow: class ImageWindow:
def __init__(self, window): def __init__(self, app):
self.window = Toplevel(window) self.app = app
self.window = Toplevel(app.root)
self.window.title("Image") self.window.title("Image")
self.window.geometry("1280x1024") self.window.geometry("1280x1024")
self.option = { 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 = Button(toolbar, relief=FLAT, compound=LEFT, command=self.toggle_mirror, text="mirror")
self.mirror_button.pack(side=LEFT, padx=0, pady=0) 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 = Button(toolbar, relief=FLAT, compound=LEFT, command=self.toggle_timer, text="timer")
self.timer_button.pack(side=LEFT, padx=0, pady=0) self.timer_button.pack(side=LEFT, padx=0, pady=0)
@ -74,7 +80,9 @@ class ImageWindow:
self.timer_label.pack_forget() self.timer_label.pack_forget()
except TclError: except TclError:
self.timer_label.pack(side=RIGHT, ipadx=20) 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): def lets_draw(self, images, timer):
random.shuffle(images) random.shuffle(images)