Reputation: 1
I am trying to access the file name that is gathered from one of my python scripts in and use it in a different script, I will show my code below. Currently I tried returning the filename value, however I believe I am getting whats called the object or memory value instead of the file name. Any help or tips to getting this figured out?
The function with the value I want
def selected_file(event, listbox, menu):
item = listbox.curselection()
if item:
filename = listbox.get(item[0])
popup_menu(event, menu, listbox)
print(f"{filename} selected")
return filename
The function I want to retrieve the value with
def folders_setup(self):
filename = functions.selected_file
print(f"for {filename}")
labelsFrame = Frame(self.folders_frame)
labelsFrame.pack(side=TOP, pady=8, fill=X)
Label(labelsFrame, text="Folders")
What shows when I run my code
for <function selected_file at 0x10880f9c0>
craftpix-net-622999-free-pixel-art-tiny-hero-sprites selected
Anything helps thanks!
Btw the "craftpix-net-622999-free-pixel-art-tiny-hero-sprites selected" is what I want the "0x10880f9c0" to print.
Upvotes: 0
Views: 62
Reputation: 15728
You're not actually calling the function, to call it you have to add the brackets ()
and pass your arguments:
def folders_setup(self):
filename = functions.selected_file(YOUR_ARGUMENTS_HERE)
print(f"for {filename}")
labelsFrame = Frame(self.folders_frame)
labelsFrame.pack(side=TOP, pady=8, fill=X)
Label(labelsFrame, text="Folders")
Upvotes: 0