> -----Original Message-----
> From: Stef Pillaert [mailto:[EMAIL PROTECTED]]
> 
> It is a solution (and I realise that in a lot of Tcl/Tk 
> tutorials this way of coding is recommended ;-), but I 
> hesitate to write proc's for every button, where the 
> actual command is very simple and short : in those 
> cases I prefer to keep it in the button-command itself. 
> I even have to admit that I often have very long and 
> complex button-commands (Why would I write  a procedure 
> for it, since I'm not going to use it elsewhere, and 
> Vtcl shows me the command nice and clean in one window, 
> the same as if it where a procedure). 

The reason that you should write procs is that the button's -command script
cannot be byte-compiled.  You may only call the command script from one
place, but it will run faster if you use a proc.

Tk must dynamically build the command string to include any % substitutions
(see the [bind] man page), eliminating the possibility of byte-compiling.
Disclaimer:  I don't recall if command scripts that without % substitutions
get byte-compiled.  A little experimenting on my part indicates that they do
not, but there is probably a more authoritative source.

Bob
-- 
Bob Techentin                        [EMAIL PROTECTED] 
Mayo Foundation                                 (507) 538-5495 
200 First St. SW                            FAX (507) 284-9171
Rochester MN, 55901  USA            http://www.mayo.edu/sppdg/ 


_______________________________________________
vtcl-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/vtcl-user

Reply via email to