add background and draw it
This commit is contained in:
parent
1697fa5bea
commit
19a0e6000d
BIN
background.jpg
Normal file
BIN
background.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 6.7 MiB |
16
journal.py
16
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()
|
||||
journal.mainloop()
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user