I have a pandas database with slides and text named "df_slides". I would like to make a tkinter GUI to click through the slides and display the text, like that:
This is what I have implemented so far:
import tkinter
from PIL import Image, ImageTk
import base64
import pandas as pd
i = 0
def load_next_img():
global pil_image, tk_image, i, text
i = i+1
base64string = df_slides["Slide_Image"][i]
imgdata = base64.b64decode(base64string)
pil_image = Image.open(io.BytesIO(imgdata))
tk_image = ImageTk.PhotoImage(pil_image)
label['image'] = tk_image
text = df_slides["Text"][i]
def load_previous_img():
global pil_image, tk_image, i, text
i = i-1
base64string = df_slides["Slide_Image"][i]
imgdata = base64.b64decode(base64string)
pil_image = Image.open(io.BytesIO(imgdata))
tk_image = ImageTk.PhotoImage(pil_image)
label['image'] = tk_image
text = df_slides["Text"][i]
root = tkinter.Tk()
label = tkinter.Label(root)
label.pack(side = "bottom", fill = "both", expand = "yes")
load_next_img()
nextbutton = tkinter.Button(text="next", command=load_next_img)
nextbutton.pack()
backbutton = tkinter.Button(text="back", command=load_previous_img)
backbutton.pack()
T = tkinter.Text(root, height=10, width=30)
T.pack()
T.insert(tkinter.END, text)
root.mainloop()
This is the current result:
As you can see the text does not use the full width and more importantly it does not update together with the slide when I press "next" and "back". The slide updates but the text stays the same all the time.

