2

I have started with GUI and have a question. I've already created a window and now I want to set an image as background.
I saw that it was used with canvas, but I did not understand how to use it. Can someone help me / Best regards

import tkinter as tk
from tkinter import ttk 
from PIL import Image, ImageTk

TITLE = ('Arial', 22, 'bold italic underline')

class LoLApp(tk.Tk):

    def __init__(self, *args, **kwargs ):

        tk.Tk.__init__(self, *args, **kwargs )
        tk.Tk.wm_title(self, 'Test')
        tk.Tk.geometry(self, '800x400')

        container = tk.Frame(self)
        container.pack(side='top', fill='both', expand = True)
        container.grid_rowconfigure(0, weight=1)
        container.grid_columnconfigure(0, weight=1)

        self.frames={}
        frame = StartPage(container, self)        
        self.frames[StartPage]=frame
        frame.grid(row=0, column=0, sticky='nsew')
        self.show_frame(StartPage)

    def show_frame(self, cont):

        frame = self.frames[cont]
        frame.tkraise()

class StartPage(tk.Frame):

     def __init__(self, parent, controller):
         tk.Frame.__init__(self, parent)
         label = tk.Label(self, text='Welcome to the First Page', font = TITLE )
         label.pack()

app = LoLApp()
app.mainloop()
yil98
  • 33
  • 1
  • 8

0 Answers0