fixed tabview initial fg_color, removed tests from simple_example.py

This commit is contained in:
Tom Schimansky 2023-07-27 14:40:19 +02:00
parent 16990a566f
commit d719950f80
2 changed files with 12 additions and 17 deletions

View File

@ -202,6 +202,14 @@ class CTkTabview(CTkBaseClass):
width=0,
border_width=0,
corner_radius=0)
if self._fg_color == "transparent":
new_tab.configure(fg_color=self._apply_appearance_mode(self._bg_color),
bg_color=self._apply_appearance_mode(self._bg_color))
else:
new_tab.configure(fg_color=self._apply_appearance_mode(self._fg_color),
bg_color=self._apply_appearance_mode(self._fg_color))
return new_tab
def _draw(self, no_color_updates: bool = False):
@ -235,7 +243,7 @@ class CTkTabview(CTkBaseClass):
fill=self._apply_appearance_mode(self._border_color),
outline=self._apply_appearance_mode(self._border_color))
self._canvas.configure(bg=self._apply_appearance_mode(self._bg_color))
tkinter.Frame.configure(self, bg=self._apply_appearance_mode(self._bg_color)) # configure bg color of tkinter.Frame, cuase canvas does not fill frame
tkinter.Frame.configure(self, bg=self._apply_appearance_mode(self._bg_color)) # configure bg color of tkinter.Frame, cause canvas does not fill frame
def configure(self, require_redraw=False, **kwargs):
if "corner_radius" in kwargs:

View File

@ -63,22 +63,9 @@ text_1.insert("0.0", "CTkTextbox\n\n\n\n")
segmented_button_1 = customtkinter.CTkSegmentedButton(master=frame_1, values=["CTkSegmentedButton", "Value 2"])
segmented_button_1.pack(pady=10, padx=10)
tabview_1 = customtkinter.CTkTabview(master=frame_1, width=300, height=120, fg_color="transparent", corner_radius=4, anchor="sw")
tabview_1 = customtkinter.CTkTabview(master=frame_1, width=300)
tabview_1.pack(pady=10, padx=10)
tabview_1.add("1")
tabview_1.add("2")
tabview_1.add("3")
b1 = customtkinter.CTkButton(tabview_1.tab("1"))
b1.pack()
b2 = customtkinter.CTkButton(tabview_1.tab("2"))
b2.pack()
tabview_1.move(1, "3")
tabview_1.rename("3", "42")
print(tabview_1.index("42"))
tabview_1.configure(fg_color='transparent', corner_radius=10, border_width=5)
tabview_1.configure(fg_color='green', corner_radius=10, border_width=5)
tabview_1.add("CTkTabview")
tabview_1.add("Tab 2")
app.mainloop()