Python: How to get some characters in the menu bar underlined?
<p>I built with Python a tkinter menu and I would like to underline in it some characters. I used the command "underline" in some lines, but strangely the characters are not appearing as underlined.
What should I do that "underline" finally works and starts to underline a given index? Did I have something forgotten?</p>

<pre><code>from tkinter import Tk, Frame, Menu


class Window():
    def __init__(self):
        self.__window = Tk()
        self.__set_window()
        self.__set_menu()


    def __set_window(self):
        self.__window.geometry("700x500")
        self.__window.minsize(500, 200)
        self.__window.title("Some Text")
        self.__window.iconbitmap("MyIcon")

    def start_window(self):
        self.__window.mainloop()

    def __set_menu(self):
        self.__menubar = Menu(self.__window)
        self.__file= Menu(self.__menubar, tearoff=0)


        self.__file.add_command(label = "Exit", underline=1, accelerator="Strg + C")
        self.__menubar.add_cascade(label="File", underline=0, menu=self.__datei)

        self.__menubar.add_cascade(label="Edit", underline=1)


        self.__menubar.add_cascade(label="Help", underline=0)
        self.__window["menu"] = self.__menubar
</code></pre>

<p>Underlines in tkinter menus are definitely determined by the underline command.  In your example, the 'F' in file, and the 'x' in Exit are both underlined.  After fixing the typo below, (and adding code to call the class) I had the underlines show up correctly.</p>

<p>from:</p>

<pre><code>self.__menubar.add_cascade(label="File", underline=0, menu=self.__datei)
</code></pre>

<p>to:</p>

<pre><code>self.__menubar.add_cascade(label="File", underline=0, menu=self.__file)
</code></pre>

<p>Do you still have the error when you run the code snippet as opposed to your complete file?</p>

python windows tkinter menu underline