decreased border with and padding for tkinter.Label in CTkButton, CTkLabek, CTkOptionMenu

This commit is contained in:
Tom Schimansky 2022-10-13 17:28:33 +02:00
parent 466ba7747e
commit 7abdf21021
7 changed files with 15 additions and 10 deletions

View File

@ -166,6 +166,9 @@ class CTkButton(CTkBaseClass):
self._text_label = tkinter.Label(master=self,
font=self._apply_font_scaling(self._font),
text=self._text,
padx=0,
pady=0,
borderwidth=1,
textvariable=self._textvariable)
self._text_label.bind("<Enter>", self._on_enter)

View File

@ -62,11 +62,13 @@ class CTkLabel(CTkBaseClass):
self._text_label = tkinter.Label(master=self,
highlightthickness=0,
bd=0,
padx=0,
pady=0,
borderwidth=1,
anchor=self._anchor,
text=self._text,
font=self._apply_font_scaling(self._font),
**pop_from_dict_by_set(kwargs, self._valid_tk_label_attributes))
font=self._apply_font_scaling(self._font))
self._text_label.configure(**pop_from_dict_by_set(kwargs, self._valid_tk_label_attributes))
text_label_grid_sticky = self._anchor if self._anchor != "center" else ""
self._text_label.grid(row=0, column=0, sticky=text_label_grid_sticky,

View File

@ -101,6 +101,9 @@ class CTkOptionMenu(CTkBaseClass):
self._text_label = tkinter.Label(master=self,
font=self._apply_font_scaling(self._font),
anchor="w",
padx=0,
pady=0,
borderwidth=1,
text=self._current_value)
self._text_label.grid(row=0, column=0, sticky="w",
padx=(max(self._apply_widget_scaling(self._corner_radius), self._apply_widget_scaling(3)),

View File

@ -241,7 +241,6 @@ class CTkBaseClass(tkinter.Frame):
raise ValueError(f"'{attribute_name}' is not a supported argument. Look at the documentation for supported arguments.")
def _update_dimensions_event(self, event):
print(event)
# only redraw if dimensions changed (for performance), independent of scaling
if round(self._current_width) != round(event.width / self._widget_scaling) or round(self._current_height) != round(event.height / self._widget_scaling):
self._current_width = (event.width / self._widget_scaling) # adjust current size according to new size given by event

View File

@ -180,7 +180,7 @@ class CTk(tkinter.Tk):
self._current_width = max(self._min_width, min(width, self._max_width)) # bound value between min and max
self._current_height = max(self._min_height, min(height, self._max_height))
else:
return self.reverse_geometry_scaling(super().geometry())
return self._reverse_geometry_scaling(super().geometry())
@staticmethod
def _parse_geometry_string(geometry_string: str) -> tuple:

View File

@ -138,8 +138,6 @@ class App(customtkinter.CTk):
self.seg_button_1.configure(values=["CTkSegmentedButton", "Value 2", "Value 3"])
self.seg_button_1.set("Value 2")
self.radiobutton_frame.configure(border_width=50)
def open_input_dialog(self):
dialog = customtkinter.CTkInputDialog(master=self, text="Type in a number:", title="CTkInputDialog")
print("CTkInputDialog:", dialog.get_input())

View File

@ -5,10 +5,10 @@ app = customtkinter.CTk()
tabview_1 = customtkinter._CTkTabview(app)
tabview_1.pack(padx=20, pady=20)
tabview_1.add("tab 1")
tabview_1.insert(0, "tab 0 g |ß$§")
tabview_1.insert(0, "tab 0 g |ß$§ 😀")
app.update()
tabview_1._segmented_button._buttons_dict["tab 0 g |ß$§"]._text_label.configure(padx=0, pady=0, bd=0)
tabview_1._segmented_button._buttons_dict["tab 0 g |ß$§"]._text_label.configure(bg="red")
tabview_1._segmented_button._buttons_dict["tab 0 g |ß$§ 😀"]._text_label.configure(padx=0, pady=0, bd=1)
tabview_1._segmented_button._buttons_dict["tab 0 g |ß$§ 😀"]._text_label.configure(bg="red")
app.mainloop()