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()
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().
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()