[fxruby-users] Directory listing query
Stuart Clarke
stuart_clarke86 at yahoo.com
Wed Dec 17 16:51:52 EST 2008
Hi,
I am trying to write a small GUI to glue onto the front of some other code. The purpose of the GUI is to allow the user to select a text file full of word lists, then to select a directory for the data to be output to and finally for the user to enter a name for the job in a text field. Thus far I have created the directory dialogs and relevant text fields, however I would like some assistance with the remainder. Firstly when a user selects a file (word list file) I would like the full path and file name to be displayed in a text box (I would like the same for the directory selection also). How would I go about this? This is my most of my code this far which shows my ideas but this is not working:
Thanks in advance.
require 'fox16'
include Fox
class GUI < FXMainWindow #SUBCLASS FOR CREATING A WINDOW, CONTAINS ALL THE CUSTOMISATION INFORMATION
def initialize(app)
super(app, "GUI", :width => 300, :height => 250)
frame = FXVerticalFrame.new(self, LAYOUT_FILL_X)
inputFile = FXButton.new(frame, "Input Phrase File")
inputFile.connect(SEL_COMMAND) do
dialog = FXFileDialog.new(self, "Select input file")
dialog.patternList = ["Text Files (*.txt)", "All Files (*)"]
dialog.selectMode = SELECTFILE_EXISTING
if dialog.execute != 0 #display the box and wait fot user response
loadinput(dialog.filename) #if the user selects a file it calls the openevtfile method
end
end
@inputfield = FXTextField.new(frame, 30, :opts => FRAME_SUNKEN|FRAME_THICK|LAYOUT_FILL_X)
FXHorizontalSeparator.new(frame, :opts => LAYOUT_FILL_X|SEPARATOR_GROOVE)
FXLabel.new(frame, "Classifcation name:", :opts => JUSTIFY_LEFT)
tagfield = FXTextField.new(frame, 30, :opts => FRAME_SUNKEN|FRAME_THICK|LAYOUT_FILL_X)
FXButton.new(frame, "Run")
FXButton.new(frame, "Cancel", nil, getApp(), FXApp::ID_QUIT)
end
def loadinput(filename)
inputfile = []
inputfile.push "(#{filename})"
@inputfield = inputfile.join("\n")
end
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/fxruby-users/attachments/20081217/123215f4/attachment.html>
More information about the fxruby-users
mailing list