From: Lark Work Date: 2011-03-27T18:05:55+09:00 Subject: ruby shoes problems he iam stuck with ruby shoes the "search" and "list" button doesn't work here is the code: Shoes.app :title => "PPID", :height => 400, :width => 700 do background black, :height => 60 background gradient(rgb(1.0, 1.0, 1.0, 0.7), rgb(1.0, 1.0, 1.0, 0.0)) title "PPID", :align => "center", :stroke => white caption "Personal: Person Info Database", :top => 80, :left => 20 stack :top => 130, :left => 50 do para "Add to database:" flow do inscription "Name: " @name = edit_line :width => 120 end flow do inscription "Lastname: " @lastname = edit_line :width => 120 end flow do inscription "Phonenumber: " @phonenumber = edit_line :width => 80 end flow do inscription "Birthday: " @month = edit_line :width => 30 @day = edit_line :width => 30 @year = edit_line :width => 50 end flow do inscription "City: " @city = edit_line :width => 120 end flow do inscription "Streetname: " @streetname = edit_line :width => 120 @housenumber = edit_line :width => 50 end @save_button = button "Save" do open('PPIDdata.txt', 'a+') { |f| f.puts "#{@name.text},#{@lastname.text},#{@phonenumber.text},#{@month.text}-#{@day.text}-#{@year.text},#{@city.text},#{@streetname.text} #{@housenumber.text}"} stack do @show_text = "Name: #{@name.text} #{@lastname.text} Phonenumber: #{@phonenumber.text} Birthday: #{@month.text}-#{@day.text}-#{@year.text} City: #{@city.text} Adress: #{@streetname.text} #{@housenumber.text}" end edit_box @show_text, :width => 250, :height => 200, :top => 140, :left => 380 end end edit_box "", :width => 250, :height => 200, :top => 140, :left => 380 class SomeDataProcessing Person = Struct.new :name, :last_name, :phone_number, :birthday, :city, :adress def self.openOn(p_file) new(p_file) end def initialize(p_file) @file = p_file @persons = {} loadData end def listData @persons.keys.sort.each {|p| showlistData(p)} end def loadData File.foreach(@file) do |line| name, last_name, phone_number, birthday, city, adress = line.chomp.split(",") @persons[name] = Person.new(name, last_name, phone_number, birthday, city, adress) end end def showData(p_name) person = @persons[p_name] if person.nil? then @show_text2 = "#{p_name} not in database." end stack do @show_text2 = "Name: #{person.name} #{person.last_name}" "Phonenumber: #{person.phone_number}" "Birthday: #{person.birthday}" "City: #{person.city}" "Adress: #{person.adress}" end edit_box @show_text2, :width => 250, :height => 200, :top => 140, :left => 380 end def showlistData(p_name) person = @persons[p_name] if person.nil? then @show_text3 = "#{p_name} not in database." end @show_text3 = "#{person.name} #{person.last_name}" edit_box @show_text3, :width => 250, :height => 200, :top => 140, :left => 380 end end stack :top => 85, :left => 380 do flow do name = edit_line :width => 150 button "Search" do ds = SomeDataProcessing.openOn("PPIDdata.txt") ds.showData(name.text) end button "List" do dl = SomeDataProcessing.openOn("PPIDdata.txt") dl.listData end end end end the file they are asking for is this "PPIDdata.txt" it contains "test,test,test,test-test-test,test,test test" -- Posted via http://www.ruby-forum.com/.