Scrolling / wxPanel / wxFlexGridSizer

I have a problem getting scroll bars to become active. Scrollbars
appear but do not actually scroll. The problem I am trying to
solve is to list a large number of key/value pairs. I looked
to use PropertyGrid but did not find it in wxruby 2.0.1. I’m
really stuck and would appreciate any help.

Thanks,
Dave

Details:

I am starting with an .xrc file containing:

wxStaticBoxSizer (horizontal, stretch factor 1, expanded vertically)
wxPanel (stretch factor 1, expanded vertically)

In the ruby file invoking the interface I have:

require ‘wx’
require ‘loadgui.rb’ # from xrcise

class MyApp < MyGUI
def on_init
# Sizer holding key value pairs
@settings_sizer = Wx::FlexGridSizer.new(2)
@settings_sizer.add_growable_col(1, 1)

# wxPanel holding the sizer above
@panel       = @finder.call( 'ID_SETTINGS' )
@panel.sizer = @settings_sizer

@labels = {}
@texts  = {}
ENV.each { |k, v|
  @labels[k] = Wx::StaticText.new(@panel, :label => k)
  @texts[k]  = Wx::TextCtrl.new(@panel, :value => v)
  @settings_sizer.add @labels[k], 0
  @settings_sizer.add @texts[k], 1, Wx::EXPAND
}

end
end

Run the Application

Wx::App.run do
$app = MyApp.new
$app.show
end

Hello Dave,

On Fri, Nov 12, 2010 at 7:05 PM, David I. [email protected]
wrote:

I have a problem getting scroll bars to become active. Scrollbars
appear but do not actually scroll. The problem I am trying to
solve is to list a large number of key/value pairs. I looked
to use PropertyGrid but did not find it in wxruby 2.0.1. I’m
really stuck and would appreciate any help.

Thanks,
Dave

We don’t have PropertyGrid available in 2.0.1, but we do have Wx::Grid
available, which should allow you to use a Key > Val pairs setup in it,
as
well as Wx::ListCtrl. Take a look at these two classes’ documentation,
to
see if it will help you.

http://wxruby.rubyforge.org/doc/grid.html
http://wxruby.rubyforge.org/doc/listctrl.html

hth,

Mario

Thanks for the help Mario.

I did look at grid and listctrl. I had hoped to use a FlexGridSizer
instead, because I wanted columns of different sizes and to have
one column grow. ListCtrl looks fairly complicated.

My problem seems to be getting the parenting or settings correct
to have scrollbars work when I fill the FlexGridSizer beyond its
window capacity. The scrollbars appear, using a settings of the
wxPanel, but mouse clicks on them don’t cause scrolling.

My hierarchy looks like:

wxStaticBoxSizer (horizontal, stretch factor 1, expanded vertically)
wxPanel (stretch factor 1, expanded vertically)
wxFlexGridSizer (2 cols, col 1 growable, stretch factor 1)
wxStaticText
wxTextCtrl

wxStaticText
wxTextCtrl

Thanks,
Dave