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§}
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”

Hi Lark,

Thank you for the post about Shoes! :slight_smile:

I confirmed your problem with Shoes 3 (0.r1514) on my Windows 7.

I’ve uploaded two solutions on Gist. Try them out. :wink:

https://gist.github.com/890466

Hope this helps,
ashbb

heey many thanks for your help i will check it as soon as i got home,

sorry for my late reply i was very busy these day’s.

heey your great it works!!!

but i have one problem the list button works but it doesn’t shows all
names
he stacks the editbox’s on each other
please help me

Hi Lark,

but i have one problem the list button works
but it doesn’t shows all names

If you want to change the text within an editbox every time you click
search or list button, it’s better to use EditBox#text() method.

I updated ppid.rb and PPIDdata.txt in the gist:
https://gist.github.com/890466

Try it out,
ashbb

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs