From: Hidetoshi NAGAI Date: 2005-11-09T01:08:35+09:00 Subject: Re: Scheudle display From: "csjasnoch@wisc.edu" Subject: Scheudle display Date: Tue, 8 Nov 2005 04:47:11 +0900 Message-ID: <1131392781.003984.245710@z14g2000cwz.googlegroups.com> > Currently I am just using Tk listbox that displays like > : > > It would be nice if I could generate a 24 hour clock (meaning a circle > with 24 divisions) and fill it in where the appropriate action is. Maybe, I don't understand your problem. Can the following script give you a hint to solve the problem ? --------------------------------------------------------- require 'tk' c = TkCanvas.new(:width=>400, :height=>400, :scrollregion=>[-200, -200, 200, 200]).pack oval = TkcOval.new(c, [-150, -150], [150, 150], :fill=>'white') TkcOval.new(c, [-5, -5], [5, 5], :fill=>'black') def coords_to_time(x, y) return ((y < 0)? [0, 0]: [12, 0]) if x == 0 hh, mm = (Math.atan(-y/-x.to_f) + Math::PI/2).divmod(Math::PI/12) [((x >= 0)? hh.to_i: (hh.to_i + 12)), (60 * mm).to_i] end l = TkLabel.new(:text=>'00:00').pack oval.bind('Motion', proc{|x, y| l.text = '%02d:%02d' % coords_to_time(c.canvasx(x), c.canvasy(y)) }, '%x %y') Tk.mainloop --------------------------------------------------------- -- Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)