使用wxRuby的RadioBox问题

使用wxRuby的RadioBox问题,ruby,radio-button,wxruby,Ruby,Radio Button,Wxruby,我在wxRuby上发现了一个使用的情况 我的收音机盒有一些丑陋的背景和边框: 与我运行时风格更好的演示不同: 这是我的密码: #!/usr/bin/env ruby # coding: utf-8 require 'wx' include Wx class MainFrame < Frame def initialize() super(nil, :title => "Title", :size => [ 480, 400 ])

我在wxRuby上发现了一个使用的情况

我的收音机盒有一些丑陋的背景和边框:

与我运行时风格更好的演示不同:

这是我的密码:

#!/usr/bin/env ruby
# coding: utf-8

require 'wx'
include Wx

class MainFrame < Frame
    def initialize()
    super(nil, :title => "Title", :size => [ 480, 400 ])
        #sizer = Wx::BoxSizer.new(Wx::VERTICAL)
        sampleList = ["Choice1","Choice2","Choice3"]
    rb = Wx::RadioBox.new(self, -1, "Title1", Wx::Point.new(15,20), Wx::Size.new(100,200), sampleList, 1, Wx::RA_SPECIFY_COLS, DEFAULT_VALIDATOR, "Name1")
        evt_radiobox(rb) {|event, other| on_debug(sampleList[event.get_int()].to_s(), rb.name.to_s())}
        #sizer.add(rb, 0, Wx::ALL, 20)
    rb2 = Wx::RadioBox.new(self, -1, "Title2", Wx::Point.new(150,20), Wx::Size.new(100,200), sampleList, 1, Wx::RA_SPECIFY_COLS, DEFAULT_VALIDATOR, "Name2")
        evt_radiobox(rb2) {|event| on_debug(sampleList[event.get_int()].to_s(), rb2.name.to_s())}
        #sizer.add(rb2, 0, Wx::ALL, 20)
        #set_sizer(sizer)
    #sizer.fit(self)
        #sizer.layout()
  end
  
  # show a 'Debug' dialog
  def on_debug(*params)
    Wx::message_box("Debug :\n\r\n\r#{params.inspect}",
        "Debug Box",
        ICON_INFORMATION|OK)
  end
end


class MyApp < App
    def on_init
    frame = MainFrame.new
    frame.show
    end
end
MyApp.new.main_loop()
#/usr/bin/env ruby
#编码:utf-8
需要“wx”
包括Wx
类主机<框架
def初始化()
超级(零,:title=>“title”,:size=>[480400])
#sizer=Wx::BoxSizer.new(Wx::VERTICAL)
样本列表=[“Choice1”、“Choice2”、“Choice3”]
rb=Wx::RadioBox.new(self,-1,“Title1”,Wx::Point.new(15,20),Wx::Size.new(100200),sampleList,1,Wx::RA_SPECIFY_COLS,默认_验证器,“Name1”)
evt|U radiobox(rb){|事件,其他| on|U调试(sampleList[event.get_int()].to_s(),rb.name.to_s())}
#sizer.add(rb,0,Wx::ALL,20)
rb2=Wx::RadioBox.new(self,-1,“Title2”,Wx::Point.new(150,20),Wx::Size.new(100200),sampleList,1,Wx::RA\u SPECIFY\u COLS,默认的\u验证器,“Name2”)
evt_radiobox(rb2){| event | on_debug(sampleList[event.get_int()].to_s(),rb2.name.to_s())}
#sizer.add(rb2,0,Wx::ALL,20)
#设置施胶器(施胶器)
#sizer.fit(自配)
#sizer.layout()
结束
#显示“调试”对话框
def on_调试(*参数)
Wx::消息框(“调试:\n\r\n\r{params.inspect}”,
“调试框”,
图标|信息|正常)
结束
结束
类MyApp
以下是默认代码:

  • 这段代码似乎与
    C:\[your Ruby install]\lib\Ruby\gems\1.9.1\gems\wxRuby-ruby19-2.0.1-x86-mingw32\samples\bigdemo中的wxRuby安装代码不同

非常感谢您提供的任何帮助,因为我真的不知道为什么外观会有这么大的不同?

通过在主框架上设置默认背景色,问题得以解决:

代码如下:

#!/usr/bin/env ruby
# coding: utf-8

require 'wx'
include Wx

class MainFrame < Frame
    def initialize()
    super(nil, :title => "Title", :size => [ 480, 400 ])
        #sizer = Wx::BoxSizer.new(Wx::VERTICAL)
    self.set_background_colour(Wx::NULL_COLOUR)
        sampleList = ["Choice1","Choice2","Choice3"]
    rb = Wx::RadioBox.new(self, -1, "Title1", Wx::Point.new(15,20), Wx::Size.new(100,200), sampleList, 1, Wx::RA_SPECIFY_COLS, DEFAULT_VALIDATOR, "Name1")
        evt_radiobox(rb) {|event, other| on_debug(sampleList[event.get_int()].to_s(), rb.name.to_s())}
        #sizer.add(rb, 0, Wx::ALL, 20)
    rb2 = Wx::RadioBox.new(self, -1, "Title2", Wx::Point.new(150,20), Wx::Size.new(100,200), sampleList, 1, Wx::RA_SPECIFY_COLS, DEFAULT_VALIDATOR, "Name2")
        evt_radiobox(rb2) {|event| on_debug(sampleList[event.get_int()].to_s(), rb2.name.to_s())}
        #sizer.add(rb2, 0, Wx::ALL, 20)
        #set_sizer(sizer)
    #sizer.fit(self)
        #sizer.layout()
  end

  # show a 'Debug' dialog
  def on_debug(*params)
    Wx::message_box("Debug :\n\r\n\r#{params.inspect}",
        "Debug Box",
        ICON_INFORMATION|OK)
  end
end


class MyApp < App
    def on_init
    frame = MainFrame.new
    frame.show
   end
end
MyApp.new.main_loop()
#/usr/bin/env ruby
#编码:utf-8
需要“wx”
包括Wx
类主机<框架
def初始化()
超级(零,:title=>“title”,:size=>[480400])
#sizer=Wx::BoxSizer.new(Wx::VERTICAL)
设置背景颜色(Wx::空颜色)
样本列表=[“Choice1”、“Choice2”、“Choice3”]
rb=Wx::RadioBox.new(self,-1,“Title1”,Wx::Point.new(15,20),Wx::Size.new(100200),sampleList,1,Wx::RA_SPECIFY_COLS,默认_验证器,“Name1”)
evt|U radiobox(rb){|事件,其他| on|U调试(sampleList[event.get_int()].to_s(),rb.name.to_s())}
#sizer.add(rb,0,Wx::ALL,20)
rb2=Wx::RadioBox.new(self,-1,“Title2”,Wx::Point.new(150,20),Wx::Size.new(100200),sampleList,1,Wx::RA\u SPECIFY\u COLS,默认的\u验证器,“Name2”)
evt_radiobox(rb2){| event | on_debug(sampleList[event.get_int()].to_s(),rb2.name.to_s())}
#sizer.add(rb2,0,Wx::ALL,20)
#设置施胶器(施胶器)
#sizer.fit(自配)
#sizer.layout()
结束
#显示“调试”对话框
def on_调试(*参数)
Wx::消息框(“调试:\n\r\n\r{params.inspect}”,
“调试框”,
图标|信息|正常)
结束
结束
类MyApp