小编Ink*_*lot的帖子

有多少/有哪些不同类型的ttk样式?

我最近一直在制作一些GUI,发现按钮看起来很平淡,所以我读了一些关于使用ttk使外观变得更好的教程,并得到以下内容:

from tkinter import ttk
from tkinter.ttk import *

root = tkinter.Tk()

style = ttk.Style()
style.configure("BW.TLabel")

btn = ttk.Button(text="Test")
btn.pack()

root.mainloop()
Run Code Online (Sandbox Code Playgroud)

是的它看起来更好,但我想知道是否有不同的ttk样式,如果是这样,有多少样式,在哪里检查它们

python themes tkinter widget ttk

7
推荐指数
2
解决办法
7114
查看次数

如何立即在Tkinter GUI中更改所有内容的颜色

我有一些代码(如下所示),提示用户选择将GUI更改为哪种颜色。但是我的问题是,它只会改变背景。我想知道是否可以同时更改每个标签和按钮的背景,还是必须分别更改每个标签/按钮。

import tkinter
window = tkinter.Tk()  
colour_frame = tkinter.Frame(window)
options_frame = tkinter.Frame(window)

def colours():
    options_frame.pack_forget()
    red.pack()
    orange.pack()
    back_button.pack()
    colour_frame.pack()

def back():
    options_frame.pack()
    colour_frame.pack_forget()

def make_red():
    window.configure(background="red")

def make_orange():
    window.configure(background="orange")

colour_button = tkinter.Button(options_frame, text="Appearance", command=colours)

red = tkinter.Button(colour_frame, text="RED", command=make_red)
red.configure(bg = "red")
orange = tkinter.Button(colour_frame, text="ORANGE", command=make_orange)
orange.configure(bg = "orange")
back_button = tkinter.Button(colour_frame, text="Back", command=back)

window.mainloop()
Run Code Online (Sandbox Code Playgroud)

python user-interface background tkinter button

2
推荐指数
1
解决办法
1万
查看次数

标签 统计

python ×2

tkinter ×2

background ×1

button ×1

themes ×1

ttk ×1

user-interface ×1

widget ×1