This repository has been archived by the owner on Apr 19, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
In this update, I added a viewing of the license, github and version number from the application. it is also now called Image-Viewer.
- Loading branch information
Showing
4 changed files
with
81 additions
and
24 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters