enhance/ui (#28)

Fix #24

Reviewed-on: #28
This commit was merged in pull request #28.
This commit is contained in:
2023-06-07 00:59:45 +02:00
parent a149ab71bb
commit 693c596224
10 changed files with 158 additions and 99 deletions

View File

@@ -3,6 +3,7 @@ import os
import subprocess
import sys
from tkinter import *
import customtkinter
from src.util import Util
@@ -19,32 +20,34 @@ class Toolbar:
toolbar = Frame(self.image_window.window, bd=1, relief=RAISED)
toolbar.pack(side=BOTTOM, fill=X)
next_button = Button(toolbar, relief=FLAT, compound=LEFT, text="next ➡️", command=self.image_window.next_image)
next_button = customtkinter.CTkButton(toolbar, compound=LEFT, text="next ➡️",
command=self.image_window.next_image)
next_button.pack(side=LEFT, padx=0, pady=0)
self.bw_button = Button(toolbar, relief=FLAT, compound=LEFT, text="black&white",
command=self.toggle_black_white)
self.bw_button = customtkinter.CTkButton(toolbar, compound=LEFT, text="black&white",
command=self.toggle_black_white)
self.bw_button.pack(side=LEFT, padx=0, pady=0)
self.mirror_button = Button(toolbar, relief=FLAT, compound=LEFT, command=self.toggle_mirror,
text="mirror")
self.mirror_button = customtkinter.CTkButton(toolbar, compound=LEFT, command=self.toggle_mirror,
text="mirror")
self.mirror_button.pack(side=LEFT, padx=0, pady=0)
open_folder_button = Button(toolbar, relief=FLAT, compound=LEFT, command=self.open_folder, text="open folder")
open_folder_button = customtkinter.CTkButton(toolbar, compound=LEFT, command=self.open_folder,
text="open folder")
open_folder_button.pack(side=LEFT, padx=0, pady=0)
self.always_on_top_button = Button(toolbar, relief=FLAT, compound=LEFT, command=self.toggle_always_on_top,
text="always on top")
self.always_on_top_button = customtkinter.CTkButton(toolbar, compound=LEFT, command=self.toggle_always_on_top,
text="always on top")
self.always_on_top_button.pack(side=LEFT, padx=0, pady=0)
self.fullscreen_button = Button(toolbar, relief=FLAT, compound=LEFT, command=self.toggle_fullscreen,
text="fullscreen")
self.fullscreen_button = customtkinter.CTkButton(toolbar, compound=LEFT, command=self.toggle_fullscreen,
text="fullscreen")
self.fullscreen_button.pack(side=LEFT, padx=0, pady=0)
timer_button = Button(toolbar, relief=FLAT, compound=LEFT, command=self.toggle_timer, text="timer")
timer_button = customtkinter.CTkButton(toolbar, compound=LEFT, command=self.toggle_timer, text="timer")
timer_button.pack(side=LEFT, padx=0, pady=0)
self.timer_label = Label(toolbar, text=self.timer)
self.timer_label = customtkinter.CTkLabel(toolbar, text=str(self.timer), text_color=Util.get_default_button_color())
self.timer_label.pack(side=RIGHT, ipadx=20)
def display_new_timer(self):
@@ -69,13 +72,13 @@ class Toolbar:
def toggle_black_white(self):
self.image_window.option["bw"] = not self.image_window.option["bw"]
self.bw_button.config(bg="blue" if self.image_window.option["bw"] else "grey85")
self.bw_button.configure(fg_color=Util.get_default_active_button_color() if self.image_window.option["bw"] else Util.get_default_button_color())
self.image_window.image.apply_options()
def toggle_mirror(self):
self.image_window.option["mirror"] = not self.image_window.option["mirror"]
self.mirror_button.config(bg="blue" if self.image_window.option["mirror"] else "grey85")
self.mirror_button.configure(fg_color=Util.get_default_active_button_color() if self.image_window.option["mirror"] else Util.get_default_button_color())
self.image_window.image.apply_options()
@@ -96,10 +99,10 @@ class Toolbar:
def toggle_always_on_top(self):
self.image_window.option["always_on_top"] = not self.image_window.option["always_on_top"]
if self.image_window.option["always_on_top"]:
self.always_on_top_button.config(bg="blue")
self.always_on_top_button.configure(fg_color=Util.get_default_active_button_color())
self.stay_on_top()
else:
self.always_on_top_button.config(bg="grey85")
self.always_on_top_button.configure(fg_color=Util.get_default_active_button_color())
self.image_window.window.after_cancel(self.always_on_top_check)
def stay_on_top(self):
@@ -109,6 +112,6 @@ class Toolbar:
def toggle_fullscreen(self):
self.image_window.option["fullscreen"] = not self.image_window.option["fullscreen"]
self.fullscreen_button.config(bg="blue" if self.image_window.option["fullscreen"] else "grey85")
self.fullscreen_button.configure(fg_color=Util.get_default_active_button_color() if self.image_window.option["fullscreen"] else Util.get_default_button_color())
self.image_window.window.attributes("-fullscreen", self.image_window.option["fullscreen"])