Home > other >  TTK themes menu not properly displaying
TTK themes menu not properly displaying

Time:02-01

Good day! My tkinter program will not properly display a menu.

Say the menu has 3 options, the first one will always disappear. Added some screenshots.Screenshot 1 / Screenshot 2

Here's the code, if anyone knows a fix, please help!

from ttkthemes import ThemedStyle
from tkinter import ttk
from tkinter import *

root = Tk()
def show4():
    x=0

optionsmenu = [
    "Dark",
    "Mint",
    "Classic",
]
style = ThemedStyle(root)
style.set_theme("arc")
NightmodeO = StringVar()
drop = ttk.OptionMenu(root, NightmodeO, *optionsmenu)
b1=ttk.Button(root, text='Set theme', command=show4).grid(row=0)
drop.grid(row=1, column=0,sticky='w')

root.mainloop()

CodePudding user response:

You need to set a default option, like optionsmenu[0]:

drop = ttk.OptionMenu(root, NightmodeO, optionsmenu[0], *optionsmenu)

  •  Tags:  
  • Related