Python Forum

Full Version: Zooming a tkinter image
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am trying to create a program that can display images, this is going to tie in with some bigger projects in the future so I thought of just making the photo displaying program now to save me having to rewrite all the code, right now I am using the program to display 32x32 sprites but it looks tiny in comparison with my monitor (which is bad) so I wanted a way to zoom them without having to go back into Photoshop to redraw the images.

import tkinter
from tkinter import *
import threading
from threading import Timer

window = Tk()
window.title("Test")
window.config(bg = "white")

Px = 0
Py = 0
zw = 8
zh = 8
PlayerF1 = PhotoImage(file = "F1.png")
PlayerF2 = PhotoImage(file = "F2.png")
PlayerF3 = PhotoImage(file = "F3.png")
PlayerF1.zoom(zw, zh)
PlayerF2.zoom(zw, zh)
PlayerF3.zoom(zw, zh)
Playerd = Label(window, image = PlayerF1, bg = "white")

Playerd.place(x = 30, y = 30)

def ani():
    print("Cycle")
    def Frame1():
        print("Loop")
        Playerd.config(image = PlayerF1)
        window.update()
        def Frame2():
            print("Loop2")
            Playerd.config(image = PlayerF2)
            window.update()
            def Frame3():
                print("Loop3")
                Playerd.config(image = PlayerF3)
                window.update()
                ani()
                
            t = Timer(0.1, Frame3)
            t.start()
        t = Timer(0.1, Frame2)
        t.start()
    t = Timer(0.1, Frame1)
    t.start()

ani()
window.mainloop()
As you can see, I tried to use .zoom(), but it hasn't actually done anything to the image.

Right now I am also using the program to test if animations would be viable with this kind of code, so, for the most part, you can ignore ani() and its nested defs.

Any help would be greatly appreciated!
you may want to take a look at: https://stackoverflow.com/a/48137257
(Nov-09-2019, 03:17 PM)Larz60+ Wrote: [ -> ]you may want to take a look at: https://stackoverflow.com/a/48137257

I have seen that post before, it didn't really help that much (at least for me)...