The following program represents the basic layout of my application. The
problem I have is that the panel, and thus, the grid does not resize
when the window width is expanded.
Also, I would like the entire grid to be displayed without the
horizontal scroll bar. How can I force this behavior?
Please tell me if I am going about this incorrectly. I am just getting
familar with wxRuby and any advice is appreciated.
# CODE STARTS HERE ....
require ''wxruby''
class TestApp < Wx::App
def on_init
@frame = Wx::Frame.new( nil, -1, "Test", Wx::DEFAULT_POSITION )
@panel = Wx::Panel.new( @frame )
@topSizer = Wx::FlexGridSizer.new( 1, 3 )
@topSizer.add( createInputSizer(), 1, Wx::GROW|Wx::ALL, 2 )
@topSizer.add( createGridSizer(), 1, Wx::GROW|Wx::ALL, 2 )
@topSizer.add( createButtonSizer(), 1,
Wx::ALIGN_CENTER_HORIZONTAL|Wx::ALL, 2 )
@panel.set_sizer( @topSizer )
@topSizer.fit( @frame )
@frame.show
self.main_loop
end
def createButtonSizer
@buttonSizer = Wx::BoxSizer.new( Wx::HORIZONTAL )
@btn1 = Wx::Button.new(@panel, -1, ''Button 1'')
@buttonSizer.add(@btn1, 0, Wx::ALIGN_CENTER_VERTICAL|Wx::ALL, 2)
@btn2 = Wx::Button.new(@panel, -1, ''Print'')
@buttonSizer.add(@btn2, 0, Wx::ALIGN_CENTER_VERTICAL|Wx::ALL, 2)
@buttonSizer
end
def createGridSizer
@gridSizer = Wx::BoxSizer.new( Wx::VERTICAL )
@grid = Wx::Grid.new( @panel, -1, Wx::Point.new( 1, 1 ),
Wx::Size.new( 500, 350 ) )
@grid.create_grid( 15, 7 )
@gridSizer.add( @grid, 1, Wx::GROW|Wx::ALL, 5 )
@gridSizer
end
def createInputSizer
@inputSizer = Wx::FlexGridSizer.new( 4, 3 )
st1 = Wx::StaticText.new( @panel, -1, "Text:" )
@inputSizer.add( st1, 0,
Wx::ALIGN_CENTER_HORIZONTAL|Wx::ALIGN_CENTER_VERTICAL|Wx::ALL|Wx::ADJUST_MINSIZE,
5 )
@text1 = Wx::TextCtrl.new(@panel, -1, ''Type in here'' )
@inputSizer.add( @text1, 0,
Wx::ALIGN_CENTER_HORIZONTAL|Wx::ALIGN_CENTER_VERTICAL|Wx::ALL, 5 )
st2 = Wx::StaticText.new( @panel, -1, "Text:" )
@inputSizer.add( st2, 0,
Wx::ALIGN_CENTER_HORIZONTAL|Wx::ALIGN_CENTER_VERTICAL|Wx::ALL|Wx::ADJUST_MINSIZE,
5 )
@text2 = Wx::TextCtrl.new(@panel, -1, ''Type in here'' )
@inputSizer.add( @text2, 0,
Wx::ALIGN_CENTER_HORIZONTAL|Wx::ALIGN_CENTER_VERTICAL|Wx::ALL, 5 )
@inputSizer
end
end
app = TestApp.new()