[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Jacques Garrigue <garrigue@k...> |
| Subject: | Re: Scrolling canvases in LablTk 3.00 |
> 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 <A HREF=http://wwwfun.kurims.kyoto-u.ac.jp/~garrigue/>JG</A>