I have the following code where I try to allow the user to open a text file, and as soon as the user selects it, I would like the code to read it (this is not a ready-made block of code, just to show what I need).
However, I am having difficulty either using tkFileDialog.askopenfilename, either adding 'mode =' rb '' or using the code as shown below, and using reading, where it creates an error.
Does anyone know how I can do this since I do not want to enter Tkinter.'module for every item, such as a menu and list. Beginner from Tkinter and a little embarrassed! Thanks for the help!
import sys from Tkinter import * import tkFileDialog from tkFileDialog import askopenfilename
Obviously the error I am getting here is:
AttributeError: 'unicode' object has no attribute 'read'
I do not understand how to use askopen, as well as being able to read the file that I open.
python tkinter
user2063
source share