Dec-03-2019, 05:36 PM
Alexander,
I have seen this done using the PIL module, it has a function to resize called thumbnail.
Instead of label they used a canvas object create_image. below is an function from a class I'm using to preview an icon image in my script hope it will point you in the right direction:
I have seen this done using the PIL module, it has a function to resize called thumbnail.
Instead of label they used a canvas object create_image. below is an function from a class I'm using to preview an icon image in my script hope it will point you in the right direction:
def change_icon(self, size=(40,40)): # size of the icon 40x40 from PIL.ImageTk import PhotoImage, Image # 2 PIL objects self.can.delete('object') # removes exiting object from canvas pic_num= self.combo3.current() # retrieves the index number drop down pic= self.photos[pic_num] # gets photo from list print(pic) img_dir= r'../PIL/images/' img_obj= Image.open(img_dir + pic) img_obj.thumbnail(size, Image.ANTIALIAS) self.parent.one= self.img = PhotoImage(img_obj) #to prevent garbage collect icon= self.can.create_image(100,40,image=self.img, anchor='center', tag='object') self.parent.update() # self.parent is my Tk()