Hi,
I was hoping to create an application where the user can open a file from their hard drive (using the askopenfile dialogue from tkFileDialog) and it would display information such as file name / size.

I managed to get everything working correctly except for displaying the information. I tried to copy it to a temporary file and then read the size of the temporary file but this caused "TypeError: must be string or buffer, not file" for which I converted it into a string but it still returns the incorrect value (I am testing it on a file of my own that I know the size of). I am using the os module to display the size of the temporary file after it has had the contents from the askopenfile variable copied into it.

I basically want to know the size of the file using the os.path.getsize function but on the file that is already open

It has been wracking my brain and I am completely perplexed by this.

I think there is a method askopenfilname() which returns only a file name instead of an open file. Otherwise, file objects have an attribute 'name' which you could use.

You can use os.path.getsize on the file if it is open. But you have to use it on the filename not the file object.

f=open("vmi","w")
f.write("asdf")
import os
os.path.getsize("vmi")
#0 byte
f.close()
os.path.getsize("vmi")
# 4 bytes