Hi, Does anyone know how to detach controls from a panel or frame? What I want to do is click a button and redraw a new UI without the button. Is there any possible was to do this? Thank you for any help in advance. :D
on 10.04.2008 03:56
on 10.04.2008 04:08
Nilu Senevi wrote: > Does anyone know how to detach controls from a panel or frame? What I > want to do is click a button and redraw a new UI without the button. If your layout is controlled by sizers, use Sizer#remove or Sizer#detach, then call destroy on the removed Window. You may need to call Sizer#layout afterwards to adjust to the new window contents. If not, just call Window#destroy. It's one of the rare occasions that calling this directly is useful. http://wxruby.rubyforge.org/doc/window.html#Window_destroy http://wxruby.rubyforge.org/doc/sizer.html#Sizer_remove alex
on 10.04.2008 07:40
Another way, if your planning to re-use the control, is to call
hide()/show(false) on the button, then call layout() on the window, to
re-draw the controls. Hide will make it invisible, so that it's no
longer
there.
An example:
begin
require 'rubygems'
rescue LoadError
end
require 'wx'
class MyFrame < Wx::Frame
include Wx
def initialize(*args)
super
@button1 = Button.new(self,1000,"Hide Me!")
@button2 = Button.new(self,1001,"Show other button")
hbox = BoxSizer.new(HORIZONTAL)
hbox.add(@button1,1,ALL)
hbox.add(@button2,1,ALL)
set_sizer(hbox)
evt_button(1000) do
@button1.show(false)
layout()
end
evt_button(1001) do
@button1.show(true)
layout()
end
end
end
Wx::App.run do
MyFrame.new(nil,:title=>"Button Hiding
Example",:size=>[200,60]).show()
end
L8ers,
on 10.04.2008 10:59
Thank you Mario for the quick reply. I will try it out:D