any way to keep a dialog box inside its parent, instead of centered on the
screen?
require ''rubygems''
require ''wx''
include Wx
class MyFrame < Frame
def initialize()
super(nil,-1,''Wristband Manager'',:size => [400,600])
@my_panel = Panel.new(self)
@mybutton = Button.new(self,-1,''click'')
evt_button(@mybutton) {onclick}
show
end
def onclick
diagYesno = MessageDialog.new(self,''are you
sure'',''Process Request'',YES_NO)
case diagYesno.show_modal
when Wx::ID_YES
yesno = ''Yes''
when Wx::ID_NO
yesno = ''No''
end
puts yesno
end
end
class MyApp < App
def on_init
frame1 = MyFrame.new
end
end
### Main Logic
MyApp.new.main_loop()
_______________________________________________
wxruby-users mailing list
wxruby-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/wxruby-users
hi On 26/07/2010 23:07, Bruce Loving wrote:> any way to keep a dialog box inside its parent, instead of centered on > the screen?Try calling centre_on_parent() - or center_on_parent(), if you''re that way inclined Dialog inherits this method from Wx::Window cheers alex
You will need to do this, before you call show_modal, as show_modal will open the dialog, and wait for a User Response, before returning control back to your program, so just after the creation of your Dialog Object, you would call #centre_on_parent() or #center_on_parent(). On Mon, Jul 26, 2010 at 6:35 PM, Alex Fenton <alex at pressure.to> wrote:> hi > > > On 26/07/2010 23:07, Bruce Loving wrote: > >> any way to keep a dialog box inside its parent, instead of centered on the >> screen? >> > > Try calling centre_on_parent() - or center_on_parent(), if you''re that way > inclined > > Dialog inherits this method from Wx::Window > > cheers > alex > > > _______________________________________________ > wxruby-users mailing list > wxruby-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/wxruby-users >-- Mario Steele Lieutenant Commander 3 XO - Geo 99 XO - STO IFT Fleet Chief Engineer - Second Life http://www.trekfederation.com -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/wxruby-users/attachments/20100727/b7d490b2/attachment.html>
hm, ok, read the docs, but it still doesnt center on parent
also, how come button fills whole frame?
require ''rubygems''
require ''wx''
include Wx
class MyFrame < Frame
def initialize()
super(nil,-1,''The Rabbit Hole'',:size => [300,300])
@diagYesno = MessageDialog.new(self,''are you
sure'',''White Rabbit
asks'',YES_NO)
@diagYesno.center_on_parent(BOTH)
#@my_panel = Panel.new(self)
@mybutton = Button.new(self,-1,''Drink Me'',:pos
=>[2,2],:size => [30,20])
evt_button(@mybutton) {onclick}
show
end
def onclick
case @diagYesno.show_modal
when Wx::ID_YES
yesno = ''Yes''
when Wx::ID_NO
yesno = ''No''
end
puts yesno
end
end
class MyApp < App
def on_init
frame1 = MyFrame.new
end
end
### Main Logic
MyApp.new.main_loop()
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://rubyforge.org/pipermail/wxruby-users/attachments/20100727/f3a7ced8/attachment.html>