如何通过按钮点击鞋子红宝石打开一个新窗口

时间:2014-03-28 10:48:54

标签: ruby shoes

我正在尝试用鞋子建立一个GUI。但是当我点击一个按钮时,我无法打开一个新窗口。请帮助。当我点击文件按钮时,我想打开一个新窗口,它将有更多按钮。

代码是:

Shoes.app(:width => 500 ,:height => 500) do 


@File =  button "FILE"  , :width => 80 , :height => 30  do
    window :title => 'new window' ,:width => 300 ,:height => 300 do
    para "hello"
    end 

end 
@File.move(300,100)

@fileimage = image 'instagram.png' , :width => 50 , :height =>50 
@fileimage.move(220,100)

@Options = button "OPTIONS" , :width => 80 , :height => 30 do 
    alert "options button"
end
    @Options.move(300,170)

@optionsimage = image 'cog2.png' , :width => 50 , :height =>50 
@optionsimage.move(220,160)

@help = button "HELP"  , :width => 80 , :height => 30do 
    alert "Help button"
    end

@help.move(300,230)

@helpimage =image 'Dzone-Logo-Square-Webtreatsetc.png',:width => 50 , :height => 50
@helpimage.move(220,220)

@about = button "ABOUT" , :width => 80 , :height => 30   do 
    alert "About button"
    end

@about.move(300,280)            

@aboutimage =image 'thumbs-up.png',:width => 50 , :height => 50
@aboutimage.move(220,280)



end

2 个答案:

答案 0 :(得分:1)

以下是绿鞋的例子

require 'green_shoes'

Shoes.app title: "The Owner" do
   button "Pop up?" do
     window do
       para "Okay, popped up from #{owner}"
     end
   end
 end

答案 1 :(得分:0)

您可以将某个应用程序放入一个函数中并通过单击按钮调用它

require "green_shoes"
def window1
    Shoes.app do
        @a = button "click me"
        @a.click do
            window2
        end
    end
end
def window2
    Shoes.app do
        para "Window 2"
    end
end
window1

如果要在第一个窗口中引用变量,请使用owner对象。当第一个窗口被第一个窗口调用时,它是所有者,您可以通过所有者对象传递信息。