Tool Share: Finally cracked it! Create Macros from templates with variables and clipboard importing!

If you have macros or EventGhost Configuration Tree items you wish to share this is the place to do it.
User avatar
kgschlosser
Site Admin
Posts: 5028
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Tool Share: Finally cracked it! Create Macros from templates with variables and clipboard importing!

Post by kgschlosser » Sun Nov 24, 2019 12:36 am

ok so you see that eg.document.root in the code I gave you.. that is the tree item for the root of the tree, It is a class instance and has many attributes and functions. they can b viewed if you open Classes\RootItem.py

make sure you loo at the parent class as well, Classes\TreeItem.py

the key thing here is that any children of that tree item are stored in that tree item..

Code: Select all

def iter_children(parent, indent=''):
    print indent + parent.xmlTag + ':', parent.GetLabel()    
    for child in parent.childs:
        iter_children(child, indent + '    ')

iter_children(eg.document.root)
If you like the work I have been doing then feel free to Image

dan Edens
Experienced User
Posts: 91
Joined: Mon Sep 24, 2018 7:57 pm

Re: Tool Share: Finally cracked it! Create Macros from templates with variables and clipboard importing!

Post by dan Edens » Mon Nov 25, 2019 8:21 pm

So given that it would probably be a huge project and largely a waste of effort, is there anyway to reverse "copy as python" and convert the python back to xml?
just curious, not something I actually need to do.
I know i could build a case by case interpreter but hoping there is another hidden gem like import by undo handler.

(Which I'm currently expanding as a way to add items remotely to my sudo-headless second windows machine woot)

User avatar
kgschlosser
Site Admin
Posts: 5028
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Tool Share: Finally cracked it! Create Macros from templates with variables and clipboard importing!

Post by kgschlosser » Mon Nov 25, 2019 10:05 pm

that depends.. how you look at it..

so when you select an item in the tree to copy it as python.. you can use the following and it is going to give you the xml version of it.

Code: Select all

print document.selection.GetXmlString()

if you know if an item is a plugin or an action you can get the arguments being passed.

Code: Select all

print document.selection.GetArguments()

you can also set the arguments if you want

Code: Select all

eg.actionThread.Func(eg.document.selection.SetArguments)(new_arguments)
If you like the work I have been doing then feel free to Image

dan Edens
Experienced User
Posts: 91
Joined: Mon Sep 24, 2018 7:57 pm

Re: Tool Share: Finally cracked it! Create Macros from templates with variables and clipboard importing!

Post by dan Edens » Mon Nov 25, 2019 10:07 pm

That's perfect thanks.

Post Reply