Re: win32com ChartObject pythonwin vs idle



On Jul 31, 4:28 am, Tim Golden <m...@xxxxxxxxxxxxxxx> wrote:
sterling wrote:
I'm curious as to why the difference between IDLE and pythonWin when
using win32com.
opening an excel file, i've attempted to grab the chart information
out of the file.

commands like co = ChartObjects(1)  works in pythonWin but doesn't
work in IDLE.

however, on both co = chartobjects(1) works just fine.

I can't speak for IDLE vs PythonWin but in general
case-sensitivity of win32com stuff is related to
early vs late Dispatch. If you've explicitly generated
proxy modules for the Excel objects (via makepy,
EnsureDispatch or whatever) then those are Python
modules with case-sensitivity. If you're using dynamic
dispatch then Python is simply passing your attribute
name along to COM, which isn't case-sensitive, so either
case will work.

Not sure why IDLE vs PythonWin should make a difference
here, but maybe the above explanation sheds some light...

TJG

Thanks Tim. I'm wondering if it's an OS issues with Vista (I'm
strangly ashamed to admit that both my laptop and main computer are
running it).
I decided to try the same code on my main computer (do most of my work
on my laptop) and the exact same thing has happened: I can run it in
pythonwin and not idle.
I found that I can't even run Open (I must have been running open()
previously):
i.e.
import win32com.client
ex = win32com.client.Dispatch("Excel.Application")
wb = ex.Workbooks.Open("C:\Temp\SalesChart.xls")

Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
wb = ex.Workbooks.Open("C:\Temp\SalesChart.xlsx")
File "C:\Python25\Lib\site-packages\win32com\client\dynamic.py",
line 467, in __getattr__
if self._olerepr_.mapFuncs.has_key(attr): return
self._make_method_(attr)
File "C:\Python25\Lib\site-packages\win32com\client\dynamic.py",
line 295, in _make_method_
methodCodeList =
self._olerepr_.MakeFuncMethod(self._olerepr_.mapFuncs[name],
methodName,0)
File "C:\Python25\Lib\site-packages\win32com\client\build.py", line
297, in MakeFuncMethod
return self.MakeDispatchFuncMethod(entry, name, bMakeClass)
File "C:\Python25\Lib\site-packages\win32com\client\build.py", line
318, in MakeDispatchFuncMethod
s = linePrefix + 'def ' + name + '(self' + BuildCallList(fdesc,
names, defNamedOptArg, defNamedNotOptArg, defUnnamedArg, defOutArg) +
'):'
File "C:\Python25\Lib\site-packages\win32com\client\build.py", line
604, in BuildCallList
argName = MakePublicAttributeName(argName)
File "C:\Python25\Lib\site-packages\win32com\client\build.py", line
542, in MakePublicAttributeName
return filter( lambda char: char in valid_identifier_chars,
className)
File "C:\Python25\Lib\site-packages\win32com\client\build.py", line
542, in <lambda>
return filter( lambda char: char in valid_identifier_chars,
className)
UnicodeDecodeError: 'ascii' codec can't decode byte 0x83 in position
52: ordinal not in range(128)


but the exact same code works in PythonWin. Perhaps I will just find a
way to code everything I want in the older lowercase.
.



Relevant Pages

  • Re: win32com ChartObject pythonwin vs idle
    ... opening an excel file, i've attempted to grab the chart information ... commands like co = ChartObjectsworks in pythonWin but doesn't ... Is there any way to fix it such that IDLE works with ChartObject ...
    (comp.lang.python)
  • Re: ActiveState Python Together with "Regular" Python) ((DLE)
    ... PythonWin IDE instead of IDLE, all you needed to do was go to ... Is it possible to just disable the vanilla (IDLE) version? ... Install both. ...
    (comp.lang.python)
  • Re: Pylab Fails with Runtime Error on Win XP Under Python 2.4
    ... And -- I just noticed, it IS using tk for plotting, and IDLE is also ... I guess PythonWin is a download for another IDE than IDLE. ... Will modules be available like mathplotlib if I install it, or do I have to establish them for it? ... I'll look PythonWin once I get past the cmd operation. ...
    (comp.lang.python)
  • Re: ActiveState Python Together with "Regular" Python) ((DLE)
    ... PythonWin IDE instead of IDLE, all you needed to do was go to ... Is it possible to just disable the vanilla (IDLE) version? ... Install both. ...
    (comp.lang.python)
  • win32com ChartObject pythonwin vs idle
    ... I'm curious as to why the difference between IDLE and pythonWin when ... opening an excel file, i've attempted to grab the chart information ... work in IDLE. ...
    (comp.lang.python)