I cannot find a way to access this textbox and append to it from another class using Tkinter.
I can't use the method I've used before (by calling other entries StringVar()
), which has lead to a halt in my programming. As textbox cannot be named a StringVar()
, I am confused as to how I could go about doing this.
import tkinter as tk
class MainWindow(tk.Tk):
def __init__(self, *args, **kwargs):
tk.Tk.__init__(self, *args, **kwargs)
self.geometry("1350x750")
container = tk.Frame(self)
container.grid(row=0, column=0)
container.config(bg="gray20")
self.frames = {}
for F in (ReservationPage, ReceiptPage):
frame = F(container, self)
self.frames[F] = frame
frame.grid(row=0, column=0)
self.show_frame(ReservationPage)
def show_frame(self, cont):
frame = self.frames[cont]
frame.tkraise()
class ReservationPage(tk.Frame):
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent)
self.controller = controller
self.MainFrame = tk.Frame(self, width=1350, height=700, bg="gray20")
self.MainFrame.grid(row=0,column=0)
self.MoorFrame = tk.LabelFrame(self, bg="gray20", width=300, height=150)
self.MoorFrame.place(x=450, y=120)
ReceiptPageButton1 = tk.Button(self, text="Receipts", font=("Helvetica", 20, "bold"),bg="gray20", fg="light grey",
bd=0,command=lambda: controller.show_frame(ReceiptPage))
ReceiptPageButton1.place(x=100, y=30)
class ReceiptPage(tk.Frame):
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent)
self.controller = controller
self.MainFrame = tk.Frame(self, width=1350, height=700, bg="gray20")
self.MainFrame.grid(row=0,column=0)
ReservationPageButton1 = tk.Button(self, text="Reservations", font=("Helvetica", 20, "bold"),bg="gray20", fg="light grey",
bd=0,command=lambda: controller.show_frame(ReservationPage))
ReservationPageButton1.place(x=80, y=30)
ReceiptBox = tk.Text(self, height=20, width=137, font=("Helvetica",11,"bold"))
ReceiptBox.place(x=27, y=165)