From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id LAA23949 for caml-red; Mon, 21 Aug 2000 11:04:37 +0200 (MET DST) Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id BAA22345 for ; Mon, 21 Aug 2000 01:58:38 +0200 (MET DST) Received: from kurims.kurims.kyoto-u.ac.jp (kurims.kurims.kyoto-u.ac.jp [130.54.16.1]) by nez-perce.inria.fr (8.10.0/8.10.0) with ESMTP id e7KNwYP20493; Mon, 21 Aug 2000 01:58:35 +0200 (MET DST) Received: from tet.kurims.kyoto-u.ac.jp (isdnppp3.kurims.kyoto-u.ac.jp [130.54.16.104]) by kurims.kurims.kyoto-u.ac.jp (8.9.3/3.7W) with ESMTP id IAA00362; Mon, 21 Aug 2000 08:58:25 +0900 (JST) Received: from localhost (localhost [127.0.0.1]) by tet.kurims.kyoto-u.ac.jp (8.9.3/8.9.3) with ESMTP id JAA01400; Mon, 21 Aug 2000 09:00:58 +0900 (JST) (envelope-from garrigue@kurims.kyoto-u.ac.jp) To: fabien.fleutot@inria.fr Cc: caml-list@inria.fr Subject: Re: Scrolling canvases in LablTk 3.00 In-Reply-To: Your message of "Thu, 17 Aug 2000 11:57:46 +0200" <200008170957.e7H9vkw07841@faure.inria.fr> References: <200008170957.e7H9vkw07841@faure.inria.fr> X-Mailer: Mew version 1.93 on Emacs 20.4 / Mule 4.0 (HANANOEN) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-Id: <20000821090058V.garrigue@kurims.kyoto-u.ac.jp> Date: Mon, 21 Aug 2000 09:00:58 +0900 From: Jacques Garrigue X-Dispatcher: imput version 980905(IM100) Sender: weis@pauillac.inria.fr > I can't figure how to add a scrollbar to a canvas; here is my code: > > ------------------------------------ > > open Tk > open Printf > > let _ = > let win = openTk() in > let c = Canvas.create win ~width:2560 ~height:100 in > let s = Scrollbar.create win ~orient:`Horizontal in > > (* draw clearer and clearer gray strips on the canvas. *) > for i = 0 to 255 do > let color = `Color (sprintf "#%02x%02x%02x" i i i) in > ignore(Canvas.create_rectangle c ~x1:(i*10) ~x2:(i*10+10) ~y1:0 ~y2:99 > ~fill:color) > done ; > > Canvas.configure c ~xscrollcommand:(Scrollbar.set s) ; > Scrollbar.configure s ~command:(Canvas.xview c) ; > > place c ~x:0 ~y:0; > place s ~x:0 ~y:100 ~relwidth:1.; > Wm.geometry_set win "300x125" ; > mainLoop() > > ------------------------------------ You should use the ~scrollregion option: Canvas.create win ~width:300 ~height:100 ~scrollregion:(0,0,2560,100) Then you don't need the Wm.geometry_set anymore. --------------------------------------------------------------------------- Jacques Garrigue Kyoto University garrigue at kurims.kyoto-u.ac.jp JG