summaryrefslogtreecommitdiffstats
path: root/otherlibs/labltk/example/calc.ml
diff options
context:
space:
mode:
authorJacques Garrigue <garrigue at math.nagoya-u.ac.jp>2000-04-03 07:57:36 +0000
committerJacques Garrigue <garrigue at math.nagoya-u.ac.jp>2000-04-03 07:57:36 +0000
commit151d3466468edb1ecc98d9475abc90ca14418f8f (patch)
tree30c9c43e63b0db2c27f1ab9b7fcc771fa2c4bc5c /otherlibs/labltk/example/calc.ml
parented84ab0c2c15dce7ea022ada7801a70825be27c7 (diff)
change Canvas, pour des labels/ordre plus naturels
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@3029 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'otherlibs/labltk/example/calc.ml')
-rw-r--r--otherlibs/labltk/example/calc.ml25
1 files changed, 13 insertions, 12 deletions
diff --git a/otherlibs/labltk/example/calc.ml b/otherlibs/labltk/example/calc.ml
index c9657dfa6..18d0c7936 100644
--- a/otherlibs/labltk/example/calc.ml
+++ b/otherlibs/labltk/example/calc.ml
@@ -44,17 +44,17 @@ class calc () = object (calc)
method set = Textvariable.set variable
method get = Textvariable.get variable
- method insert s = calc#set to:(calc#get ^ s)
+ method insert s = calc#set (calc#get ^ s)
method get_float = float_of_string (calc#get)
method command s =
if s <> "" then match s.[0] with
'0'..'9' ->
- if displaying then (calc#set to:""; displaying <- false);
+ if displaying then (calc#set ""; displaying <- false);
calc#insert s
| '.' ->
if displaying then
- (calc#set to:"0."; displaying <- false)
+ (calc#set "0."; displaying <- false)
else
if not (mem_string elt:'.' calc#get) then calc#insert s
| '+'|'-'|'*'|'/' as c ->
@@ -62,11 +62,11 @@ class calc () = object (calc)
begin match op with
None ->
x <- calc#get_float;
- op <- Some (List.assoc key:c ops)
+ op <- Some (List.assoc c ops)
| Some f ->
x <- f x (calc#get_float);
- op <- Some (List.assoc key:c ops);
- calc#set to:(string_of_float x)
+ op <- Some (List.assoc c ops);
+ calc#set (string_of_float x)
end
| '='|'\n'|'\r' ->
displaying <- true;
@@ -75,7 +75,7 @@ class calc () = object (calc)
| Some f ->
x <- f x (calc#get_float);
op <- None;
- calc#set to:(string_of_float x)
+ calc#set (string_of_float x)
end
| 'q' -> closeTk (); exit 0
| _ -> ()
@@ -99,16 +99,17 @@ class calculator :parent = object
initializer
let buttons =
- Array.map fun:
- (List.map fun:
+ Array.map f:
+ (List.map f:
(fun text ->
Button.create :text command:(fun () -> calc#command text) frame))
m
in
Label.configure textvariable:variable label;
- calc#set to:"0";
- bind parent events:[`KeyPress] fields:[`Char]
- action:(fun ev -> calc#command ev.ev_Char);
+ calc#set "0";
+ bind events:[`KeyPress] fields:[`Char]
+ action:(fun ev -> calc#command ev.ev_Char)
+ parent;
for i = 0 to Array.length m - 1 do
Grid.configure row:i buttons.(i)
done;