[python-win32] accessing application object from OnConnection method in another Class

Graeme Glass graemeglass at gmail.com
Thu Sep 30 22:09:43 CEST 2004


If you look at the example demo "ExcelAddin" that come with win32all, 

def OnConnection(self, application, connectMode, addin, custom):
     self.appHostApp = application
     btnMyButton = self.toolbarButton =
DispatchWithEvents(btnMyButton, ButtonEvent)

the OnConnection method gets an instance of "application" , it also
registers btnMyButton to call the class ButtonEvent when the button is
click.

My question is how can i pass a refrence of "application" to
ButtonEvent class so that it can access "application" when the button
is click?

I have tried ever way i can think of: ie: 

btnMyButton = self.toolbarButton = DispatchWithEvents(btnMyButton,
ButtonEvent(ref))

self.appHostApp = application
self.appHostApp(ref)
btnMyButton = self.toolbarButton = DispatchWithEvents(btnMyButton,
ButtonEvent(self.appHostApp))

to name a few. I have also spent some time in the MSDN and Google and
still am confused. Have ordered Marks book "Python programming on
win32" but it will only be here in 10 days (i count the minutes). so
if anyone has any ideas in the interim, would be very much
appreciated.

Thanks,

Graeme


More information about the Python-win32 mailing list