RubyLit - Ruby.del.litoral!
uso de Radio Button (changes)

Showing changes from revision #0 to #1: Added | Removed

require "rubygems" 
require "wx" 
include Wx
class Ejemplo < App  
def on_init  
 frameEjemplo = Frame.new(nil, -1, "Ejemplo")

 @colores = ["celeste", "blanco", "amarillo", "rojo"]

 @rb1 = RadioBox.new(frameEjemplo,  1,  "RadioBox1", [20,20], DEFAULT_SIZE, 
            @colores, 0, RA_SPECIFY_COLS) 

 @rb2 = RadioBox.new(frameEjemplo,  2,  "RadioBox2", [20,80], DEFAULT_SIZE, 
            @colores, 0, RA_SPECIFY_ROWS) 
 @rb2.set_selection(1)

 bt1 = Button.new(frameEjemplo, 3, "click 1",  [200, 80], DEFAULT_SIZE, BU_TOP)

 evt_button(3) { | event | 
     printf("%s y %s\n", @colores[@rb1.get_selection],@colores[@rb2.get_selection])
 }
 evt_radiobox(1) { | event | 
     index = event.get_selection 
     case index
     when 0
         @rb2.set_selection(1)
     when 1
         @rb2.set_selection(0)
     when 2
         @rb2.set_selection(3)
     when 3
         @rb2.set_selection(2)
     end
 }

 evt_radiobox(2) { | event | 
     index = event.get_selection 
     case index
     when 0
         @rb1.set_selection(1)
     when 1
         @rb1.set_selection(0)
     when 2
         @rb1.set_selection(3)
     when 3
         @rb1.set_selection(2)
     end
 }

 frameEjemplo.show()

end

end
Ejemplo.new.main_loop

wx3

bajar el código fuente del ejemplo