我正试图改变我的Tkinter
主题,但当我把s.theme_use('classic')
改为s.theme_use('calm')
或s.theme_use('winnative')
时,什么都没有改变
这是我的代码:
from tkinter import *
import tkinter.ttk as ttk
window = Tk()
window.title("Running Python Script") # Create window
window.geometry('550x300') # geo of the window
s=ttk.Style()
list_themes = s.theme_names()
current_theme = s.theme_use()
s.theme_use('classic')
print(list_themes)
def run():
if dd_owner.get() == "Spain":
print("spain")
# These are the option menus
dd_owner = StringVar(window)
dd_owner.set(owner[0]) # the first value
w = OptionMenu(window, dd_owner, *owner)
w.grid(row=0, column=1)
#The run button
run_button = Button(window, text="Run application {}".format(dd_owner.get()), bg="blue", fg="white",command=run)
run_button.grid(column=0, row=2)
# These are the titles
l1 = Label(window, text='Select Owner', width=15)
l1.grid(row=0, column=0)
mainloop()
下面是一个基于代码使用
ttk
小部件的修改示例:当你点击按钮时,它会随机改变主题
相关问题 更多 >
编程相关推荐