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 |
14
journal.py
14
journal.py
|
|
@ -5,6 +5,7 @@ import tkinter as tk
|
||||||
from tkinter import ttk, StringVar
|
from tkinter import ttk, StringVar
|
||||||
from tkinter.messagebox import showinfo
|
from tkinter.messagebox import showinfo
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
from PIL import Image, ImageTk
|
||||||
|
|
||||||
now = datetime.now()
|
now = datetime.now()
|
||||||
YEAR = now.strftime("%Y")
|
YEAR = now.strftime("%Y")
|
||||||
|
|
@ -28,12 +29,23 @@ else:
|
||||||
|
|
||||||
# configure root window
|
# configure root window
|
||||||
journal = tk.Tk()
|
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()
|
width = journal.winfo_screenwidth()
|
||||||
height = journal.winfo_screenheight()
|
height = journal.winfo_screenheight()
|
||||||
journal.geometry("%dx%d" % (width, height))
|
journal.geometry("%dx%d" % (width, height))
|
||||||
journal.title("Ameland Kinderjournal")
|
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
|
# store name and message
|
||||||
name = tk.StringVar()
|
name = tk.StringVar()
|
||||||
message = tk.StringVar()
|
message = tk.StringVar()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user