Ruby green_shoes不能正常工作

时间:2016-03-19 21:15:25

标签: ruby flow shoes

系统设置

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

我是绿鞋和红宝石的新手。我试图为我的经济学课程编写一个简单的实际收入计算器,并且遇到了麻烦。

我编写的代码与普通的鞋子安装工作正常,但我想使用宝石版本,所以我选择了绿色的鞋子,这似乎是最好的。

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

Para 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

1 个答案:

答案 0 :(得分:0)

也许你应该"升级"无论是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