I am creating a tkinter window. The 'event frame' must originally display a general message, but after a venue is picked (via radio button) and the 'show event' button is clicked, this text must be changed. Currently, my window is displaying the original message, but is not updating. The variable 'message' that I am using to hold the text to be displayed updates successfully (as checked through a print function in the shell window), so I am unsure as to where the issue is, and how to update the text widget.
the relevant code is as follows:
(I have included the entire 'function' for clarity, although only the final elif is relevant to this issue... the venue radio buttons are functional, thus they are not included below as the issue does not reside with the correct elif running, but rather the tkinter code)
# define function for functionality
def function():
global venue
global option
# open url for 'display details'
if venue == 'zoo' and option == 'details':
urldisplay(url1)
option = ''
elif venue == 'qpac' and option == 'details':
urldisplay(url2)
option = ''
elif venue == 'comic' and option == 'details':
urldisplay(url3)
option = ''
elif venue == 'zoo' and option == 'event':
global message
message = 'event: ' + zoo_title_details[0] + '\n' + 'date: ' + zoo_date_details[2]
print(message)
event_text.insert('end', message)
else:
print('fail')
# define functions to define option choice
def event():
global option
option = 'event'
function()
# create options frame
options_frame = LabelFrame(window, relief = 'groove', font = window_font,
bg = window_colour, fg = header_colour,
borderwidth = 4, text = 'Options')
# create buttons within the options frame
show_event = Button(options_frame, text = 'Show event', font = window_font,
bg = window_colour, fg = text_colour, command = event)
display_details = Button(options_frame, text = 'Display details', font = window_font,
bg = window_colour, fg = text_colour, command = details)
print_ticket = Button(options_frame, text = 'Print ticket', font = window_font,
bg = window_colour, fg = text_colour)
save_booking = Button(options_frame, text = 'Save booking', font = window_font,
bg = window_colour, fg = text_colour, state = 'disabled')
# create event frame
event_frame = LabelFrame(window, relief = 'groove', font = window_font,
bg = window_colour, fg = header_colour,
borderwidth = 8, text = 'Chosen event')
# create the text box within the event frame
global message
message = '''
event name will appear here
event date(s) will appear here
.
.
.
'''
event_text = Text(event_frame, font = window_font,
bg = window_colour, fg = text_colour,
height = 5, width = 30)
event_text.insert('end', message)
event_text.config(state = 'disabled')
show_event.grid(row = 1, sticky = 'w')
event_text.grid(row = 1, sticky = 'w')
event_frame.grid(row = 2, column = 2, columnspan = 2)
window.mainloop()
when the 'zoo' venue and 'event details' button is clicked, the shell prints the correct message (indicating that the variable has updated successfully) but no changes occur to the shell (and no error messages appear).
the window appears as follows
Thank you :)
