Hello Michael,
To answer your question as easily as possible, the problem you are facing,
is that your scrolled window, needs to have a Panel or Window created inside
of it, in order for it to work. Then if your going to have multiple
controls, and don''t want to exclusively control where they are, then
you
will need to use a sizer on that Panel or Window, then all controls that are
to be displayed in the Scrolled Window, need to have their parent set to
that Panel or Window.
An example, would be:
class MyFrame < Wx::Frame
def initialize()
super nil
@scrolled = Wx::ScrolledWindow.new(self)
@panel = Wx::Panel.new(@scrolled)
text1 = Wx::StaticText.new(@panel,-1,"Hello World")
edit1 = Wx::TextCtrl.new(@panel,-1,"")
vbox = Wx::BoxSizer.new(Wx::VERTICAL)
vbox.add text1
vbox.add edit1, 1, Wx::ALL | Wx::EXPAND
@panel.sizer = vbox
end
end
With this design, you''ll see that text1 and edit1 are children of
@panel,
instead of MyFrame, or @scrolled. @panel is a child of @scrolled. And you
don''t nesscarly need to create the Box Sizer before you create the
controls.
You can create the controls at any time, as long as they are assigned to a
Box Sizer, before displaying them (Through show, or show_all methods of
Window), otherwise, they''ll just appear in the upper left hand corner.
;-)
hth to clarify,
Mario
On Sat, Jan 2, 2010 at 3:15 AM, Michael Mcandrews <lists at
ruby-forum.com>wrote:
> I''m having a real problem getting stuff into a WxScrolledWindow.
What
> I''m trying to do is use a scrolled widow to display a set records
(two
> elements, a StaticText label and a TextCtrl entry box) that will likely
> be longer than the window (so need vertical scrolling). But I
can''t get
> anything into the ScrolledWindow control, everythings ends up at the top
> left of the entire form, as if I haven''t placed them properly.
>
> Does a ScrolledWindow need to be put into a sizer?
> Does the Scrolled Window need a sizer inside of it?
> Do items go into the ScrolledWindow directly, or do they need to be
> placed into a sizer that is inside the ScrolledWindow?
>
> I''ve tried everycombination I can think of, but have not hit upon
the
> correct one. No matter what I try, all "record" items end up at
the top
> left of the form, just as they would appear if the items had been
> "defined" but not yet "placed".
> --
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> wxruby-users mailing list
> wxruby-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/wxruby-users
>
--
Mario Steele
http://www.trilake.net
http://www.ruby-im.net
http://rubyforge.org/projects/wxruby/
http://rubyforge.org/projects/wxride/
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://rubyforge.org/pipermail/wxruby-users/attachments/20100102/9a5b018a/attachment.html>