2014-03-28 40 views
2

我试图建立在鞋的图形用户界面。但是当我点击一个按钮时,我无法打开一个新窗口。请help.When我单击文件按钮我想打开一个新的窗口,将有更多的按钮。如何打开一个新窗口按钮点击鞋红宝石

代码:

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 

回答

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 
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 

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