Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import tkinter as tk
- from PIL import Image, ImageTk
- import sys
- import os
- name = os.path.basename(sys.argv[0])
- path = ""
- try:
- path = os.path.normpath(sys.argv[1])
- except IndexError:
- print(f"Usage: {name} uri")
- sys.exit()
- window = tk.Tk()
- # open the image from disk
- image = Image.open(path)
- width, height = image.size
- ws = window.winfo_screenwidth()
- hs = window.winfo_screenheight()
- x = (ws/2) - (width/2)
- y = (hs/2) - (height/2)
- # create a Tk image and pack it
- img = ImageTk.PhotoImage(Image.open(path))
- panel = tk.Label(window, image = img)
- panel.pack(side = "bottom", fill = "both", expand = "yes")
- # set the window details
- window.title("Kite - " + path)
- window.geometry(f"{width}x{height}+{int(x)}+{int(y)}")
- window.mainloop();
Add Comment
Please, Sign In to add comment