fxruby-users-bounces@... wrote:
> Hi all,
>
> I'm trying to get text on to the screen in response to pressing a
> button. This code doesn't work, and I don't know why. My puts command
> says that the window is shown, but it's not displayed.
>
> Also, it seems to me that there should be an easier way to get text
> on a screen in response to pressing a button. Any hints? Thanks!
>
> Marlene
>
> 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?")
> yesWindow = FXHorizontalFrame.new(self, :opts =>
> FRAME_GROOVE|LAYOUT_FILL_X)
> yesLabel = FXLabel.new(yesWindow,"Yes")
> yesWindow.hide
> puts "window shown?" + yesWindow.shown?.to_s
> hearButton.connect(SEL_COMMAND) do |sender,sel, data|
> yesWindow.create
> 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
>
>
> _______________________________________________
> fxruby-users mailing list
>
fxruby-users@...
>
http://rubyforge.org/mailman/listinfo/fxruby-usersHi,
You needed a call to self.recalc...
Best regards,
Philippe Lang
------------
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?")
yesWindow = FXHorizontalFrame.new(self, :opts =>
FRAME_GROOVE|LAYOUT_FILL_X)
yesLabel = FXLabel.new(yesWindow,"Yes")
yesWindow.hide
puts "window shown?" + yesWindow.shown?.to_s
hearButton.connect(SEL_COMMAND) do |sender,sel, data|
#yesWindow.create NOT NEEDED
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
_______________________________________________
fxruby-users mailing list
fxruby-users@...
http://rubyforge.org/mailman/listinfo/fxruby-users