Friday, 22 January 2021

Tkinter: OptionMenu object menu not working with highlightthickness=0

The highlightthickness = 0 config parameter is not working with the menu object and it's giving me an error:

_tkinter.TclError: unknown option "-highlightthickness"

However it does work on the widget itself but I would like to know if it's possible to remove the border from the drop down menu. (See examples below)

I've tried borderwidth = 0 as well and it does not change anything in the object menu's case.

Example

import tkinter as tk

window = tk.Tk()
ratioList = ('1 : 1', '16 : 9')
variable = tk.StringVar()
variable.set(ratioList[0])

ratioDropdown = tk.OptionMenu(window, variable, *ratioList)
ratioDropdown.place(x=170, y=155)
ratioDropdown.config(relief="flat", highlightthickness=0, font=("Montserrat", (12)), bg="#035be3", activebackground="#023c96",activeforeground="white", fg="white", borderwidth="0", indicatoron=0)

ratioDropdown["menu"].config(font=("Montserrat", (12)), bg="#035be3", relief="flat", fg="white", activebackground="#023c96", borderwidth=0)

ratioDropdown.pack()

tk.mainloop()


from Tkinter: OptionMenu object menu not working with highlightthickness=0

No comments:

Post a Comment