I have a database program which I have written a printable invoice using a txt file. I want this file to be displayed as a preview before my user has the option to print.
When entering the ClientNo
I want to print an invoice for, the code and text file is successfully updated however the current display does not update unless I close and reopen my program.
Is there a method that refreshes my display automatically after a new client has been entered so that I do not have to close and re-open my program? Here is a picture of my Tkinter frame and pressing Okay
updates the Display below.
Picture of my Tkinter PrintFrame
Here is a section of my code below (I know a lot of it is probably wrong, but I am a learning A-Level student so please forgive me):
def PrintInvoiceWidget(self):
print("Hello")
TitleLabel = Label(self.PrintFrame,text = "Create Invoice", width = 120, font = (30), bg="gainsboro")
MenuButton = Buttons(self.PrintFrame, text= "Menu", command = lambda: self.SwitchFrames(self.PrintFrame,self.MenuFrame))
ClientNoEntry = Entry(self.PrintFrame)
AcceptButton= Buttons(self.PrintFrame, text= "Okay",command = lambda: self.Print(ClientNoEntry))
File = Text(self.PrintFrame,width=70, height= 25)
Label(self.PrintFrame,text = "Create Invoice", width = 120, font = (30), bg="gainsboro")
with open("INVOICE2.txt", 'r') as f:
File.insert(INSERT, f.read())
f.close()
TitleLabel.grid(row=0,column=0)
MenuButton.grid(row=1,column=0,sticky= N,pady = 20)
ClientNoEntry.grid(row=2,column=0,pady=50)
AcceptButton.grid(row=3,column=0,sticky=S,pady=50)
File.grid(row=4,column=0)
If any further code is needed, I will edit and update my question with necessary infomation or ask a more precise question. Thank you :D