How to get Enum value from a number (int)?

I am wondering if it is possible to convert a enum into an NUMBER and back again?

import uno
# ... other code
>>> bt = uno.Enum("com.sun.star.awt.PushButtonType", "OK")
>>> bt.value
'OK'
>>> btn.PushButtonType = bt
>>> btn.PushButtonType
1
>>> bt = uno.Enum("com.sun.star.awt.PushButtonType", "CANCEL")
>>> bt.value
'CANCEL'
>>> btn.PushButtonType = bt
>>> btn.PushButtonType
2

How could I get the the enum Name from the intereger

def get_push_button_type(enum_int: int) -> str:
   # Return the enum name for Button Type; eg: "OK", "CANCEL", "STANDARD"
    #What would have to go here?
   pass

See

Sub EnumerateEnumerations(sName$)

in the wonderful book by A. Pitonyak OOME_4_1.odt.

2 Likes

I am converting this to python. So far working great.
Thank you.