require 'rubygems'
require 'wx'
class MyApp < Wx::App
def on_init
# create new Frame:
@mainwindow = Wx::Frame.new(nil, -1, "Test", Wx::DEFAULT_POSITION, Wx::Size.new(300, 200))
@mainwindow.set_background_colour(Wx::NULL_COLOUR)
# add a StaticText control:
@text1 = Wx::StaticText.new(@mainwindow, :text.to_i, "This is a test.", Wx::Point.new(50, 20))
# create Font #1
@font1 = Wx::Font.new(10, Wx::FONTFAMILY_MODERN, Wx::FONTSTYLE_NORMAL, Wx::FONTWEIGHT_NORMAL)
# create Font #2
@font2 = Wx::Font.new()
@font2.set_point_size(20)
@font2.set_family(Wx::FONTFAMILY_SWISS)
@font2.set_style(Wx::FONTSTYLE_ITALIC)
@font2.set_weight(Wx::FONTWEIGHT_BOLD)
# set the StaticText font to Font #1:
@text1.set_font(@font1)
# make the StaticText text red:
@text1.set_foreground_colour(Wx::RED)
# add a Button:
@button = Wx::Button.new(@mainwindow, :button.object_id, "Super-size Me!", Wx::Point.new(50, 60), Wx::Size.new(100, 50))
# create button click handler to change StaticText font to Font #2:
evt_button(:button.object_id){|event| @text1.set_font(@font2)}
@mainwindow.show
end
end
x = MyApp.new()
x.main_loop()