Hello KG,
I have now a solution, thank you for the hints!
I was a bit lucky since in my plugin implementation I had already implemented two useful functions:
- addActionName: keeps an updated list of names for defined actions
- getAllActionNames: returns the list
So with this and your hints it works pretty well. I have set the limit to allow only one defined action of the specific kind so the code looks like this (a bit pseudo) and is part of the Configure section of the action:
Code: Select all
def Configure(
self,
actionName = "Give this action a name",
etc,
etc
):
plugin = self.plugin
panel = eg.ConfigPanel(self)
p = plugin.getAllActionNames()
if len(p) > 0:
if actionName != p[0]:
eg.PrintNotice('You have already defined an action of this kind')
event = wx.PyCommandEvent(wx.EVT_BUTTON.typeId, panel.dialog.buttonRow.cancelButton.GetId())
wx.PostEvent(panel.dialog.buttonRow.cancelButton, event)
mySizer_1 = wx.GridBagSizer(10, 10)
mySizer_2 = wx.GridBagSizer(5, 5)
mySizer_3 = wx.GridBagSizer(10, 10)
etc, etc
In my case I wanted to restrict it to allow only one defined action of this particular kind but it is of course possible to allow another number by changing the code a bit. The good part is that no action is created in the tree if you select to add action. If you select add macro, the left over is just an empty harmless macro that can be easily deleted manually.
Besides, it allows you to create one action the first time and you can edit it as many times you like. If I delete it, the list will be empty and I can create a new one again.
Thanks,