Search code examples
pythoncustomtkinter

CustomTkinter TabView


import customtkinter

customtkinter.set_appearance_mode("dark")
customtkinter.set_default_color_theme("green")

root = customtkinter.CTk()
root.title("CustomTkinter Tabview")

tabview = customtkinter.CTkTabview(root)
tabview.pack(padx=20, pady=20)

tabview.add("tab 1")
tabview.add("tab 2")
tabview.set("tab 2")

button_1 = customtkinter.CTkButton(tabview.tab("tab 1"))
button_1.pack(padx=20, pady=20)

root.mainloop()

Here is the Python code i've got now. I want to display a text to tab 1 and tab 2, here you can see i displayed button in tab 1, But when i run code and go to tab 1, i do see button, but the name of button is the name of the function, for this one, Its CTkButton, So button's text is "CTkButton", How may i display a text i want on specific tab?


Solution

  • You need to use text argument to set the custom text to the button as below :

    button_1 = customtkinter.CTkButton(tabview.tab("tab 1"), text="Tab 1")