F
F
FOUREX2021-09-18 17:07:40
Python
FOUREX, 2021-09-18 17:07:40

How to put an image in the background of tkinter?

I have a window and I want to make a background for it.
I tried to do it, tried different ways, but it didn't work.

Here is the code:

import os
from tkinter import *
from tkinter import ttk


def start():
    app = App()
    app.mainloop()


class App(Frame):
    def __init__(self, master = None):
        super().__init__(master)
        self.master.geometry('640x360')
        self.master.title("Bot")
        self.bg()
        self.pack()

    def bg(self):
        bgImg = PhotoImage(file = "bg.png")
        self.bg = ttk.Label(self)
        self.bg["text"] = "Yep"
        self.bg["image"] = bgImg
        self.bg.pack()


start()

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question