diff --git a/Image-Viewer.exe b/Image-Viewer.exe index dd3d826..d54629e 100644 Binary files a/Image-Viewer.exe and b/Image-Viewer.exe differ diff --git a/main.py b/main.py index f6e2fe7..d352586 100644 --- a/main.py +++ b/main.py @@ -2,10 +2,14 @@ import sys import webbrowser -from tkinter import Tk, Menu, Canvas, messagebox +from tkinter import Tk, Menu, Canvas, messagebox, Label, Entry, Button from PIL import Image, ImageTk -LICENSE_TEXT = """ + +def show_license(): + """ This function shows the license. """ + + messagebox.showinfo('License', """ MIT License Copyright (c) 2020 @@ -28,53 +32,80 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -""" - +""") -def show_license(): - """ This function shows the license. """ - - messagebox.showinfo('License', LICENSE_TEXT) def opening_github(): """ This function opens the github. """ webbrowser.open('https://github.com/RIDERIUS/Image-Viewer') + def show_version(): """ This function shows the version. """ - messagebox.showinfo('Version', 'Version 0.2.0') + messagebox.showinfo('Version', 'Version 0.3.0') + + +def crop_image(): + """ This function is needed to crop images. """ + + def cropping(): + """This function will crop images.""" + root.geometry( + f"{x_entry_cropping_window.get()}x{y_entry_cropping_window.get()}") + root.mainloop() + + cropping_window = Tk() + cropping_window.geometry('404x65') + cropping_window.title('Crop Image') + cropping_window.resizable(False, False) + + x_label_cropping_window = Label(cropping_window, text='Width Image') + x_label_cropping_window.grid(column=0, row=0) + y_label_cropping_window = Label(cropping_window, text='Height Image') + y_label_cropping_window.grid(column=2, row=0) + + x_entry_cropping_window = Entry(cropping_window,) + x_entry_cropping_window.grid(column=1, row=0) + y_entry_cropping_window = Entry(cropping_window) + y_entry_cropping_window.grid(column=3, row=0) + + button_cropping_window = Button( + cropping_window, text='Submit', command=cropping) + button_cropping_window.grid(column=2, row=1) + + cropping_window.mainloop() + + +FILE_PATH = str(sys.argv[1]) -def main(): - """ Main function in the image viewer. """ +image_pil = Image.open(FILE_PATH) +(width, height) = image_pil.size - file_path = str(sys.argv[1]) +root = Tk() +root.title("Image-Viewer") +root.geometry(f'{width}x{height}') +root.resizable(False, False) - image_pil = Image.open(file_path) - (width, height) = image_pil.size - image_pil = image_pil.resize( - (width, int(image_pil.size[1] * (width / image_pil.size[0]))), Image.ANTIALIAS) +menu = Menu(root) +root.config(menu=menu) - root = Tk() - root.title("Image-Viewer") - root.geometry(f'{width}x{height}') - root.resizable(False, False) +about_menu = Menu(menu) +edit_image_menu = Menu(menu) - menu = Menu(root) - new_item = Menu(menu) - new_item.add_command(label='License', command=show_license) - new_item.add_command(label='Github', command=opening_github) - new_item.add_command(label='Version', command=show_version) - menu.add_cascade(label='About', menu=new_item) - root.config(menu=menu) +about_menu.add_command(label='License', command=show_license) +about_menu.add_command(label='Github', command=opening_github) +about_menu.add_command(label='Version', command=show_version) +edit_image_menu.add_command(label='Crop Image', command=crop_image) - image = ImageTk.PhotoImage(image_pil) +menu.add_cascade(label='About', menu=about_menu) +menu.add_cascade(label='Edit Image', menu=edit_image_menu) - canv = Canvas(root, width=width, height=height) - canv.create_image(width / 2, height / 2, image=image) - canv.pack() +image = ImageTk.PhotoImage(image_pil) - root.mainloop() +canv = Canvas(root, width=width, height=height) +canv.create_image(width / 2, height / 2, image=image) +canv.pack() -main() +root.mainloop() diff --git a/requirements.txt b/requirements.txt index 38bd2bd..6ca6c45 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1 @@ -pillow==7.2.0 +pillow==7.2.0 \ No newline at end of file