🚧 Add icons in toolbar

For #17
This commit is contained in:
Clement Desmidt 2023-06-15 12:12:52 +02:00
parent e27769c8f3
commit d99478935d
9 changed files with 39 additions and 19 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 643 B

BIN
assets/icons/copy.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 423 B

BIN
assets/icons/flip.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 427 B

BIN
assets/icons/folder.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 464 B

BIN
assets/icons/maximize.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 245 B

BIN
assets/icons/next.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 451 B

BIN
assets/icons/timer.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 534 B

View File

@ -1,4 +1,6 @@
pillow~=9.5.0 pillow~=9.5.0
pyinstaller pyinstaller==5.12.0
pygame~=2.4.0 pygame~=2.4.0
customtkinter~=5.1.3 customtkinter~=5.1.3
configparser~=5.3.0
CTkToolTip~=0.4

View File

@ -3,6 +3,9 @@ import os
import subprocess import subprocess
import sys import sys
from tkinter import * from tkinter import *
from CTkToolTip import *
from PIL import ImageTk, Image, ImageOps
import customtkinter import customtkinter
from src.util import Util from src.util import Util
@ -20,34 +23,46 @@ class Toolbar:
toolbar = Frame(self.image_window.window, bd=1, relief=RAISED) toolbar = Frame(self.image_window.window, bd=1, relief=RAISED)
toolbar.pack(side=BOTTOM, fill=X) toolbar.pack(side=BOTTOM, fill=X)
next_button = customtkinter.CTkButton(toolbar, compound=LEFT, text="next ➡️", next_button = customtkinter.CTkButton(toolbar, image=ImageTk.PhotoImage(Image.open("assets/icons/next.png")),
command=self.image_window.next_image) text="", command=self.image_window.next_image)
next_button.pack(side=LEFT, padx=0, pady=0) next_button.pack(side=LEFT, padx=0, pady=0)
CTkToolTip(next_button, delay=0.5, message="Next")
self.bw_button = customtkinter.CTkButton(toolbar, compound=LEFT, text="black&white", self.bw_button = customtkinter.CTkButton(toolbar, image=ImageTk.PhotoImage(Image.open("assets/icons/black-and"
command=self.toggle_black_white) "-white.png")),
text="", command=self.toggle_black_white)
self.bw_button.pack(side=LEFT, padx=0, pady=0) self.bw_button.pack(side=LEFT, padx=0, pady=0)
CTkToolTip(self.bw_button, delay=0.5, message="Black and white image")
self.mirror_button = customtkinter.CTkButton(toolbar, compound=LEFT, command=self.toggle_mirror, self.mirror_button = customtkinter.CTkButton(toolbar, command=self.toggle_mirror, text="",
text="mirror") image=ImageTk.PhotoImage(Image.open("assets/icons/flip.png")))
self.mirror_button.pack(side=LEFT, padx=0, pady=0) self.mirror_button.pack(side=LEFT, padx=0, pady=0)
CTkToolTip(self.mirror_button, delay=0.5, message="Mirrored image")
open_folder_button = customtkinter.CTkButton(toolbar, compound=LEFT, command=self.open_folder, open_folder_button = customtkinter.CTkButton(toolbar, command=self.open_folder, text="",
text="open folder") image=ImageTk.PhotoImage(Image.open("assets/icons/folder.png")))
open_folder_button.pack(side=LEFT, padx=0, pady=0) open_folder_button.pack(side=LEFT, padx=0, pady=0)
CTkToolTip(open_folder_button, delay=0.5, message="Open folder")
self.always_on_top_button = customtkinter.CTkButton(toolbar, compound=LEFT, command=self.toggle_always_on_top, self.always_on_top_button = customtkinter.CTkButton(toolbar, command=self.toggle_always_on_top, text="",
text="always on top") image=ImageTk.PhotoImage(
Image.open("assets/icons/copy.png")))
self.always_on_top_button.pack(side=LEFT, padx=0, pady=0) self.always_on_top_button.pack(side=LEFT, padx=0, pady=0)
CTkToolTip(self.always_on_top_button, delay=0.5, message="Always on top")
self.fullscreen_button = customtkinter.CTkButton(toolbar, compound=LEFT, command=self.toggle_fullscreen, self.fullscreen_button = customtkinter.CTkButton(toolbar, command=self.toggle_fullscreen, text="",
text="fullscreen") image=ImageTk.PhotoImage(
Image.open("assets/icons/maximize.png")))
self.fullscreen_button.pack(side=LEFT, padx=0, pady=0) self.fullscreen_button.pack(side=LEFT, padx=0, pady=0)
CTkToolTip(self.fullscreen_button, delay=0.5, message="Fullscreen")
timer_button = customtkinter.CTkButton(toolbar, compound=LEFT, command=self.toggle_timer, text="timer") timer_button = customtkinter.CTkButton(toolbar, command=self.toggle_timer, text="",
image=ImageTk.PhotoImage(Image.open("assets/icons/timer.png")))
timer_button.pack(side=LEFT, padx=0, pady=0) timer_button.pack(side=LEFT, padx=0, pady=0)
CTkToolTip(timer_button, delay=0.5, message="Toggle timer")
self.timer_label = customtkinter.CTkLabel(toolbar, text=str(self.timer), text_color=Util.get_default_button_color()) 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) self.timer_label.pack(side=RIGHT, ipadx=20)
def display_new_timer(self): def display_new_timer(self):
@ -72,13 +87,15 @@ class Toolbar:
def toggle_black_white(self): def toggle_black_white(self):
self.image_window.option["bw"] = not self.image_window.option["bw"] self.image_window.option["bw"] = not self.image_window.option["bw"]
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.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() self.image_window.image.apply_options()
def toggle_mirror(self): def toggle_mirror(self):
self.image_window.option["mirror"] = not self.image_window.option["mirror"] self.image_window.option["mirror"] = not self.image_window.option["mirror"]
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.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() self.image_window.image.apply_options()
@ -112,6 +129,7 @@ class Toolbar:
def toggle_fullscreen(self): def toggle_fullscreen(self):
self.image_window.option["fullscreen"] = not self.image_window.option["fullscreen"] self.image_window.option["fullscreen"] = not self.image_window.option["fullscreen"]
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.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"]) self.image_window.window.attributes("-fullscreen", self.image_window.option["fullscreen"])