2 years ago

#41406

test-img

pypy

I want to search for file and assign content to a variable with the libary of tkinter

I want to use tkinter for a simple file search and assign the content to a matrix y for example because the file has numbers in it which I need. I browsed a little bit and found this code.

import tkinter as tk
from tkinter import filedialog as fd 

def callback():
    name= fd.askopenfilename() 
    print(name)
    
errmsg = 'Error!'
tk.Button(text='Click to Open File', 
       command=callback).pack(fill=tk.X)
tk.mainloop()

I could search for the file but didnt give me the expected output. It just gave me the path of the file which I dont need. I tried something with read() but it did not work.

Does somebody has a simple code for searching a file and assign the content or any tipps? I appreciate every answer :)

python

file

tkinter

search

assign

0 Answers

Your Answer

Accepted video resources