I am using Python 3.2 for Windows with Tkinter 8.5. Does anyone knows if it is possible to open text file by selecting an item on a listbox and display the text file contents on a text widget? Here is my code:
def starters_menu():
self.listBox.delete(0, END)
starters_menu = open("starters_menu.txt")
for line in starters_menu:
line = line.rstrip()
self.listBox.insert(END, line)
self.listBox.bind("<ButtonRelease-1>", recipe_title, add="+")
self.listBox.bind("<ButtonRelease-1>", recipe_ingredients, add="+")
recipe_menu.add_command(label="Starters, Snacks and Savouries", command=starters_menu)
I need help to write the definition for "recipe_ingredients" so that when the item in the list is selected, a text file linked to the item is opened and its contents displayed in text widget. I need to know how how to link a file to the listbox item and how to call it using the handler shown in the code above.