OptionMenu中的短语显示为“{Piece of cake}”,而不是“Piece of cake”。这种情况只发生在多字字符串上。我确保字符串没有那些括号连接替换。当我打印列表时,括号不在那里,但在OptionMenu中它们在那里。有人知道原因吗?你知道吗
from tkinter import *
root = Tk()
root.geometry('300x200')
ingredients = [('French fries', 'szt', 'D'), ('Salt', 'g', 'D'), ('Cake', 'szt', 'D'), ('Potatoes and eggs', 'g', 'D')]
chosen_ingredient = StringVar()
om_ingredients_list = OptionMenu(root, chosen_ingredient, *ingredients)
om_ingredients_list.config(width=12)
om_ingredients_list.pack(pady=10)
root.mainloop()
下面是一个使用format函数创建选项的示例。你知道吗
相关问题 更多 >
编程相关推荐