If you want to get a little more complicated, you could do this dance:
1. Write the script so that when it's run the first time, it rewrites the
script node to define its name:
p.b = f'script_name = {p.h}\n' + p.b
2. Run the script using CTRL-B.
3. There has to be some code to check to see if script_name has been
defined. If it is, the script would output your log message using its
name. Otherwise, it outputs no nome.
4. When the script runs, it logs using the name if it was already defined.
This would let you use the same button for many different trees. OTOH, it
does add more complication, so probably it's just easiest to embed the name
directly.
On Monday, April 20, 2020 at 11:44:51 AM UTC-4, Edward K. Ream wrote:
>
>
>
> On Sun, Apr 19, 2020 at 11:01 AM Matt Wilkie <[email protected]
> <javascript:>> wrote:
>
>> How do I get the name/position of a script bound to a button, regardless
>> of what node is currently selected when the button is used?
>>
>
> You can right-click the button itself, then choose "Goto Script".
>
> If you want to do that programmatically, you will have to study the
> horrible code in mod_scripting.py. Searching for 'Goto Script' yields
> qtFrame.QtIconBarClass.setCommandForButton, which includes a gnx that could
> then be used to find a vnode, and its headline.
>
> The goal is make it clear in the Log pane where the status message is
>> coming from (the script).
>>
>
> I agree with Thomas that having the script itself print the message looks
> simplest.
>
> Edward
>
--
You received this message because you are subscribed to the Google Groups
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/leo-editor/8cf83ca5-f587-490f-b5c2-03201c611e58%40googlegroups.com.