0
在FXRuby;打开时如何将FXFileDialog
设置为主目录?FXRuby FXFileDialog框默认目录
在FXRuby;打开时如何将FXFileDialog
设置为主目录?FXRuby FXFileDialog框默认目录
这里是一个非常懒惰的方式做到这一点:
#!/usr/bin/ruby
require 'rubygems'
require 'fox16'
include Fox
theApp = FXApp.new
theMainWindow = FXMainWindow.new(theApp, "Hello")
theButton = FXButton.new(theMainWindow, "Hello, World!")
theButton.tipText = "Push Me!"
iconFile = File.open("icon.jpg", "rb")
theButton.icon = FXJPGIcon.new(theApp, iconFile.read)
theButton.iconPosition = ICON_ABOVE_TEXT
iconFile.close
theButton.connect(SEL_COMMAND) {
fileToOpen = FXFileDialog.getOpenFilename(theMainWindow, "window name goes here", `echo $HOME`.chomp + "/")
}
FXToolTip.new(theApp)
theApp.create
theMainWindow.show
theApp.run
这依赖于你是在* nix框(或具有$ HOME环境变量设置)。那具体回答你的问题的范围有:
theButton.connect(SEL_COMMAND) {
fileToOpen = FXFileDialog.getOpenFilename(theMainWindow, "window name goes here", `echo $HOME`.chomp + "/")
}
在这里,第一个参数是拥有对话框的窗口,第二个是窗口的标题,第三个是开始在默认路径(你最后需要“/”,否则它会在用户的主文件夹被选中时启动一个更高的目录)。查看this link了解关于FXFileDialog的更多信息。