So i was just improving the text editor that i made.. The problem is that i want to get the clicked element of the menu inside my menubar of tkinter window..
Here in this picture How can i get the clicked item "C++ Compile"? I am just unable to figure out how to solve this..
Menu code:
Menubar = Menu(root, activebackground ="#0084FF", activeforeground = "#FFFFFF",bg = "#FFFFFF", fg = "#0084FF" ,font = "consolas")
Filemenu = Menu(root, tearoff = 0)
Filemenu.add_command(label="New",command=newTab)
Filemenu.add_separator()
Filemenu.add_command(label="Open", command=openFile)
Filemenu.add_command(label="Save", command=saveFile)
Filemenu.add_command(label="Save As", command=saveAsFile)
Filemenu.add_separator()
Filemenu.add_command(label="Close", command=deltab)
Filemenu.add_separator()
Filemenu.add_command(label="Exit", command=root.destroy)
Menubar.add_cascade(label="File", menu=Filemenu)
toolsMenu = Menu(root,tearoff=0)
confmenu = Menu(root,tearoff=0)
runmenu = Menu(root,tearoff = 0)
runmenu.add_command(label = "Open file from cmd", command = lambda:runfile())
runmenu.add_separator()
runner_command = StringVar()
if isConf:
for i in getConfs():
runmenu.add_command(label = i, command = lambda:runnerConf(i))
runmenu.add_separator()
runmenu.add_command(label= "New Runner",command = lambda:newrunner())
toolsMenu.add_cascade(label = "Runner", menu = runmenu)
toolsMenu.add_command(label = "Open cmd here", command = lambda:opencmd())
Menubar.add_cascade(label="Tools",menu = toolsMenu)
SPECS:
OS: Windows 7 (i will upgrade to Windows 20 ONLY)
Python: 3.8.10
Arch: x86 (32 bit)