我目前正在使用Tkinter将我的编码和解码文件“抛光”到DNA项目中。坦率地说,我从未使用过GUI。如果这里有人可以帮助我,将不胜感激!谢谢!我不确定是否必须将文件上传到GUI或否。
答案 0 :(得分:0)
使用filedialog
中的tkinter
,演示:
import tkinter as tk
from tkinter import filedialog
def UploadAction(event=None):
filename = filedialog.askopenfilename()
print('Selected:', filename)
root = tk.Tk()
button = tk.Button(root, text='Open', command=UploadAction)
button.pack()
root.mainloop()
注意:还打印选定的文件。
答案 1 :(得分:0)
要打开文件,请尝试以下操作:
import tkinter as tk
from tkinter import filedialog
root = tk.Tk()
root.withdraw()
file_path = filedialog.askopenfilename()
#if you want additional options:
import tkinter.simpledialog
window = tk.Tk()
window.withdraw() #hides the window
file = tk.simpledialog.askstring("file", "Options Here")