Answers for "how to set background image in tkinter frame"

2

how to set background image in python tkinter

om tkinter import *
from PIL import ImageTk

canvas = Canvas(width=600, height=800, bg='blue')
canvas.pack(expand=YES, fill=BOTH)

image = ImageTk.PhotoImage(file="File route")
canvas.create_image(10, 10, image=image, anchor=NW)

mainloop()
Posted by: Guest on July-06-2020
0

how to set background image in python tkinter

app = Tk()
app.title("Welcome")
image2 =Image.open('C:\\Users\\adminp\\Desktop\\titlepage\\front.gif')
image1 = ImageTk.PhotoImage(image2)
w = image1.width()
h = image1.height()
app.geometry('%dx%d+0+0' % (w,h))
#app.configure(background='C:\\Usfront.png')
#app.configure(background = image1)

labelText = StringVar()
labelText.set("Welcome !!!!")
#labelText.fontsize('10')

label1 = Label(app, image=image1, textvariable=labelText,
               font=("Times New Roman", 24),
               justify=CENTER, height=4, fg="blue")
label1.pack()

app.mainloop()
Posted by: Guest on May-16-2020
0

how to set background image in tkinter frame

from tkinter import *
  
# Create object 
root = Tk()
  
# Adjust size 
root.geometry("400x400")
  
# Add image file
bg = PhotoImage(file = "Your_img.png")
  
# Create Canvas
canvas1 = Canvas( root, width = 400,
                 height = 400)
  
canvas1.pack(fill = "both", expand = True)
  
# Display image
canvas1.create_image( 0, 0, image = bg, 
                     anchor = "nw")
  
# Add Text
canvas1.create_text( 200, 250, text = "Welcome")
  
# Create Buttons
button1 = Button( root, text = "Exit")
button3 = Button( root, text = "Start")
button2 = Button( root, text = "Reset")
  
# Display Buttons
button1_canvas = canvas1.create_window( 100, 10, 
                                       anchor = "nw",
                                       window = button1)
  
button2_canvas = canvas1.create_window( 100, 40,
                                       anchor = "nw",
                                       window = button2)
  
button3_canvas = canvas1.create_window( 100, 70, anchor = "nw",
                                       window = button3)
  
# Execute tkinter
root.mainloop()
Posted by: Guest on August-30-2021
0

python tk frame background image

from PIL import Image, ImageTk
import tkinter as tk

IMAGE_PATH = 'sfondo.png'
WIDTH, HEIGTH = 200, 200

root = tk.Tk()
root.geometry('{}x{}'.format(WIDTH, HEIGTH))

canvas = tk.Canvas(root, width=WIDTH, height=HEIGTH)
canvas.pack()

img = ImageTk.PhotoImage(Image.open(IMAGE_PATH).resize((WIDTH, HEIGTH), Image.ANTIALIAS))
canvas.background = img  # Keep a reference in case this code is put in a function.
bg = canvas.create_image(0, 0, anchor=tk.NW, image=img)

# Put a tkinter widget on the canvas.
button = tk.Button(root, text="Start")
button_window = canvas.create_window(10, 10, anchor=tk.NW, window=button)

root.mainloop()
Posted by: Guest on October-02-2020

Code answers related to "how to set background image in tkinter frame"

Python Answers by Framework

Browse Popular Code Answers by Language