系统设置
Windows 10 Education Edition 64bit
Ruby 2.3.0
green_shoes installed via gem install green_shoes
我一般对绿色鞋子和红宝石很陌生。 我试图为我的经济学课写一个简单的实际收入计算器,但遇到了麻烦。
我编写的代码适用于常规鞋子安装,但我想使用 gem 版本,所以我选择了green_shoes看起来最好的。
我遇到的问题是 para 对象应该显示在edit_line对象的左侧,例如
Edit_Line
但显示像
Para
Edit_Line
不确定我做错了什么,但如果有人能帮忙,那就太棒了。
我的代码
require 'green_shoes'
Shoes.app(title: "Real Income Calculator", width: 400, height: 180) do
stack do
para "Real Income Calculator"
flow do
@nip = para "Nominal Income"
@nip.style(margin_right: 10)
@nit = edit_line
@nit.style(width: 150)
end
flow do
@cpip = para "CPI"
@cpip.style(margin_right: 10)
@cpit = edit_line
@cpit.style(width: 80)
end
@calc = button "Calculate"
@calc.click do
ni = @nit.text.to_i
cpi = @cpit.text.to_i
ri = (ni/cpi)*100
alert(ri)
end
end
end
我从手册页 http://ashbb.github.io/green_shoes/Check.html 建模的代码green_shoes
Shoes.app do
stack do
flow do
check; para "Frances Johnson", width: 200
end
flow do
check; para "Ignatius J. Reilly", width: 200
end
flow do
check
para "Winston Niles Rumfoord", width: 200
end
end
end
也许你应该"升级"到Shoes3.3.1或Shoes4(下面在 3.3.1 上测试,在 Shoes4 上也应该没问题)
Shoes.app title: "Real Income Calculator", width: 400, height: 180 do
stack do
para "Real Income Calculator"
flow do
@nip = para "Nominal Income", margin_right: 10
@nit = edit_line "", width: 150
end
end
end