Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

resizing windows with background tkinter

from tkinter import *

from PIL import Image, ImageTk

root = Tk()
root.title("Title")
root.geometry("600x600")
root.configure(background="black")



class Example(Frame):
    def __init__(self, master, *pargs):
        Frame.__init__(self, master, *pargs)



        self.image = Image.open("./resource/Background.gif")
        self.img_copy= self.image.copy()


        self.background_image = ImageTk.PhotoImage(self.image)

        self.background = Label(self, image=self.background_image)
        self.background.pack(fill=BOTH, expand=YES)
        self.background.bind('<Configure>', self._resize_image)

    def _resize_image(self,event):

        new_width = event.width
        new_height = event.height

        self.image = self.img_copy.resize((new_width, new_height))

        self.background_image = ImageTk.PhotoImage(self.image)
        self.background.configure(image =  self.background_image)



e = Example(root)
e.pack(fill=BOTH, expand=YES)


root.mainloop()
Comment

PREVIOUS NEXT
Code Example
Python :: Circular heatmap python 
Python :: create matrice 2d whit 3colum panda 
Python :: Use if a not trusted message will come up 
Python :: uninstall python 2.7 in ubuntu 
Python :: helper for FastAPI Users to create a super user 
Python :: python input text in file 
Python :: python get all items from generator 
Python :: pandas terms for list of substring present in another list python 
Python :: ev. DJANGO CREATE ACC 
Python :: features and image recongnition 
Python :: ordereddict deleting wrong item 
Python :: drop values based on type pandas 
Python :: zipfian distribution python 
Python :: spacy text annotation dict comprehension 
Python :: float value in regression expression python 
Python :: python increment char a to b az to ba 
Python :: print convert hex as string ascii 
Python :: python enumerate list with comprehension 
Python :: Python String to array using list comprehension 
Python :: python get all items exept las from array 
Python :: find the middle of the document in the image opencv 
Python :: python open multiple .py windows 
Python :: how to count the appearance of number or string in a list python 
Python :: python project 
Python :: how to recover a list from string in python 
Python :: How to compress image field in django? 
Python :: [Solved] Pandas TypeError: no numeric data to plot 
Python :: adding hyperlinks in streamlit table 
Python :: hello world with a variable in python 3 
Python :: task orchestration framework 
ADD CONTENT
Topic
Content
Source link
Name
7+1 =