Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
enum from typelib
#1
Hello!
I try to use a typelib of a COM application.
In the Typelib are also enum's defined.

Is there a chance to use the enum definitions in python?

I tried import comtypes
e.g. if I code
Quote:mycmod : MyApp.ColorModel = 0

the variable mycmod is an integer and has no idea of the defined enum values
this doesn't work:
[icode]mycmod : MyApp.ColorModel = MyApp.ColorModel.RGB

Thank you for advice
Erhy
Reply
#2
Now I see with comtypes the definitions for enum values can be accessed like global constants
e.g.
mycmod : MyApp.ColorModel = MyApp.CMYK

this with the exception:
If the name of the constant is used for others.
e.g. RGB is a function and so the constant RGB of the enum cannot be accessed.

Erhy
Reply
#3
further I discovered that if I use

import win32com.client as COM
pl = COM.Dispatch("Erhy.Application")
rgbState = COM.constants.RGB
works!

So I will try not using the comtypes package
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Variable sorting methods for Enum DataClasses koen 1 755 May-30-2023, 07:31 PM
Last Post: deanhystad
  Alarm system with state, class, enum. Frankduc 0 1,256 May-04-2022, 01:26 PM
Last Post: Frankduc
Question Having trouble writing an Enum with a custom __new__ method stevendaprano 3 4,105 Feb-13-2022, 06:37 AM
Last Post: deanhystad
  Enum help SephMon 3 1,485 Nov-19-2021, 09:39 AM
Last Post: Yoriz
  how to handle COM Typelib OUT parameters? Erhy 1 1,950 Jan-26-2019, 10:47 PM
Last Post: Erhy
  Python error? Enum and strings tycarac 3 3,563 Dec-15-2018, 10:39 AM
Last Post: tycarac

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020