2008-09-03 7 views

答えて

1

はここでそれを行うには非常に怠惰な方法です:

#!/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 + "/") 
} 

は、最初の引数は、ダイアログボックスを所有するウィンドウで、3番目はで起動するデフォルトのパスです(最後に "/"が必要な場合は、ユーザーのホームフォルダが選択された状態でディレクトリが上がります)。 FXFileDialogの詳細については、 this linkをご覧ください。