Sriram Sundararajan wrote:
I have a question on the excelAddin.py sample in the win32com\demos folder.
We create a Tool Bar, add a button to it,
btnMyButton = cbcMyBar.Controls.Add(Type=constants.msoControlButton,
Parameter="Greetings")
'register' the button with the ButtonEvent class,
btnMyButton=self.toolbarButton = DispatchWithEvents(btnMyButton,
ButtonEvent)
and set a couple of properties.
btnMyButton.Caption = "&Python"
btnMyButton.TooltipText = "Python rules the World"
In the OnClick event handler of the ButtonEvent class,
class ButtonEvent:
def OnClick(self, button, cancel):
1. How is the 'button' argument related to the actual button that was
clicked? It showed up as a PyIDispatch object when I tried printing
it.
2. Assuming there is more than one button that can be clicked, how
would I access some of the properties of the button instance that was
actually clicked by the user?
Thanks
Sriram
You can use win32com.client.Dispatch(button) to get a wrapped
object that exposes all the properties of the button.
This will allow you to access the Caption, TooltipText, or any
other property you need to identify the button.
Roger
_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32