如何创建一个 FileDialog 以显示在 window 的框架中,而不是将 FileDialog 弹出 window?
How to create a FileDialog to appear in a frame of a window instead of the FileDialog being a popout window?
如何嵌入应用程序打开时出现在左侧框架中的 FileDialog,而不是单击按钮 "browse" 并使 FileDialog 弹出 window?
我使用 Python 创建了一个 GUI,在 window 我的左边有一个框架,右边有一个列表框。
def browseButtonClicked():
browsePath = filedialog.askopenfilename()
.
.
.
# GUI setup
root = Tk()
mainframe = ttk.Frame(root)
browseFrame = ttk.Frame(mainframe)
sfPathLB = Listbox(browseFrame, height=12, width=40, selectmode=MULTIPLE)
browseButton = ttk.Button(mainframe, text="Browse",
command=browseButtonClicked)
browseFrame.grid(column=1, row=2, rowspan=3, padx=3, sticky=(W+E+N+S))
sfPathLB.grid(column=3, row=2, rowspan=3, padx= 3, sticky=(W+E+N+S))
当我在框架内添加文件对话框时:
frame.browseFrame = filedialog.askopenfilename()
我执行程序时文件对话框打开,但它占据了整个window而不是只出现在框架中。
How to create a FileDialog to appear in a frame of a window instead of the FileDialog being a popout window?
你不能。对话框由 OS 控制。你不能嵌入它们。
如何嵌入应用程序打开时出现在左侧框架中的 FileDialog,而不是单击按钮 "browse" 并使 FileDialog 弹出 window?
我使用 Python 创建了一个 GUI,在 window 我的左边有一个框架,右边有一个列表框。
def browseButtonClicked():
browsePath = filedialog.askopenfilename()
.
.
.
# GUI setup
root = Tk()
mainframe = ttk.Frame(root)
browseFrame = ttk.Frame(mainframe)
sfPathLB = Listbox(browseFrame, height=12, width=40, selectmode=MULTIPLE)
browseButton = ttk.Button(mainframe, text="Browse",
command=browseButtonClicked)
browseFrame.grid(column=1, row=2, rowspan=3, padx=3, sticky=(W+E+N+S))
sfPathLB.grid(column=3, row=2, rowspan=3, padx= 3, sticky=(W+E+N+S))
当我在框架内添加文件对话框时:
frame.browseFrame = filedialog.askopenfilename()
我执行程序时文件对话框打开,但它占据了整个window而不是只出现在框架中。
How to create a FileDialog to appear in a frame of a window instead of the FileDialog being a popout window?
你不能。对话框由 OS 控制。你不能嵌入它们。