From: Fabien Fleutot <fabien.fleutot@inria.fr>
To: caml-list@inria.fr
Subject: Scrolling canvases in LablTk 3.00
Date: Thu, 17 Aug 2000 11:57:46 +0200 [thread overview]
Message-ID: <200008170957.e7H9vkw07841@faure.inria.fr> (raw)
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()
------------------------------------
The translator in the scrollbar uses 100% of the bar's width, instead of
(300/2560) = 11.7%.
using 'pack' intead of 'place' doesn't change amything, except that if I
suppress the 'geometry_set', it creates a 2560 pixels wide window.
Does anybody know what's wrong with that piece of code ?
next reply other threads:[~2000-08-18 11:14 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-08-17 9:57 Fabien Fleutot [this message]
2000-08-21 0:00 ` Jacques Garrigue
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200008170957.e7H9vkw07841@faure.inria.fr \
--to=fabien.fleutot@inria.fr \
--cc=caml-list@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox