Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

How To Display A Background Image With Tkinter

Import tkinter
from tkinter import *
from PIL import Image, ImageTk

root = Tk()

# Create a photoimage object of the image in the path
image1 = Image.open("<path/image_name>")
test = ImageTk.PhotoImage(image1)

label1 = tkinter.Label(image=test)
label1.image = test

# Position image
label1.place(x=<x_coordinate>, y=<y_coordinate>)
root.mainloop()
Comment

how to create background images in tkinter

# Import module 
from tkinter import *
  
# Create object 
root = Tk()
  
# Adjust size 
root.geometry("400x400")
  
# Add image file
bg = PhotoImage(file = "Your_image.png")
  
# Show image using label
label1 = Label( root, image = bg)
label1.place(x = 0, y = 0)
  
label2 = Label( root, text = "Welcome")
label2.pack(pady = 50)
  
# Create Frame
frame1 = Frame(root)
frame1.pack(pady = 20 )
  
# Add buttons
button1 = Button(frame1,text="Exit")
button1.pack(pady=20)
  
button2 = Button( frame1, text = "Start")
button2.pack(pady = 20)
  
button3 = Button( frame1, text = "Reset")
button3.pack(pady = 20)
  
# Execute tkinter
root.mainloop()
Comment

tkinter background image python 3

You need to apply the grid method to the label that contains the image, not the image object:

bg_image = PhotoImage(file ="pic.gif")
x = Label (image = bg_image)
x.grid(row = 0, column = 0)
http://effbot.org/tkinterbook/photoimage.htm
Comment

PREVIOUS NEXT
Code Example
Python :: python string ends with 
Python :: importing python module from different directory 
Python :: python new date 
Python :: Python connect to a server via RDP 
Python :: python dataframe replace in all dataframe 
Python :: how to capitalize first letter in python in list using list comprehension 
Python :: pickle example 
Python :: python remove duplicates 
Python :: django create superuser from script 
Python :: hugingface ner 
Python :: Python write value in next row of existing .text file 
Python :: postman authorization 
Python :: django data from many to many field in template 
Python :: download image from url 
Python :: np ln 
Python :: Update modules within the requirements.txt file 
Python :: np.random.exponential 
Python :: image blur in python 
Python :: django-mathfilters 
Python :: binary python 
Python :: shallow copy in python 
Python :: how to make an array in python 
Python :: how to filter a series in pandas 
Python :: python get last element of array 
Python :: python string remove whitespace 
Python :: python - count number of occurence in a column 
Python :: numpy loadtxt skip header 
Python :: swapping in python 
Python :: how to fix def multiply(a ,b): a*b 
Python :: jinja if or 
ADD CONTENT
Topic
Content
Source link
Name
6+2 =