用法:
map(style, query_opt=None, **kw)
查詢或設置
style
中指定選項的動態值。kw
中的每個鍵都是一個選項,每個值應該是一個列表或元組(通常),其中包含按元組、列表或其他首選項分組的狀態規範。 statespec 是一個或多個狀態的組合,然後是一個值。一個例子可能會讓它更容易理解:
import tkinter from tkinter import ttk root = tkinter.Tk() style = ttk.Style() style.map("C.TButton", foreground=[('pressed', 'red'), ('active', 'blue')], background=[('pressed', '!disabled', 'black'), ('active', 'white')] ) colored_btn = ttk.Button(text="Test", style="C.TButton").pack() root.mainloop()
請注意,選項的(狀態,值)序列的順序確實很重要,例如,如果在前景選項中將順序更改為
[('active', 'blue'), ('pressed', 'red')]
,則當小部件處於活動狀態或按下時,結果將是藍色前景狀態。
相關用法
- Python tkinter.ttk.Style.theme_settings用法及代碼示例
- Python tkinter.ttk.Style.layout用法及代碼示例
- Python tkinter.ttk.Style.configure用法及代碼示例
- Python tkinter.ttk.Style.lookup用法及代碼示例
- Python tkinter.tix.Tk用法及代碼示例
- Python tkinter.tix.tixCommand用法及代碼示例
- Python torch.distributed.rpc.rpc_async用法及代碼示例
- Python torch.nn.InstanceNorm3d用法及代碼示例
- Python tf.compat.v1.distributions.Multinomial.stddev用法及代碼示例
- Python tf.compat.v1.distribute.MirroredStrategy.experimental_distribute_dataset用法及代碼示例
- Python torchaudio.transforms.Fade用法及代碼示例
- Python tf.compat.v1.data.TFRecordDataset.interleave用法及代碼示例
- Python tf.summary.scalar用法及代碼示例
- Python tf.linalg.LinearOperatorFullMatrix.matvec用法及代碼示例
- Python tf.linalg.LinearOperatorToeplitz.solve用法及代碼示例
- Python tf.raw_ops.TPUReplicatedInput用法及代碼示例
- Python tf.raw_ops.Bitcast用法及代碼示例
- Python tf.compat.v1.distributions.Bernoulli.cross_entropy用法及代碼示例
- Python Pandas tseries.offsets.CustomBusinessHour.onOffset用法及代碼示例
- Python torch.special.gammaincc用法及代碼示例
注:本文由純淨天空篩選整理自python.org大神的英文原創作品 tkinter.ttk.Style.map。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。