Getting Application object in Python 2005-03-28 - By Bernard Lebel
Back The issue was brought up not later than... today!
import win32com Application = win32.client.Dispatch( 'XSI.Application' ) xsi = Application.application
xsi.logmessage( 'hello!' ) xsi.logmessage( xsi.classname( xsi.selection(0) ) )
Setting module globals never really worked well for me, so instead I instantiate the Application object in every module I import.
Cheers Bernard
Luke Emrose wrote: > Hi there, > > I think from memory that this may have been discussed before but I > cannot remember if a solution was ever found. > > At the moment in Python, if I use modules I have to pass in the > Application object from the main piece of code in order for everything > to work as expected. > > Originally I thought I could use: > > * from win32com import client > ap = client.Dispatch('XSI.Application')* > > which for most things seems to work, but for some strange reason doesn't > seem to work for the ClassName and GetValue commands. > > At the moment this is driving me nutz, as I have a very large module > library for a large tool I'm building and for some stupid reason if I > have to pass in the Application object to an object more than two levels > deep it stops working (i.e, *module1.module2.module3.ap = Application* > doesn't work but *module1.module2.ap = Application* does, huh!!!!). > > Surely there is an easier and foolproof way to get the Application > object without having to pass it in from one place (which sucks), > especially since this is completely painless in every other language > that is supported (i.e. C++, JavaScript and VBScript). > > thanks, > > Luke
--- Unsubscribe? Mail Majordomo@(protected) with the following text in body: unsubscribe xsi
|
|