This question occurred to me when I had to make changes to the source code of a Tk. Where, there was only one proc
when invoked brought the result to aframe
widget.
However, due to improvements in the internal code, this has affected the GUI [Tk]. In the way you presented the results, you now do nothing but press a button that calls the second proc
. And this second proc
was put in the first, since the ready code made me see only this solution.
However, the two are linked. And what came to mind was that if possible I could invoke this second internal proc
from within the first proc
, ie the first has to invoke the second and everything is resolved.
Example:
proc one {} { # your code here! proc two {} { # your code here! } } pack [button .bt1 -text "Click-Me" -command { one }] pack [button .bt2 -text "Click-Me" -command { two }]
Around the illustration of the example, I will call both procedures/processes at the same time, just once, clicking the one button
, since the first gives me the opening of the frame
widget, then I will pass the call to the second. This second brings me random results with each click on button
two.
Maybe what I’m looking for is to simulate clicking the second button when pressed the first, I think it would work too.
But I cannot ignore the first, as it contains instructions that serve the second.
Advertisement
Answer
Your example code is defining a proc from within another. This is possible, but the new proc will still be created in the current namespace, or in the specified namespace if the name contains namespace qualifiers. This means that it is also accessible from outside of the enclosing proc.
To invoke the proc, just put the proc name and any arguments as you would for any command:
proc one {} { # your code here! proc two {} { # Proc two definition } # Proc two invocation two }