From: Armin Roehrl Date: 2001-10-31T07:17:26+09:00 Subject: [ruby-talk:23871] best way to group objects in Ruby-Tk? Hi, What is the best way to group objects together? I want to manipulate a group of lines/circles/text and move them as if it were a (single) widget. For example I have rectangles and text in each rectangle. To move that around I could move the rectangle and the text, but I would have to code the "interconnection" between the two items (if I move the rectangle by 20,20 I need to move the text by 20, 20 and vice versa). Can't Ruby-Tk do that work for me? Does Ruby-Tk allow me to "build" a group and then move the entire group? A bit like moving a background frame around; moving a sprite around; Not speaking Japanese, but searching for TkcWindow I first thought that TkcWindow might be the best way todo it as it allows embedding of other widgets. http://www2s.biglobe.ne.jp/~Nori/ruby/ja/tk-faq/rtkFAQ-11.html But I didn't get it to work; Probably I don't know what TkcWindows are good for; #!/usr/local/bin/ruby require 'tk' class D def initialize @root = TkRoot.new{ title 'Tk fun' } canvas = TkCanvas.new(@root) canvas.pack win = TkcWindow.new(canvas, 1, 1, {'width'=>200, 'height'=>'200'}) win.pack(canvas) canvas2=TkCanvas.new(win) canvas2.pack t=TkcRectangle.new(canvas2, 5, 5, 50,50) t.pack(canvas2) win.move(100,100) #-> should move the Rectangle, too, but doesn't. end end t=D.new Tk.mainloop ---- thanks to all for your time, Armin ----------------------------------------------- Armin Roehrl, http://www.approximity.com "The best way to predict the future is to invent it." --Alan Kay