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.
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.
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
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,
Thank you Mario for the quick reply. I will try it out:D
Thanks Alex. I will try it out
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs