[PYTHON] How to display in the entire window when setting the background image with tkinter

Introduction

When displaying a background image using tkinter When I displayed it using Canvas, a white frame was included as shown in the image on the left. I didn't like that, so I will describe how to display it in the entire window as shown in the image on the right. Lenna_all.png

environment

Windows10 64bit Python 3.6.9 tkinter 8.6

Overview

Use Label to display the image.

procedure

Image used (256x256) Lenna.png

When using Label(Displayed throughout)


import tkinter as tk

#Creating a window
root = tk.Tk()
root.title("Test")
root.geometry("256x256")

#Browse file
background = tk.PhotoImage(file="Lenna.png ")

#Creating a Label
bg = tk.Label(root, image=background)
bg.pack(fill="x")

#Window drawing
root.mainloop()

Summary

Because there was a white frame when displaying using Canvas It was to display using Label. If you know how to erase the Canvas frame or other efficient methods I would appreciate it if you could teach me.

Recommended Posts

How to display in the entire window when setting the background image with tkinter
How to use tkinter with python in pyenv
Convert the image in .zip to PDF with Python
Python OpenCV tried to display the image in text.
[Note] How to write QR code and description in the same image with python
Solution when the image cannot be displayed with tkinter [python]
How to deal with UnicodeDecodeError when executing google image download
How to display the regional mesh of the official statistics window (eStat) in a web browser
How to not escape Japanese when dealing with json in python
How to implement Java code in the background of RedHat (LinuxONE)
How to change the color of just the button pressed in Tkinter
How to display formulas in latex when using sympy (> = 1.4) in Google Colaboratory
I tried to process the image in "pencil style" with OpenCV
Two ways to display multiple graphs in one image with matplotlib
[Memo] How to use BeautifulSoup4 (3) Display the article headline with class_
How to display legend marks in one with Python 2D plot
How to display bytes in the same way in Java and Python
What to do when a part of the background image becomes transparent when the transparent image is combined with Pillow
[PostgreSQL] How to grant superuser authority when the user (role) with superuser authority is 0
How to suppress display error in matplotlib
[Python] How to specify the window display position and size of matplotlib
Behavior when returning in the with block
How to hide the command prompt when running python in visual studio 2015
How to crop the lower right part of the image with Python OpenCV
Image display taken with the built-in ISIGHT
How to get the date and time difference in seconds with python
Display Python 3 in the browser with MAMP
How to work with BigQuery in Python
[Image recognition] How to read the result of automatic annotation with VoTT
How to display multiplication table in python
How to display python Japanese with lolipop
[Python] How to set the (client) window size inside the browser with Selenium
How to adjust image contrast in Python
When using the zap library in your own Logger with Golang, how to put the hierarchy above Logger in Caller
How to display Hello world in python
[AWS] How to deal with WordPress "An error occurred when cropping an image."
How to pass the path to the library built with pyenv and virtualenv in PyCharm
How to get a list of files in the same directory with python
Mouse over Matplotlib to display the corresponding image
How to deal with memory leaks in matplotlib.pyplot
How to use the C library in Python
Log in to the remote server with SSH
How to deal with errors when hitting pip ②
[REAPER] How to play with Reascript in Python
How to specify the NIC to scan with amazon-dash
[Python] How to change the date format (display format)
How to use Python Image Library in python3 series
How to try the friends-of-friends algorithm with pyfof
How to deal with run-time errors in subprocess.call
How to deal with SessionNotCreatedException when using Selenium
Determine the numbers in the image taken with the webcam
Detect folders with the same image in ImageHash
How to get the files in the [Python] folder
How to display images continuously with matplotlib Note
How to display videos inline in Google Colab
How to Learn Kaldi with the JUST Corpus
I want to display the progress in Python!
Display the image after Data Augmentation with Pytorch
The background of the characters in the text image is overexposed to make it easier to read.
How to set a shared folder with the host OS in CentOS7 on VirtualBOX
How to display the modification date of a file in C language up to nanoseconds