win32com ChartObject pythonwin vs idle

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • sterling

    win32com ChartObject pythonwin vs idle

    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.

    The same goes other things like SeriesCollectio n()/
    seriescollectio n(1),seriescoll ection(2)..., Close()/close

    Is there any way to fix it such that IDLE works with ChartObject()
    too? I'd really like to be able to use ChartObject().C ount() (there
    doesn't seem to be an equivalent chartobject.cou nt)

    Thanks.
  • Tim Golden

    #2
    Re: win32com ChartObject pythonwin vs idle

    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

    Comment

    • sterling

      #3
      Re: win32com ChartObject pythonwin vs idle

      On Jul 31, 4:28 am, Tim Golden <m...@timgolden .me.ukwrote:
      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("Exce l.Application")
      >>wb = ex.Workbooks.Op en("C:\Temp\Sal esChart.xls")
      Traceback (most recent call last):
      File "<pyshell#2 >", line 1, in <module>
      wb = ex.Workbooks.Op en("C:\Temp\Sal esChart.xlsx")
      File "C:\Python25\Li b\site-packages\win32c om\client\dynam ic.py",
      line 467, in __getattr__
      if self._olerepr_. mapFuncs.has_ke y(attr): return
      self._make_meth od_(attr)
      File "C:\Python25\Li b\site-packages\win32c om\client\dynam ic.py",
      line 295, in _make_method_
      methodCodeList =
      self._olerepr_. MakeFuncMethod( self._olerepr_. mapFuncs[name],
      methodName,0)
      File "C:\Python25\Li b\site-packages\win32c om\client\build .py", line
      297, in MakeFuncMethod
      return self.MakeDispat chFuncMethod(en try, name, bMakeClass)
      File "C:\Python25\Li b\site-packages\win32c om\client\build .py", line
      318, in MakeDispatchFun cMethod
      s = linePrefix + 'def ' + name + '(self' + BuildCallList(f desc,
      names, defNamedOptArg, defNamedNotOptA rg, defUnnamedArg, defOutArg) +
      '):'
      File "C:\Python25\Li b\site-packages\win32c om\client\build .py", line
      604, in BuildCallList
      argName = MakePublicAttri buteName(argNam e)
      File "C:\Python25\Li b\site-packages\win32c om\client\build .py", line
      542, in MakePublicAttri buteName
      return filter( lambda char: char in valid_identifie r_chars,
      className)
      File "C:\Python25\Li b\site-packages\win32c om\client\build .py", line
      542, in <lambda>
      return filter( lambda char: char in valid_identifie r_chars,
      className)
      UnicodeDecodeEr ror: '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.

      Comment

      • Roger Upole

        #4
        Re: win32com ChartObject pythonwin vs idle


        "sterling" <sterlingsomers @gmail.comwrote in message
        news:670b57b7-d48e-44c0-abd0-b6772d23688d@79 g2000hsk.google groups.com...
        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.
        >
        The same goes other things like SeriesCollectio n()/
        seriescollectio n(1),seriescoll ection(2)..., Close()/close
        >
        Is there any way to fix it such that IDLE works with ChartObject()
        too? I'd really like to be able to use ChartObject().C ount() (there
        doesn't seem to be an equivalent chartobject.cou nt)
        >
        Thanks.
        This was probably due to a conflict with the way IDLE sets the locale.
        Bug report here:


        This is fixed in build 212, just released today.

        Roger



        Comment

        • sterling

          #5
          Re: win32com ChartObject pythonwin vs idle

          On Jul 31, 11:22 pm, "Roger Upole" <rup...@hotmail .comwrote:
          "sterling" <sterlingsom... @gmail.comwrote in message
          >
          news:670b57b7-d48e-44c0-abd0-b6772d23688d@79 g2000hsk.google groups.com...
          >
          >
          >
          >
          >
          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.
          >
          The same goes other things like SeriesCollectio n()/
          seriescollectio n(1),seriescoll ection(2)..., Close()/close
          >
          Is there any way to fix it such that IDLE works with ChartObject()
          too?  I'd really like to be able to use ChartObject().C ount() (there
          doesn't seem to be an equivalent chartobject.cou nt)
          >
          Thanks.
          >
          This was probably due to a conflict with the way IDLE sets the locale.
          Bug report here:http://sourceforge.net/tracker/index...d=2006053&grou...
          >
          This is fixed in build 212, just released today.
          >
                    Roger- Hide quoted text -
          >
          - Show quoted text -
          Thanks for the tip Roger. Installed 212 and it worked right away!

          Comment

          Working...