The variable ports_available
contains an array of COMPORTS. I want these to be added to the submenu "ports_menu" on startup of the GUI so that I can select any one of them for selecting the COMPORT.
global ports_available
ports_available = [comport.device for comport in serial.tools.list_ports.comports()]
global port_select
port_select = "COM1"
#Create Menu
my_menu = Menu(window)
window.config(menu = my_menu)
# Add Tool Menu
tool_menu = Menu(my_menu, tearoff = False)
my_menu.add_cascade(label = "Tools", menu = tool_menu)
tool_menu.add_command(label = "Bold", command =bold_it)
tool_menu.add_command(label = "Italic", command =italic_it)
#Menu for ports
ports_menu = Menu(tool_menu, tearoff = False)
tool_menu.add_cascade(label = "Ports", menu = ports_menu)
for name in ports_available:
ports_menu.add_checkbutton(label = name, variable = port_select)
[![When i select any one of the option everything gets selected][1]][1]
Thank you, Dhruv Gupta