【发布时间】:2014-04-18 19:28:38
【问题描述】:
我一直在玩 TKinter,试图创建一个多标签窗口。
当我尝试设置TNotebook.Tab 的样式时,它会忽略background 和borderwidth 选项,但它会承认foreground。我做错了什么?
以下是代码的相关部分:
COLOR_1 = 'black'
COLOR_2 = 'white'
COLOR_3 = 'red'
COLOR_4 = '#2E2E2E'
COLOR_5 = '#8A4B08'
COLOR_6 = '#DF7401'
#Notebook Style
noteStyler = ttk.Style()
noteStyler.configure("TNotebook", background=COLOR_1, borderwidth=0)
noteStyler.configure("TNotebook.Tab", background=COLOR_1, foreground=COLOR_3, lightcolor=COLOR_6, borderwidth=0)
noteStyler.configure("TFrame", background=COLOR_1, foreground=COLOR_2, borderwidth=0)
#Create Notebook and Tabs
note = ttk.Notebook(gui, style='TNotebook')
myTab = ttk.Frame(note, style='TFrame')
note.add(myTab, text = 'MyTab', compound=tk.TOP)
note.pack(anchor=tk.W)
这是窗口外观的图像:
以防万一,我在 Windows 7 64 位上运行 python 2.7。
【问题讨论】:
标签: python python-2.7 tkinter tk ttk