python对话框_Tkinter 对话框

原生 加载/保存 对话框.¶

The following classes and functions provide file dialog windows that combine a

native look-and-feel with configuration options to customize behaviour.

The following keyword arguments are applicable to the classes and functions

listed below:

parent - the window to place the dialog on top of

title - the title of the window

initialdir - the directory that the dialog starts in

initialfile - the file selected upon opening of the dialog

filetypes - a sequence of (label, pattern) tuples, '*' wildcard is allowed

defaultextension - default extension to append to file (save dialogs)

multiple - when true, selection of multiple items is allowed

Static factory functions

The below functions when called create a modal, native look-and-feel dialog,

wait for the user's selection, then return the selected value(s) or None to the

caller.

tkinter.filedialog.askopenfile(mode="r", **options)¶

tkinter.filedialog.askopenfiles(mode="r", **options)¶

The above two functions create an Open dialog and return the opened

file object(s) in read-only mode.

tkinter.filedialog.asksaveasfile(mode="w", **options)¶

Create a SaveAs dialog and return a file object opened in write-only mode.

tkinter.filedialog.askopenfilename(**options)¶

tkinter.filedialog.askopenfilenames(**options)¶

The above two functions create an Open dialog and return the

selected filename(s) that correspond to existing file(s).

tkinter.filedialog.asksaveasfilename(**options)¶

Create a SaveAs dialog and return the selected filename.

tkinter.filedialog.askdirectory(**options)¶

提示用户选择一个目录.

Additional keyword option:

mustexist - determines if selection must be an existing directory.

classtkinter.filedialog.Open(master=None, **options)¶

classtkinter.filedialog.SaveAs(master=None, **options)¶

The above two classes provide native dialog windows for saving and loading

files.

Convenience classes

The below classes are used for creating file/directory windows from scratch.

These do not emulate the native look-and-feel of the platform.

classtkinter.filedialog.Directory(master=None, **options)¶

Create a dialog prompting the user to select a directory.

注解

The FileDialog class should be subclassed for custom event

handling and behaviour.

classtkinter.filedialog.FileDialog(master, title=None)¶

Create a basic file selection dialog.

cancel_command(event=None)¶

Trigger the termination of the dialog window.

dirs_double_event(event)¶

Event handler for double-click event on directory.

dirs_select_event(event)¶

Event handler for click event on directory.

files_double_event(event)¶

Event handler for double-click event on file.

files_select_event(event)¶

Event handler for single-click event on file.

filter_command(event=None)¶

以目录过滤文件.

get_filter()¶

获取当前使用的文件过滤器.

get_selection()¶

获取当前选择的项目.

go(dir_or_file=os.curdir, pattern="*", default="", key=None)¶

渲染对话和启动事件循环,

ok_event(event)¶

退出对话回到当前选择.

quit(how=None)¶

退出对话回到文件名, 如果有的话.

set_filter(dir, pat)¶

设置文件过滤器.

set_selection(file)¶

Update the current file selection to file.

classtkinter.filedialog.LoadFileDialog(master, title=None)¶

A subclass of FileDialog that creates a dialog window for selecting an

existing file.

ok_command()¶

Test that a file is provided and that the selection indicates an

already existing file.

classtkinter.filedialog.SaveFileDialog(master, title=None)¶

A subclass of FileDialog that creates a dialog window for selecting a

destination file.

ok_command()¶

Test whether or not the selection points to a valid file that is not a

directory. Confirmation is required if an already existing file is

selected.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值