【发布时间】:2020-01-22 07:16:39
【问题描述】:
enter image description here我有这样的代码:
from tkinter import Tk
import tkinter.ttk as ttk
"""Styles"""
style = ttk.Style()
style.configure('OrangeButton.TButton', foreground='white', background='#ff9203')
style.map('OrangeButton.TButton',
foreground=[('pressed', 'white'), ('active', 'white')],
background=[('pressed', '!disabled', '#adadad'), ('active', '#de8e26')])
root = Tk()
button = ttk.Button(root, text="Ok", width=20, style='OrangeButton.TButton')
button.pack(padx=50, pady=50)
root.mainloop()
我是新手。我在互联网上搜索了解决方案,但找不到。他们到处写关于widthdraw()的文章,但这无济于事。始终出现两个窗口,并且自定义样式未应用于按钮。我究竟做错了什么?如何在 Google 上搜索此问题?请告诉我。谢谢。
【问题讨论】:
标签: python-3.x tkinter styles ttk