-
Notifications
You must be signed in to change notification settings - Fork 0
/
image_widgets.py
34 lines (26 loc) · 1.24 KB
/
image_widgets.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import customtkinter as ctk
from tkinter import filedialog, Canvas
from settings import *
class ImageImport(ctk.CTkFrame):
def __init__(self, parent, import_func):
super().__init__(master=parent)
self.grid(column=0, columnspan=2, row=0, sticky='nsew')
self.import_func = import_func
# button
ctk.CTkButton(self, text='Open Image',
command=self.open_dialog).pack(expand=True)
# dialog box of file explorer to select image
def open_dialog(self):
path = filedialog.askopenfile().name
self.import_func(path)
class ImageOutput(Canvas):
def __init__(self, parent, resize_image):
super().__init__(master=parent, background=BACKGROUND_COLOR,
bd=0, highlightthickness=0, relief='ridge')
self.grid(row=0, column=1, sticky = 'nsew', padx = 10, pady = 10)
self.bind('<Configure>', resize_image)
class CloseOutput(ctk.CTkButton):
def __init__(self, parent, close_func):
super().__init__(master=parent, command=close_func, text='X', text_color=WHITE, fg_color='transparent',
width=40, height=40, corner_radius=0, hover_color=CLOSE_RED)
self.place(relx=0.99, rely=0.01, anchor='ne')