Ruby green_shoes 流量

Ruby green_shoes flows

系统设置

Windows 10 Education Edition 64bit
Ruby 2.3.0
green_shoes installed via gem install green_shoes

我是绿鞋新手,ruby 总的来说。我试图为我的经济学 class 编写一个简单的实际收入计算器,但遇到了麻烦。

我编写的代码在常规鞋安装上运行良好,但我想使用 gem 版本,所以我选择了 green_shoes,这似乎是最好的。

我遇到的问题是 para 对象应该显示在 edit_line 对象的左侧,例如

段Edit_Line

而是显示为


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

我根据 green_shoes 手册页 http://ashbb.github.io/green_shoes/Check.html

建模的代码
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

也许你应该 "upgrade" 选择 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