caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Camltk and Font_Size
@ 2003-03-20 14:45 Vincent Poirriez
  2003-03-20 16:08 ` Jun P. FURUSE
  0 siblings, 1 reply; 2+ messages in thread
From: Vincent Poirriez @ 2003-03-20 14:45 UTC (permalink / raw)
  To: caml-list; +Cc: vincent.poirriez

Hello,

 a simple question concerning the Camltk API.

 What is the simplest way to specify the size of the font used in a widget.

 I've found Font_Size but when I try to use it, it raises Invalid_argument("Font_Size")

I'll appreciate any indication.

 Vincent

Below the program helloworld.ml modified from the examples_camltk directory of the distribution

open Camltk;;            (* Make interface functions available *)

let top = opentk ();;   (* Initialisation of the interface *)
(* top is now the toplevel widget *)

(* Widget initialisation *)
let b = Button.create top 
          [Text "foobar"; 
           Command (function () -> 
                      print_string "foobar"; 
                      print_newline();
                      flush stdout)];;
(* b exists but is not yet visible *)

let q = Button.create top 
          [Text "quit"; Font_Size 12;
           Command closeTk];;
(* q exists but is not yet visible *)

pack [b; q][] ;;           (* Make b visible *)
mainLoop() ;;           (* User interaction*)

-- 
courriel: vincent.poirriez@univ-valenciennes.fr  
tel: (33)[0]3 27 51 19 53 
Université de Valenciennes et du Hainaut-Cambrésis - Le Mont Houy
F-59313 Valenciennes cedex 9 - FRANCE
http://www.univ-valenciennes.fr/LAMIH/ROI/poirriez

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Caml-list] Camltk and Font_Size
  2003-03-20 14:45 [Caml-list] Camltk and Font_Size Vincent Poirriez
@ 2003-03-20 16:08 ` Jun P. FURUSE
  0 siblings, 0 replies; 2+ messages in thread
From: Jun P. FURUSE @ 2003-03-20 16:08 UTC (permalink / raw)
  To: Vincent.Poirriez; +Cc: caml-list

Hello,
 
>  a simple question concerning the Camltk API.
> 
>  What is the simplest way to specify the size of the font used in a widget.
> 
>  I've found Font_Size but when I try to use it, it raises Invalid_argument("Font_Size")
> 
> I'll appreciate any indication.

> let q = Button.create top 
>           [Text "quit"; Font_Size 12;
>            Command closeTk];;
> (* q exists but is not yet visible *)

This is since Font_Size is not a valid option for the button widget.
What you should do is:

     1. define a font using Font_Size 12:

	let font = Font.create [Font_Size 12]

     2. At the creation of the button, specify this font using Font option:

         let q = Button.create top 
           [Text "quit"; Font font;
            Command closeTk];;
        	
The options of Tk commands are gathered and form a huge type 
Camltk.options in Camltk. But a widget class does not take all of them
as valid options, but only a small subset. The validity of tk options
is tested at run-time, and if an invalid option is found, Invalid_argument
exception is raised.

In LablTk, this problem is almost resolved, by replacing option lists
to labeled optional arguments.

To find out which options are valid for a widget class is either

   * look the source code: otherlibs/labltk/Widgets.src defines the subsets
     of valid options for each widget class.

   * tk command manual

   * or, look at the type of the corresponding LablTk function, which
     details the set of possible options.

--
Jun

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2003-03-20 16:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-03-20 14:45 [Caml-list] Camltk and Font_Size Vincent Poirriez
2003-03-20 16:08 ` Jun P. FURUSE

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).