python - GtkFileChooserButon 在选择文件之前重置为初始状态

标签 python gtk

如何将 GtkFileChooserButton 重置为其初始状态,即在选择文件之前?

代码:

#!/usr/bin/env python3

import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk

def file_changed(filechooserbutton):
    print("File selected: %s" % filechooserbutton.get_filename())

window = Gtk.Window()
window.set_title("FileChooserButton")
window.set_default_size(150, -1)
window.connect("destroy", Gtk.main_quit)

filechooserbutton = Gtk.FileChooserButton(title="FileChooserButton")
filechooserbutton.connect("file-set", file_changed)
window.add(filechooserbutton)

window.show_all()

Gtk.main()

选择文件之前:

enter image description here

选择文件后:

enter image description here

最佳答案

GtkFileChooserButton 实现了 GtkFileChooser,因此您可以使用 unselect_all功能。

关于python - GtkFileChooserButon 在选择文件之前重置为初始状态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39518302/

相关文章:

Python3、Gtk3 - GtkGrid 扩展

gtk - 从 Windows 在 Linux 计算机上运行 GTK+ 应用程序

c - 如何在 Make 中使用 pkg-config

python - 为什么我的代码不能正确拆分扫描的 pdf 中的每一页?

python - 嵌入式 python 无法在 Windows 笔记本电脑上运行

python - 嵌套字典到数据框,将字典键保留为列而不是索引

python - 区分文档的图像和另一个图像

c# - C 代码模拟器的 GUI 和后端选择

python - 如何检索 Zope 文件系统的内容?

c - Gtk 与 Eclipse CDT