I'm trying to make a window that will hold all the current data for an object, and will let me change it. I'm stuck on how to make the options menu hold values of the enum and to save the selection as the correct enum key.
Here is my current code, which is being called on the button click:
current = tk.StringVar()
current .set(self.CustomEnum.value)
tk.OptionMenu(infoMenu, current, [e.value for e in CustomEnum]).pack()
This is the result of the list comprehension:
['Option 1', 'Option 2', 'Option 3']
I'm more focused on getting it to display correctly as right now the only option in the menu is
Option1 {Option 2} {Option 3}
Minimum reproducible example:
import tkinter as tk
from enum import Enum
window = tk.Tk()
class CustomEnum(Enum):
Option1 = "Option1"
Option2 = "Option2"
current = tk.StringVar()
current .set(CustomEnum.Option1.value)
tk.OptionMenu(window, current, [e.value for e in CustomEnum]).pack()
window.mainloop()