On Fri, 26 Jul 2002, lyle / knology.net wrote: > The FOX button widget is called FXButton, and the "button.rb" example [...] > The FOX equivalent of Tk's Entry widget is the FXTextField. For your program [...] > Finally, FOX's equivalent of the Tk Label is (you guessed it) called FXLabel: [...] That was enough to get me there. Thank you. My code, which was brutally "carved with an axe" from the Pig Latin example in Programming Ruby (as you could tell by the unfinished stuff) now looks like that below. I post it here (a) so you can use it as an example and (b) so others trawling the archives can find it. > > Can I suggest that you link the filenames in chapter 2 (Examples) to the > > actual code, so that we can see how to use these widgets, please? > > Yes, this is a good suggestion. I will make a note to do this for the next > release. thank you. > > Hope this helps, It seems that FXDataTargets are not quite the same as Tcl's linking of variables to widgets -- it is necessary to extract the value from the FXDataTarget with a .value call. I note this here for those who follow, it is not intended as a perjorative remark about your description! The serious thing that tripped me up near the end was the application.create call, which I thought would be implicit in the show or the run call. I don't know what it does exactly, so I don't understand why it needs to be a separate call. Also, application.init insists on taking an argument. If I'm not using ARGV to pass the data this is not really what I want. I have not tried leaving this call out since the code worked. If these reflect aspects of the C++ API, may I suggest that you either document their purpose in the Ruby API, or allow them to be assimilated into soemthing more Rubyesque, because at the moment we have calls to application.new, application.init and application.create. > > Lyle > Hugh #!/usr/local/bin/ruby # A program to allow the transmission of a file inband. require "fox" include Fox class Upload attr_accessor :application def do_connection() require 'net/telnet' # print "host #{@host.value}" # print "user #{@user.value}, pass #{@pass.value}" # print "file #{@file.value}" # return tn = Net::Telnet.new("Host" => @host.value) response = tn.login(@user.value, @pass.value) print response # tn.waitfor(@prompt.value) open(@file.value, "rb") { |fp| tn.print(%Q{cat | ruby -pe '$_ = $_.unpack("m").shift' > #{@file.value}}) while line = fp.read(40) tn.print "#{[line].pack('m')}\n" sleep 0.1 # print "#{[line].pack('m')}\n" end tn.print "\004\n" sleep 1 tn.print "exit\n" } end def initialize() @application = FXApp.new("Uploader", "HughSasse") @application.init(ARGV) entry_width = 15 main = FXMainWindow.new(@application, "Uploader", nil, nil, DECOR_ALL) # initilize varaibles @host = FXDataTarget.new("") # for a string @user = FXDataTarget.new("") # for a string @pass = FXDataTarget.new("") # for a string @prompt = FXDataTarget.new("") # for a string @file = FXDataTarget.new("") # for a string @host_label = FXLabel.new(main, "Remote Host:") @host_entry = FXTextField.new(main, entry_width, @host, FXDataTarget::ID_VALUE) @user_label = FXLabel.new(main, "username:") @user_entry = FXTextField.new(main, entry_width, @user, FXDataTarget::ID_VALUE) @pass_label = FXLabel.new(main, "password:") @pass_entry = FXTextField.new(main, entry_width, @pass, FXDataTarget::ID_VALUE, TEXTFIELD_NORMAL|TEXTFIELD_PASSWD) # @prompt_label = FXLabel.new(main, "prompt:") # @prompt_entry = FXTextField.new(main, entry_width, # @prompt, FXDataTarget::ID_VALUE) @file_label = FXLabel.new(main,"File to send:") @file_entry = FXTextField.new(main, entry_width, @file, FXDataTarget::ID_VALUE) @send_button = FXButton.new(main, "Send") @send_button.connect(SEL_COMMAND) { do_connection } @exit_button = FXButton.new(main, "Exit") @exit_button.connect(SEL_COMMAND) { exit 0 } @application.create main.show(PLACEMENT_SCREEN) end end uploader = Upload.new() uploader.application.run