WebExample #9. def save_as(self, event): """ It pops a asksaveasfilename window to save the contents of the text area. """ filename = asksaveasfilename() if not filename: return try: self.area.save_data_as(filename) except Exception: root.status.set_msg('It failed to save data.') else: root.status.set_msg('Data saved.') 1 Answer Sorted by: 18 askopenfilename () returns the path of the selected file or empty string if no file is selected: from tkinter import filedialog as fd filename = fd.askopenfilename () print (len (filename)) To open the file selected with askopenfilename, you can simply use normal Python constructs and functions, such as the open function:
Get OpenFileDialog filename path... - C# / C Sharp
WebJul 4, 2008 · After I select a file with the OpenFileDialog, I get the file name with .FileName, but I want to know the drive and path where that file is. What function, method, class can … WebMay 30, 2024 · python通过对话框实现文件或文件夹路径的选择并获得路径 import tkinter as tk from tkinter import filedialog '''打开选择文件夹对话框''' root = tk.Tk() root.withdraw() Filepath = filedialog.askopenfilename() #获得选择好的文件 这样代码就完成了 看看实际效果吧: 另外想要获取文件夹路径 ... lose weight with slow metabolism
Python Examples of tkinter.filedialog.askopenfilenames
Webdef select_preamble_file(self): file_name = TkFileDialogs.askopenfilename(initialdir=os.path.dirname(self._preamble.get()), … WebMar 31, 2024 · In order to use askopenfile () function you may require to follow these steps: -> import tkinter -> from tkinter.filedialog import askopenfile ## Now you can use this function -> file = askopenfile … WebFeb 19, 2024 · Try This: from tkinter import * from tkinter import filedialog root = Tk () def open (): filename = filedialog.askopenfilename (initialdir='D:\Music', title="Select … lose weight with swimming