« Return to Thread: Learning FXRuby please help!

Re: Learning FXRuby please help!

by Philippe Lang :: Rate this Message:

Reply to Author | View in Thread

fxruby-users-bounces@... wrote:

> Thanks again for your input. I've read through Lyle's book, which is
> where I'm trying to learn FXRuby from. It's a great book, but I don't
> see where there's anything about using self.recalc.  
>
> While trying to solve this problem, I also tried to create the window
> in the button block, and it didn't work. I just now tried adding your
> self.recalc code, and it still doesn't show. Clearly I'm missing
> something that should be obvious!  
>
> class Lookup < FXMainWindow
>   def initialize(app)
>     super(app, "Lookup window", :width=>400, :height=>600,
>     :opts => DECOR_ALL|LAYOUT_FILL_X|LAYOUT_FILL_Y)
>     bframe = FXHorizontalFrame.new(self, :opts => LAYOUT_FILL_X)
>     hearButton = FXButton.new(bframe, "Do you hear me?")
>     hearButton.connect(SEL_COMMAND) do |sender,sel, data|
>       @yesWindow = FXHorizontalFrame.new(self, :opts =>
> FRAME_GROOVE|LAYOUT_FILL_X)
>       yesLabel = FXLabel.new(@yesWindow,"Yes")
>       self.recalc
>       @yesWindow.show
>       puts "pushed hear button"
>       puts "window shown? " + @yesWindow.shown?.to_s
>     end
>   end

When you create controls dynamically, don't forget to call "create",
like this:

require 'fox16'
include Fox

class Lookup < FXMainWindow
  def initialize(app)
    super(app, "Lookup window", :width=>400, :height=>600,
    :opts => DECOR_ALL|LAYOUT_FILL_X|LAYOUT_FILL_Y)
    bframe = FXHorizontalFrame.new(self, :opts => LAYOUT_FILL_X)
    hearButton = FXButton.new(bframe, "Do you hear me?")
    hearButton.connect(SEL_COMMAND) do |sender,sel, data|
      @yesWindow = FXHorizontalFrame.new(self, :opts =>
FRAME_GROOVE|LAYOUT_FILL_X)
      yesLabel = FXLabel.new(@yesWindow,"Yes")
      @yesWindow.create
      self.recalc
      @yesWindow.show
      puts "pushed hear button"
      puts "window shown? " + @yesWindow.shown?.to_s
    end
  end

  def create
    super
    show(PLACEMENT_SCREEN)
  end

end

if __FILE__ == $0
  FXApp.new do |app|
    Lookup.new(app)
    app.create
    app.run
  end
End

Best regards,

Philippe Lang
Attik System
_______________________________________________
fxruby-users mailing list
fxruby-users@...
http://rubyforge.org/mailman/listinfo/fxruby-users

 « Return to Thread: Learning FXRuby please help!