From: Gerald Murray Date: 2006-01-25T07:28:12+09:00 Subject: Re: ruby and Tk:- Menu's calling other widgets An example is in the ruby source distribution: ruby-1.8.4/ext/tk/sample/demos-en/widget best regards, Gerald If you only want buttons you might try: require 'tk' #= windowmaker - create button array, each pops a window #global $button[] holds buttons defined by this method #parm root the frame which is to hold the button #parm b_text the button text; also becomes toplevel title #parm t_place String, "0x0+100+200", toplevel window size, place #parm init_color String, "#000000", 2 hex digits for red, green, blue # def windowmaker(root,b_text,t_place,init_color="#000000") toplevelwindow = -1 b = TkButton.new(root, 'text'=>b_text, 'command'=> proc { toplevelwindow = TkToplevel.new(root, { 'title'=> "#{b.text}", 'geometry'=>t_place, 'bg'=>init_color }) } ).pack('expand'=>'yes','fill'=>'x') $buttons.push [b,toplevelwindow] end r = TkRoot.new f = TkFrame.new(r) $buttons = [] # each entry holds [button,toplevel] windowmaker(f,"red","100x100","#ff0000") windowmaker(f,"white","200x200","#ffffff") windowmaker(f,"blue","300x300","#0000ff") windowmaker(f,"0x400+100+100","dummy") # re-configured: # show reconfiguration of the last button $buttons[-1][0].configure('command'=>proc{r.destroy; exit},'text'=>"Quit") f.pack Tk.mainloop