So I made this text editor with tkinter and python. It has a menu bar with a File drop down menu.
I've been trying to change the color of it but no matter what I do nothing works.
Here's a code snippet:
class MenuBar:
def __init__(self, mainClass):
fontSpecs = ("ubuntu", 9)
menuBar = tk.Menu(mainClass.win, font=fontSpecs)
mainClass.win.config(bg="#3C3F41", menu=menuBar)
fileDropDown = tk.Menu(menuBar, font=fontSpecs, tearoff=0, fg="#AFB1B3", bg="#313335")
fileDropDown.add_command(label="New File", command=mainClass.NewFile, accelerator="Ctrl+N")
fileDropDown.add_command(label="Open File", command=mainClass.OpenFile, accelerator="Ctrl+O")
fileDropDown.add_command(label="Save", command=mainClass.Save, accelerator="Ctrl+S")
fileDropDown.add_command(label="Save As", command=mainClass.SaveAs, accelerator="Ctrl+Shift+S")
fileDropDown.add_separator()
fileDropDown.add_command(label="Exit", command=mainClass.Exit)
menuBar.add_cascade(label="File", menu=fileDropDown)
Here's the __init__()
method of the main class:
class TextEditor:
def __init__(self, win: tk.Tk):
win.title(f"Untitled - {name}")
win.geometry("1100x600")
fontSpecs = ("ubuntu", 12)
self.win = win
self.fileName = None
self.textArea = tk.Text(self.win, font=fontSpecs, insertbackground="#AFB1B3", fg="#AFB1B3", bg="#313335")
self.scroll = tk.Scrollbar(self.win, command=self.textArea.yview())
self.textArea.configure(yscrollcommand=self.scroll.set)
self.textArea.pack(side=tk.LEFT, fill=tk.BOTH, expand=True)
font = tk_font.Font(font=self.textArea["font"])
tab = font.measure(" ") # 4 empty spaces
self.textArea.config(tabs=tab)
self.scroll.pack(side=tk.RIGHT, fill=tk.Y)
self.menuBar = MenuBar(self)
If you need any more info, please ask.