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>
On Dec 17, 2008, at 3:51 PM, Stuart Clarke wrote:> 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?I don''t see in your program (or at least the part that you included in your e-mail) where you''ve attempted to do this, so it''s hard to guess what''s wrong. But since the FXFileDialog#filename returns the selected file''s name, it seems like you''d want to assign that to the appropriate text field, e.g. @inputfield.text = dialog.filename Hope this helps, Lyle -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/fxruby-users/attachments/20081218/eacb486d/attachment.html>
Apologies I was sending a chunk of the wrong coding. This is more useful I would imagine: ??? inputFile = FXButton.new(frame, "Input Phrase File") ??? inputFile.connect(SEL_COMMAND) do #the connect will ensure the following block is performed ????? 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 ??????? inputfield.text = dialog.filename ????? end ??? end ??? #create a text field to insert file path in ??? inputfield = FXTextField.new(frame, 30, :opts => FRAME_SUNKEN|FRAME_THICK|LAYOUT_FILL_X) This throws errors. Do I need a to_s? Thanks in advance! --- On Thu, 18/12/08, Lyle Johnson <lyle at lylejohnson.name> wrote: From: Lyle Johnson <lyle at lylejohnson.name> Subject: Re: [fxruby-users] Directory listing query To: fxruby-users at rubyforge.org Date: Thursday, 18 December, 2008, 3:50 PM On Dec 17, 2008, at 3:51 PM, Stuart Clarke wrote: 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? I don''t see in your program (or at least the part that you included in your e-mail) where you''ve attempted to do this, so it''s hard to guess what''s wrong. But since the FXFileDialog#filename returns the selected file''s name, it seems like you''d want to assign that to the appropriate text field, e.g. @inputfield.text = dialog.filename Hope this helps, Lyle_______________________________________________ fxruby-users mailing list fxruby-users at rubyforge.org http://rubyforge.org/mailman/listinfo/fxruby-users -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/fxruby-users/attachments/20081218/fb170d13/attachment.html>
On Dec 18, 2008, at 10:53 AM, Stuart Clarke wrote:> This throws errors. Do I need a to_s?That depends. What kind of error does it throw? -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/fxruby-users/attachments/20081218/1701028e/attachment.html>
to_s worked and its up and running. I do have one other question which is completely unrelated but again to do with FX. I have a program which carves out data from a structured file (Windows event log). Each struct holds a chunk of data with the exception of the last struct which holds a lot more data and requires regular expressions to get the relevant data out. I was wondering is there a way in FX that when the program encounters this struct, it passes a hyperlink type thing or button so when the user clicks on it they can view the entire contents of the complex struct for example data a????????? data b????????? data c????????? data d???????????? button for clicking Regards Stuart --- On Thu, 18/12/08, Lyle Johnson <lyle at lylejohnson.name> wrote: From: Lyle Johnson <lyle at lylejohnson.name> Subject: Re: [fxruby-users] Directory listing query To: fxruby-users at rubyforge.org Date: Thursday, 18 December, 2008, 8:30 PM On Dec 18, 2008, at 10:53 AM, Stuart Clarke wrote: This throws errors. Do I need a to_s? That depends. What kind of error does it throw?_______________________________________________ fxruby-users mailing list fxruby-users at rubyforge.org http://rubyforge.org/mailman/listinfo/fxruby-users -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/fxruby-users/attachments/20081218/4803ea33/attachment-0001.html>