From df05fa3a8134a3aac2d7b03afa561a7c8729da4f Mon Sep 17 00:00:00 2001 From: Tom Schimansky Date: Mon, 8 Mar 2021 18:28:40 +0100 Subject: [PATCH] readme changed --- Readme.md | 12 ++++++++++++ customtkinter/customtkinter_button.py | 7 +++++++ 2 files changed, 19 insertions(+) diff --git a/Readme.md b/Readme.md index f17cbf7..f61c7bc 100644 --- a/Readme.md +++ b/Readme.md @@ -139,6 +139,18 @@ hover_color | hover color, tuple: (light_color, dark_color) or single color text_color | text color, tuple: (light_color, dark_color) or single color text_font | button text font, tuple: (font_name, size) hover | enable/disable hover effect: True, False +image | put an image on the button, removes the text, must be class PhotoImage + +CTkButton Methods: +```python +CTkButton.set_text(new_text) +CTkButton.change_image(new_image) +CTkButton.configure_color(bg_color=new_bg_color, + fg_color=new_fg_color, + hover_color=new_hover_color, + text_color=new_text_color) +``` + ### CTkLabel diff --git a/customtkinter/customtkinter_button.py b/customtkinter/customtkinter_button.py index 22bee53..f9bc5de 100644 --- a/customtkinter/customtkinter_button.py +++ b/customtkinter/customtkinter_button.py @@ -250,6 +250,13 @@ class CTkButton(tkinter.Frame): if self.text_label is not None: self.text_label.configure(text=self.text) + def change_image(self, image): + if self.image_label is not None: + self.image = image + self.image_label.configure(image=self.image) + else: + sys.stderr.write("ERROR (CTkButton): Cant change image because button has no image.") + def on_enter(self, event=0): for part in self.canvas_fg_parts: if type(self.hover_color) == tuple and len(self.hover_color) == 2: