python - How to resize a Splash Screen Image using Tkinter? -


i working on game school project , part of splash screen load simulate 'loading' of game. have code , bring image, want bring defined .gif file onto screen. here code:

import tkinter tk root = tk.tk() root.overrideredirect(true) width = root.winfo_screenwidth() height = root.winfo_screenheight() root.geometry('%dx%d+%d+%d' % (width*1, height*1, width*0, height*0)) image_file = "example.gif" image = tk.photoimage(file=image_file) canvas = tk.canvas(root, height=height*1, width=width*1, bg="darkgrey") canvas.create_image(width*1/2, height*1/2, image=image) canvas.pack() root.after(5000, root.destroy) root.mainloop() 

my issue because image larger screen not fit whole image. how can resize image using code .gif image fits on screen?

p.s. please not make real drastic changes code want, value changes ok.

i recommend use pil.
here code:

from pil import image, imagetk import tkinter tk  root = tk.tk() root.overrideredirect(true) width = root.winfo_screenwidth() height = root.winfo_screenheight() root.geometry('%dx%d+%d+%d' % (width*1, height*1, width*0, height*0)) image = image.open(image_path) image = image.resize((width, height), image.antialias) image = imagetk.photoimage(image) canvas = tk.canvas(root, height=height*1, width=width*1, bg="darkgrey") canvas.create_image(width*1/2, height*1/2, image=image) canvas.pack() root.after(5000, root.destroy) root.mainloop() 

you width , height from:

width = root.winfo_screenwidth() height = root.winfo_screenheight() 

then call resize()

if still want use photoimage, can try zoom(x, y) , subsample(x, y). here doc. way, it's not work on computer...(python2.7 + win7)


Comments

Popular posts from this blog

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -

mongodb - How to keep track of users making Stripe Payments -