Page 1 of 1

Disable/Enable macro in script

Posted: Tue Jan 24, 2012 6:50 pm
by eatmeimadanish
Does anyone know of a way to enable or disable a folder or macro inside of a python script in EG?

So far eg.plugins.EventGhost.DisableItem(XmlIdLink(1130)) wont work because XmlIDLink is not defined in the script. This would make designing triggers far easier if I could do this in one piece of code.

Re: Disable/Enable macro in script

Posted: Mon Jan 30, 2012 4:41 am
by hotbuddha
Check out the code in EventGhost\eg\Classes\UndoHandler\ToggleEnable.py

I used one of the classes in UndoHandler in the RCAware plugin, to paste an XML document into the config tree after plugin installation:

Code: Select all

            if self.firstLoad:
                try:
                    xmlFile = open(os.path.join(self.pluginDir, "macros.xml"), "r")
                    xmlString = xmlFile.read()
                    xmlFile.close()
                    wx.TheClipboard.Open()
                    wx.TheClipboard.SetData(wx.TextDataObject(xmlString))
                    wx.TheClipboard.Close()
                    eg.document.selection = eg.document.selection.parent
                    [b]eg.UndoHandler.Paste(eg.document).Do(eg.document.selection)[/b]
                except:
                    pass
You should be able to figure out how to get the TreePosition object to the node you want to enable/disable (see EventGhost\eg\Classes\TreeItem.py, looks like GetAllItems() may be useful).

Re: Disable/Enable macro in script

Posted: Tue Feb 07, 2012 5:13 pm
by eatmeimadanish
Wow thanks, I was totally going down a different path, but that makes much more sense. I wonder if this could be a feature request inside of EG for a an enhancement. I know that if I could easily script enable or disable based on payload data, it would make web based settings pages far easier to manage and simpler to control programmaticly then tons of macros.

Re: Disable/Enable macro in script

Posted: Tue Feb 07, 2012 5:14 pm
by eatmeimadanish
Or maybe I will just write my own update... :)

Re: Disable/Enable macro in script

Posted: Tue Feb 07, 2012 11:33 pm
by eatmeimadanish
I noticed that this method would only update the XML file, but not sure it would trigger the actual action.