diff --git a/Image-Viewer.exe b/Image-Viewer.exe new file mode 100644 index 0000000..dd3d826 Binary files /dev/null and b/Image-Viewer.exe differ diff --git a/Main.py b/Main.py index 7fc25b9..f6e2fe7 100644 --- a/Main.py +++ b/Main.py @@ -1,23 +1,80 @@ +""" This is the main file to launch the Image-Viewer. """ + import sys -from tkinter import * +import webbrowser +from tkinter import Tk, Menu, Canvas, messagebox from PIL import Image, ImageTk -file_path = str(sys.argv[1]) +LICENSE_TEXT = """ +MIT License + +Copyright (c) 2020 + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +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') + +def main(): + """ Main function in the image viewer. """ + + file_path = str(sys.argv[1]) + + 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) + + root = Tk() + root.title("Image-Viewer") + root.geometry(f'{width}x{height}') + root.resizable(False, False) -imagePIL = Image.open(file_path) -(width, height) = imagePIL.size -imagePIL = imagePIL.resize( - (width, int(imagePIL.size[1] * (width / imagePIL.size[0]))), Image.ANTIALIAS) + 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) -root = Tk() -root.title("Picture reader") -root.geometry(f'{width}x{height}') -root.resizable(False, False) + image = ImageTk.PhotoImage(image_pil) -image = ImageTk.PhotoImage(imagePIL) + canv = Canvas(root, width=width, height=height) + canv.create_image(width / 2, height / 2, image=image) + canv.pack() -canv = Canvas(root, width=width, height=height) -imageSprite = canv.create_image(width / 2, height / 2, image=image) -canv.pack() + root.mainloop() -root.mainloop() +main() diff --git a/Picture-reader.exe b/Picture-reader.exe deleted file mode 100644 index a7cc5f4..0000000 Binary files a/Picture-reader.exe and /dev/null differ diff --git a/README.md b/README.md index d2813e0..c0bddee 100644 --- a/README.md +++ b/README.md @@ -1,20 +1,20 @@ -# Picture-reader +# Image-Viewer [![forthebadge made-with-python](http://ForTheBadge.com/images/badges/made-with-python.svg)](https://www.python.org/) [![forthebadge](https://forthebadge.com/images/badges/built-with-love.svg)](https://forthebadge.com) -Hi! **Picture-reader** is a Windows picture reader based on Python 3.8. +Hi! **Image-Viewer** is a Windows image viewer based on Python 3.8. ## Using: -You must download "Picture-reader.exe" from the root of the repository. Then you have to open the image with "Picture reader.exe". +You must download "Image-Viewer.exe" from the root of the repository. Then you have to open the image with "Image-Viewer.exe". -![OpenFile](https://image.prntscr.com/image/EmCtDUhDTH_HHxAgBFwLag.png) +![OpenFile](https://image.prntscr.com/image/wbp7ZkYURHW2kH31pf-TFA.png) Then you will see a window like this: -![Picture](https://image.prntscr.com/image/mfNX2USsREu--i70QjsyYA.png) +![Picture](https://image.prntscr.com/image/Xem6tkkkT8SKmUA9bZi-aQ.png) ## Modules Used: @@ -28,16 +28,16 @@ Python 3.8 or higher is recommended for using this program. You need to install ## Compilation -Picture-reader is compiled with pyinstaller. This command is used for this. +Image-Viewer is compiled with pyinstaller. This command is used for this. -> pyinstaller -F -i icon.ico -w -n Picture-reader main.py +> pyinstaller -F -i icon.ico -w -n Image-Viewer main.py You can see what these parameters mean in the [pyinstaller documentation](https://pyinstaller.readthedocs.io/en/stable/usage.html#options). ## Versioning -**Picture-reader** uses [Semantic Versioning](https://semver.org/). +**Image-Viewer** uses [Semantic Versioning](https://semver.org/). ## License -This project is licensed under the MIT License, see the [LICENSE](https://github.com/RIDERIUS/Picture-reader/blob/main/LICENSE) file for details. \ No newline at end of file +This project is licensed under the MIT License, see the [LICENSE](https://github.com/RIDERIUS/Image-Viewer/blob/main/LICENSE) file for details. \ No newline at end of file