Windows, COM, and SigmaPlot

tla tla_member at newsranger.com
Thu Apr 5 22:55:52 EDT 2001


I'm having difficulty getting COM to work with SigmaPlot.  I'm using Windows NT,
SigmaPlot 6.1 and I've run MakePy for SigmaPlot 6.1 and Excel from the Pythonwin
Tools menu.

0) To get started I enter:
>>> from win32com.client import Dispatch
>>> sp = Dispatch("SigmaPlot.Application")
>>> sp.Visible = 1
(ok so far - SigmaPlot appears)

1) My main difficulty is that some commands which I think should require
parentheses don't seem to allow them.  So I think I should type
>>> sp.Notebooks.Add()
but, when I do this I get the error
Traceback (innermost last):
File "<pyshell#7>", line 1, in ?
sp.Notebooks.Add()
File "D:\Program Files\python\win32com\client\dynamic.py", line 141, in __call__
return
self._get_good_object_(apply(self._oleobj_.Invoke,allArgs),self._olerepr_.defaultDispatchName,None)
com_error: (-2147352573, 'Member not found.', None, None)

What's going on is odd: if I watch SigmaPlot as I type this in, as soon as I
type the "(" a Notebook appears.  Then when I type ")" and a <cr>, another
notebook appears and I get the error message.  So if I just enter the line
>>> sp.Notebooks.Add
I get a notebook with no error message.
This would be fine except when a function needs parameters I am not able to
enter the parameters.  By the way, the analogous problem doesn't occur with
Excel.  For Excel, I can enter the examples and everything works fine.

2) Not supper crucial, but if I enter
>>> from win32com.client import constants
I don't seem to get the SigmaPlot constants, but I do get Excel constants
>>> print constants.xlDiamond
2
>>> print constants.CT_GRAPHICPAGE
Traceback (innermost last):
File "<pyshell#10>", line 1, in ?
constants.CT_GRAPHICPAGE
File "D:\Program Files\python\win32com\client\__init__.py", line 72, in
__getattr__
raise AttributeError, a
AttributeError: CT_GRAPHICPAGE

Although I can see that this exists when i run combrowse.py.

3) Just out of curiosity, I'm surprised that I can load data directly from NumPy
arrays into SigmaPlot
>>> vals = arange(0, pi, .3)
>>> spDataTable.PutData(vals, 1,1)
Is this something that someone wrote specifically for SigmaPlot.  I don't find
any reference to this ability, but it does seem to work.  Can I count on it
continuing to work?

4) And finally, to set a Cell's value, it seems I need to write:
>>> spDataTable.Cell(row, column, val)
instead of 
>>> spDataTable.Cell(row, column) = 1
as seems to work for Excel.  Do I just need to try both ways for everything, or
is this somehow systematic.

Thanks,
Tom






More information about the Python-list mailing list