Ruby shoes. How to enable windows dependencies

I am experimenting with ruby ​​and found a gui toolkit called Shoes.

I am using Windows 8 and I would like to create a button in Shoes and play an audio file when pressed.

The handleless box I'm using is as follows. Be aware that I had to install this gem for this: https://rubygems.org/gems/win32-sound

require 'win32/sound'
include Win32

puts "Hit Enter"   
makeSound = gets.chomp  

while makeSound
Sound.play('c:\users\william\desktop\oink.wav') 
makeSound = gets.chomp  
end

      

The code I'm trying to run using Shoes is:

require 'win32/sound'
include Win32


 Shoes.app {
    @push = button "Push me"
    @push.click {
      Sound.play('c:\users\william\desktop\oink.wav')
    }
  }

      

Now of course this won't work, but I am asking how to approach and / or fix this problem.

enter image description here

+3


source to share


1 answer


I am assuming you are using Red Shoes (as seen in the above snapshot). The shoes will not be able to require gems that you have installed directly into the car. You need to tell the Shoes in detail that you are going to use some kind of gem and let the shoes customize it before starting the application.

You can do it like this: enter the code below your shoe code:



Shoes.setup do
 gem 'win32-sound'
end
#Now you can require gem and do the rest as you need...
require 'win32/sound'
include Win32 

      

Hope this helps :)

+1


source







All Articles