diff --git a/background.jpg b/background.jpg new file mode 100644 index 0000000..22f9e1d Binary files /dev/null and b/background.jpg differ diff --git a/journal.py b/journal.py index c0ed4e7..17f73d1 100755 --- a/journal.py +++ b/journal.py @@ -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() @@ -88,4 +100,4 @@ button_quit = ttk.Button( ) button_quit.pack() -journal.mainloop() \ No newline at end of file +journal.mainloop()