[fxruby-users] resizing main window on the fly

Don Wilde dwilde1 at gmail.com
Thu Nov 6 21:19:36 EST 2008


On Thu, Nov 6, 2008 at 1:53 PM, angico <angico at angico.org> wrote:

> Em Qui, 2008-11-06 às 12:01 -0600, Don Wilde escreveu:
> > Hi, all -
> >
> > Is it possible to resize the main window on the fly? I want to default
> > to an 800x600 window but give the user an option to resize to 1024.
> >
> > This approach didn't work:
> >
>
 [snip]

When you say @mainWindowWidth = data.to_i you're just assigning variable
> @mainWindowWidth a new value. It has nothing to do with the
> application's main window's width.
>
> Instead, try:
>
>    winWidth.connect( SEL_COMMAND ) do | sender, sel, data |
>        resize(data.to_i, height)
>    end
>
>
> Hope this helps.


 Hi, Angico -

You definitely put me on the right track.

One further refinement necessary, for the record.

FXListBox returns a zero-based index into the list, not the text. FXComboBox
(according to Lyle) can be inspected with sender.text, but FXListBox is a
bit more primitive.

My working solution, retaining the variable so I can intelligently size and
position things:

    availWinWidths = Array["800", "1024"]
    winWidth = FXListBox.new( blk1, :opts => LISTBOX_NORMAL )
    availWinWidths.each { | w | winWidth.appendItem( w ) }
    winWidth.connect( SEL_COMMAND ) do | sender, sel, data |
      wSel = availWinWidths[ data.to_i ]
      @mainWindowWidth = wSel.to_i
      resize(@mainWindowWidth, 600 )
    end

It works marvelously well. Thank you for the big nudge in the right
direction!

-- :D
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/fxruby-users/attachments/20081106/04d88080/attachment.html>


More information about the fxruby-users mailing list