Is there any method to change the color of an active tab in tkinter?

时间:2019-02-05 17:16:26

标签: python-3.x user-interface tkinter

I want to customize the tkinter GUI and make it more responsive and interactive. I wanted to know to that is any method in which the color of a particular tab changes when it is selected? By default there is a dashed line that borders an active tab. I am trying to remove the dashed border and instead use a color changing scheme to denote an active or inactive tab. Below I am posting the relevant part of the code.

mainframe = ttk.Notebook(window,width=50, height=200) 
mainframe.grid(row=0,column=0,columnspan=50,rowspan=40,sticky='NESW')

#create frame style
frame_style=ttk.Style()
frame_style.configure('TFrame',background='#800000')


#create tabs within the frame.
tab1 = ttk.Frame(mainframe, style='Frame1.TFrame')
mainframe.add(tab1, text="TAB1")



tab2 = ttk.Frame(mainframe, style='Frame2.TFrame')
mainframe.add(tab2, text="TAB2")


tab3 = ttk.Frame(mainframe)
mainframe.add(tab3, text="TAB3")

tab4 = ttk.Frame(mainframe)
mainframe.add(tab4, text="TAB4")

tab5 = ttk.Frame(mainframe)
mainframe.add(tab5, text="TAB5")

window.mainloop() #end of GUI

0 个答案:

没有答案