I am trying to display text on top of an image. Right now the text is below the image or if I put a row=0 in the grid disappears. I am assuming it is behind the image. I can't seem to get it to work. My code is:
from Tkinter import *
from PIL import ImageTk
import csv
import time
root = Tk()
image = ImageTk.PhotoImage(file='C:\Users\Shawn\PycharmProjects\Test\Background.gif')
var0 = StringVar()
var1 = StringVar()
var2 = StringVar()
var3 = StringVar()
label0 = Label(root, fg="white", textvariable=var0)
label1 = Label(root, fg="white", textvariable=var1)
label2 = Label(root, fg="white", textvariable=var2)
label3 = Label(root, fg="white", textvariable=var3)
# ----------------------------------------------------------------------
def csv_dict_reader(file_obj):
reader = csv.DictReader(file_obj, delimiter=',')
for column in reader:
if (column["Week"]) == (time.strftime("%U")):
var0.set(column["Parashat"])
var1.set(column["Torah"])
var2.set(column["Haftarah"])
var3.set(column["Gospel"])
# ----------------------------------------------------------------------
if __name__ == "__main__":
with open("Torah.csv") as f_obj:
csv_dict_reader(f_obj)
Label(root, image=image).grid(row=0, column=0)
label0.grid()
label1.grid()
label2.grid()
label3.grid()
mainloop()
I have tried putting the row and column in the label0.grid(row=1, column=1), along with all labels and all row and column numbers.
The outcome I want is label0 - label3 to be centered on top of the image. The image is black and dark blue so the white text will show well. Thank you.
Shawn