- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
当我在 bash 终端(Ubuntu 14.04、ruby 1.9.3)中运行以下 ruby 代码时,folder_test 工作正常,但 my_test 表现出奇怪的行为:当我从中选择一个文件夹时,它不会关闭 gtk 对话框窗口书签并且焦点保留在对话窗口上而不是返回到终端尽管已将所选文件夹正确报告给终端。出了什么问题以及如何强制关闭对话窗口?
# -*- encoding : utf-8 -*-
#!/usr/bin/ruby
require 'gtk3'
def get_folder(folder)
a=''
Dir.chdir(File.expand_path(folder)) {
dialog = Gtk::FileChooserDialog.new(
:title => "Choose folder", :parent => nil,
:action => :select_folder,
:buttons => [[Gtk::Stock::OPEN, Gtk::ResponseType::ACCEPT], [Gtk::Stock::CANCEL, Gtk::ResponseType::CANCEL]])
if dialog.run == Gtk::ResponseType::ACCEPT
a=dialog.filename
end
dialog.destroy }
return a
end
def folder_test
b=get_folder("/home")
if b=="/home"
puts "No folder chosen"
exit
end
puts "#{b} was choosen."
end
def my_test
while true do
folder_test
puts "Another folder?(y/n)"
answer=gets.chomp.downcase
unless answer=='y'
exit
end
end
end
#folder_test
my_test
最佳答案
你可以在dialog.destroy
之后使用下面的代码:
while Gtk.events_pending?
Gtk.main_iteration
end
例如:
if dialog.run == Gtk::ResponseType::ACCEPT
a=dialog.filename
end
dialog.destroy
while Gtk.events_pending?
Gtk.main_iteration
end
}
return a
end
差异:
@@ -13,7 +13,11 @@ def get_folder(folder)
if dialog.run == Gtk::ResponseType::ACCEPT
a=dialog.filename
end
- dialog.destroy }
+ dialog.destroy
+ while Gtk.events_pending?
+ Gtk.main_iteration
+ end
+ }
return a
end
关于ruby - Ruby 中的 GTK FileChooserDialog 不会关闭窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33438137/
当我尝试显示文件选择器对话框时,它缺少操作按钮: let dialog = FileChooserDialog::new(Some("Open File"), Some(&window), FileC
有什么方法可以让 FileChooserDialog 同时选择文件和文件夹吗? 我知道有 FileChooserAction OPEN 和 SELECT_FOLDER 但它们是排他性的。 PD:我不想
我正在使用 OpenGL GUI 编写应用程序。在 Windows 上,我使用 GetOpenFilename 允许用户选择文件。 我尝试使用 Gtk::FileChooserDialog(在 thi
我第一次尝试在 Python 中制作 GUI,我选择通过 PyGObject 使用 gtk3+。 我在 Ubuntu 18.04 中工作,我习惯于使用 Anaconda 开发一切。 我只是按照 htt
我有一个 python 脚本,使用 FileChooserDialog 从用户那里请求一个文件。完成后,它会在对话框中调用 .destroy() ,但之后会立即开始加载文件。由于它通常是一个大文件,因
我现在有一个很奇怪的问题,我希望你能重现它。请尝试以下 Python 代码: import gtk print '=== 1 ===' def _createFileDialog(): dia
我在 WeatherController.cs 中使用 StreamReader 从 CSV 文件中读取数据。在我的 MainWindow 中,我使用 FileChooseDialog 来查找要读取的
是否可以将 gtk.FileChooserDialog/gtk.FileChooserButton 设置为仅允许用户选择文件夹/目录? 也许我添加一个目录过滤器来实现这个?我怎样才能让用户只能选择一个
我有一个 pygtk 程序,可以在 Windows 和 Ubuntu 上运行。它是带有静态绑定(bind)的 Python 2.7 和 gtk2(即没有 gobject 自省(introspectio
当我在 bash 终端(Ubuntu 14.04、ruby 1.9.3)中运行以下 ruby 代码时,folder_test 工作正常,但 my_test 表现出奇怪的行为:当我从中选择一个文件夹
对于包含许多文件的 nfs 目录,打开 gtk FileChooserDialog 非常慢。 strace 显示很多时间调用“stat”。目录中的每个文件大约调用 5 次。我们如何才能关闭对“stat
我设置了一个程序,它可以单独显示一个 FileChooserDialog(没有主 Gtk 窗口,只有对话框)。 我遇到的问题是对话框没有消失,即使在用户选择了文件并且程序似乎继续执行之后也是如此。 这
我有一些代码使用 Python 3.4 中的 Gtk+ FileChooserDialog 来允许用户选择文件。 然后,它应该关闭对话框(很明显)并继续执行用户选择文件后的代码。然而,发生的情况是用户
希望处理用户可能尚未打开的图像文件。尽管我似乎只能在图像已打开的情况下启用该插件。在打开图像之前,Gimp 2.8 附带的所有 Python 插件都会被禁用。搜索了许多示例,似乎找到的每个示例都需要在
我是使用 Gtk 进行 UI 开发的新手,遇到了一些我没想到的事情。 FileChooser 自动按名称排序,无论它是文件还是目录。我喜欢首先列出目录,人们习惯于/期待它。 有什么方法可以让 File
我是一名优秀的程序员,十分优秀!