From: nagai@... Date: 2002-02-06T11:29:21+09:00 Subject: Re: Progress with Ruby/Tk Hi, From: Peter Hickman Subject: Progress with Ruby/Tk Date: Tue, 5 Feb 2002 19:34:47 +0900 Message-ID: <3C5FB53D.4000801@semantico.com> peter> What I want is. peter> peter> +-------------------+ peter> | | peter> | MESSAGE | peter> | | peter> | +---------------+ | peter> | | A | | peter> | +---------------+ | peter> | +---------------+ | peter> | | B | | peter> | +---------------+ | peter> | +---------------+ | peter> | | C | | peter> | +---------------+ | peter> +-------------------+ For example, -------------------------------------------------------------- require 'tk' def v_dialog(title, btns, keys) top = TkToplevel.new{ title(title) } msg = TkMessage.new(top, keys).pack('side'=>'top', 'fill'=>'x', 'expand'=>true) v = TkVariable.new f = TkFrame.new(top).pack('side'=>'top', 'fill'=>'x', 'padx'=>7, 'pady'=>2) btns.each_with_index{|btn, idx| TkButton.new(f, 'text'=>btn, 'command'=>proc{v.value = idx + 1}) \ .pack('side'=>'top', 'fill'=>'x') } top.protocol('WM_DELETE_WINDOW', proc{v.value = 0}) f.focus begin top.grab v.wait ensure top.grab('release') top.destroy end v.to_i end msg = "This is a sample dialog. " + "It returns clicked button number " + "based on the order of 'btns' parameter." + "If the dialog is destroyed by window manager control, returns 0. " + "To control window size, give 'width' option." + "If you give options by hash parameter, " + "they are passed to the message widget on the dialog." b = TkButton.new{ text 'disp dialog' command proc{p v_dialog('dialog sample', ['Yes', 'No', 'Cancel'], 'text'=>msg, 'width'=>300)} pack } Tk.mainloop -------------------------------------------------------------- -- Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)