add background and draw it

This commit is contained in:
julian 2024-03-23 14:08:14 +01:00
parent 1697fa5bea
commit 19a0e6000d
2 changed files with 14 additions and 2 deletions

BIN
background.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 MiB

View File

@ -5,6 +5,7 @@ import tkinter as tk
from tkinter import ttk, StringVar
from tkinter.messagebox import showinfo
from datetime import datetime
from PIL import Image, ImageTk
now = datetime.now()
YEAR = now.strftime("%Y")
@ -28,12 +29,23 @@ else:
# configure root window
journal = tk.Tk()
# set Window to fullscreen (dependend of the actual screensize)
# label = tk.Label(journal, image=image)
# label.place(x=0, y=0)
# set window to fullscreen (dependend of the actual screensize) and fill with a background image
image_location = 'background.jpg'
width = journal.winfo_screenwidth()
height = journal.winfo_screenheight()
journal.geometry("%dx%d" % (width, height))
journal.title("Ameland Kinderjournal")
img = ImageTk.PhotoImage(Image.open(image_location).resize((width, height), Image.ADAPTIVE))
label = tk.Label(journal, image=img)
# Keep a reference in case this code put is in a function.
label.img = img
# Place label in center of parent.
label.place(relx=0.5, rely=0.5, anchor='center')
# store name and message
name = tk.StringVar()
message = tk.StringVar()