0

I have an image of a bit large size (470 x 580)px.

I want to place this image in a 4x4 Canvas.

I do the following - but it doesnot squeeze the complete image into the canvas, it just crops the canvas size from the image and display it here.

from Tkinter import *
import ttk

class Application(Frame):
    def __init__(self, master=None):
        Frame.__init__(self, master)

        self.createWidgets(master)


    def createWidgets(self, master):

        master.title("Login - AHPS")
        self.mainframe = ttk.Frame(master, padding=(5,5,12,12))
        self.mainframe.grid(row=0, column=0, sticky=(W, N, E, S) )

        self.img = PhotoImage(file='image.gif')
        self.welcomeImage = Canvas(self.mainframe)
        self.welcomeImage.create_image(0, 0, image=self.img, anchor=NW)
        self.welcomeImage.iamge = self.img

        self.welcomeImage.grid(row=0, column=0, rowspan=4, columnspan=4, sticky=(W, N, E, S))


root = Tk()
app = Application(master=root)
app.mainloop()

How can I squeeze the complete image into this canvas?

Bryan Oakley
  • 370,779
  • 53
  • 539
  • 685
Ejaz
  • 1,504
  • 3
  • 25
  • 51

0 Answers0