October 3rd, 2004, 07:03 PM
Updating contents of file
I have the collowing code for a GUI function:
I redirected the stdout stream to the calcs.log file. When a user clicks certain buttons, it prints it into the file via the output stream. However, the only way to get an updated history is to restart the program. How can I reload the file and update the listbox when a user clicks the View History button? Thanks.
newWin = Toplevel()
scrollbar = Scrollbar(newWin, orient=VERTICAL)
list = Listbox(newWin, yscrollcommand=scrollbar.set, width=45)
log = file('calcs.log','r')
rLog = log.readlines()
for line in rLog:
line = line.strip('\n')
QB = Button(newWin, text='Close', command=newWin.destroy)
October 4th, 2004, 04:40 AM
Basically you need a seperate update method for your list as strings are written to the file.
Last edited by Grim Archon; October 4th, 2004 at 04:48 AM.