diff --git a/TempCode.py b/TempCode.py deleted file mode 100644 index 4ceddc4..0000000 --- a/TempCode.py +++ /dev/null @@ -1,3 +0,0 @@ - -# command=fns.update_contrast) -# contrast_scale.grid(row=9, column=0, pady=(10, 0), columnspan=4) \ No newline at end of file diff --git a/__pycache__/design.cpython-310.pyc b/__pycache__/design.cpython-310.pyc deleted file mode 100644 index fb85dad..0000000 Binary files a/__pycache__/design.cpython-310.pyc and /dev/null differ diff --git a/__pycache__/functions.cpython-310.pyc b/__pycache__/functions.cpython-310.pyc deleted file mode 100644 index a3d563f..0000000 Binary files a/__pycache__/functions.cpython-310.pyc and /dev/null differ diff --git a/__pycache__/resources.cpython-310.pyc b/__pycache__/resources.cpython-310.pyc deleted file mode 100644 index 5edc1fb..0000000 Binary files a/__pycache__/resources.cpython-310.pyc and /dev/null differ diff --git a/design.py b/design.py index ffcd415..6e096db 100644 --- a/design.py +++ b/design.py @@ -38,12 +38,13 @@ def __init__(self, master, row, column, text, data1, data2): class Slider: def __init__(self, master, row, length, label, update_command, release_command): self.scale = Scale(master, label=label, command=update_command, orient=HORIZONTAL, from_=-50, to=50, - showvalue=False, length=length, font=('Consolas', 11), bg=color_1, fg=color_2) - self.scale.grid(row=row, column=0, pady=(20, 0), columnspan=4) + showvalue=False, length=length, font=('Consolas', 11), bg=color_1, fg=color_2) + self.scale.grid(row=row, column=0, pady=(0, 15), columnspan=4) self.scale.bind('', release_command) sliders.append(self.scale) + class Line: - def __init__(self, master, row): - Label(master, text = "-"*50, font = ('Consolas', 11), bg = color_1, - fg = color_2).grid(row = row, column = 0, columnspan = 4) + def __init__(self, master, row, pady=(0, 0)): + Label(master, text="-"*50, font=('Consolas', 11), bg=color_1, + fg=color_2).grid(row=row, column=0, columnspan=4, pady=pady) diff --git a/editor.py b/editor.py index a13dfe1..e0f62d8 100644 --- a/editor.py +++ b/editor.py @@ -1,4 +1,5 @@ from tkinter import * +from tkinter import ttk from PIL import Image from pip import main @@ -77,13 +78,13 @@ color_2 = design.color_2 middle_frame_height = height*.15 -middle_frame = Frame(root, border=3, borderwidth=5, bg=color_1, - pady=10, width=main_frame_width, height=middle_frame_height, relief=RIDGE) +middle_frame = Frame(root, height=middle_frame_height, border=3, borderwidth=5, bg=color_1, + pady=10, width=main_frame_width, relief=RIDGE) middle_frame.grid(row=1, column=1, padx=10, pady=( 10, 0), ipadx=5, ipady=5, sticky=N) -main_frame = Frame(root, border=3, borderwidth=5, bg=color_1, - pady=20, width=main_frame_width, height=height - 340 - middle_frame_height, relief=RIDGE) +main_frame = Frame(root, height=height - 340 - middle_frame_height, border=3, borderwidth=5, bg=color_1, + pady=10, width=main_frame_width, relief=RIDGE) main_frame.grid(row=2, column=1, padx=10, pady=(5, 0)) # importing images @@ -138,7 +139,7 @@ LabeledButton(main_frame, 2, 2, my_images.effects_img, 'Effects', fns.effects) LabeledButton(main_frame, 2, 3, my_images.add_img, 'Add Image', fns.add_img) -Line(main_frame, 3) +Line(main_frame, 3, pady=(0, 10)) brightness_slider = Slider(main_frame, 4, main_frame_width*.7, 'Brightness', fns.update_brightness, fns.apply_enhance) @@ -149,6 +150,15 @@ color_slider = Slider(main_frame, 7, main_frame_width*.7, 'Color', fns.update_color, fns.apply_enhance) +Line(main_frame, 8) + +status = Label(main_frame, bg=color_1, text='----Status----', + fg=color_2, font=('Consolas bold', 10)) +status.grid(row=9, column=0, columnspan=4) +if fns.current_img is None: + status.configure(text="Open a new image") + +fns.set_status(status) # setting every frame non-resizable for w in root.winfo_children(): w.grid_propagate(0) diff --git a/functions.py b/functions.py index 05c7e12..4142e16 100644 --- a/functions.py +++ b/functions.py @@ -1,3 +1,4 @@ +from math import sqrt from tkinter import * from PIL import Image, ImageTk, ImageEnhance, ImageOps from PIL.ImageFilter import * @@ -5,18 +6,31 @@ img_window = None current_img = None +clipboard_img = None i_f_w = i_f_h = 0 history_data = [] current = -1 +status = None -def set_img_window(i_w, w_w, w_h): + +def set_img_window(i_w, f_w, f_h): global img_window, i_f_w, i_f_h img_window = i_w - i_f_w = w_w - i_f_h = w_h + i_f_w = f_w + i_f_h = f_h + + +def set_status(st): + global status + status = st + +def update_status(val): + status.configure(text=val) +def success_status(): + update_status("Changes are done successfully") def fit_image(img, w, h): i_w, i_h = img.size @@ -31,16 +45,12 @@ def fit_image(img, w, h): in_h = int(i_h/w_s) return img.resize((in_w, in_h)) - def change_img(new_img, add_in_history=True, update=True): - # if a very large image is given then resize - i_w, i_h = new_img.size - if i_w > 1400: - new_img = new_img.resize((1400, int(1400*i_h/i_w))) - elif i_h > 1400: - new_img = new_img.resize((int(1400*i_w/i_h), 1400)) - global current_img, photo, current + w, h = new_img.size + if w > 2048 or h > 2048: + new_img = fit_image(new_img, 2048, 2048) + if update: current_img = new_img if add_in_history: @@ -53,6 +63,7 @@ def change_img(new_img, add_in_history=True, update=True): photo = ImageTk.PhotoImage(new_img) img_window.create_image(in_w/2, in_h/2, image=photo) img_window.configure(width=in_w, height=in_h) + if status is not None : success_status() def origional(cord): @@ -69,59 +80,104 @@ def valid(a, b): return origional(a) + origional(b) -rect = c1 = c2 = None - - -def end_selection(cmd): - img_window.unbind('') - img_window.unbind('') - img_window.unbind('