#!/usr/local/bin/entity
<app>
<tcl>
puts [list hello, world]
</tcl>
</app>
The message "hello, world" is printed to stdout while
entity parses the file, that is -- only once.
default-lang="tcl"
in the tag <app> --
<app default-lang="tcl">
tcl separated by a colon --
tcl:my_handler
hello is bound to the event onkeypress.
#!/usr/local/bin/entity
<app default-lang="tcl">
<window title="simple" onkeypress="hello">
<label text="hello"/>
<tcl>
proc hello args {
puts [list hello, world]
}
</tcl>
</window>
</app>
#!/usr/local/bin/entity
<app default-lang="tcl">
<window title="entry">
<entry name = "fred" onenter = "dump"/>
<tcl>
namespace import ::Entity::*
proc dump args {
puts [get_attr entry.fred text]
}
</tcl>
</window>
</app>
namespace eval namespace7 {
namespace import ::Entity::*
proc dump args {
puts [get_attr entry.fred text]
}
}
where namespace7 could be an arbitrary name
chosen by entity. Note that importing Entity::*
wouldn't work because there's no namespace Entity
within the namespace7.
Entity always uses the proper namespace when calling event handlers. Calling the event handler of the previous example would actually be accomplished like this: (where path is the path of the calling node, see the reference)
namespace eval namespace7 {
dump path
}
This should be kept in mind when accessing elements of
different namespaces. The usage of global variables is
deprecated (as always). To share variables between different
procs the tcl variable should be used:
#!/usr/local/bin/entity
<app default-lang="tcl">
<tcl>
variable pi 3.1415927
proc dump_pi args {
variable pi
puts $pi
}
</tcl>
</app>