readme changed

This commit is contained in:
Tom Schimansky 2021-03-08 18:28:40 +01:00
parent 83421abcb5
commit df05fa3a81
2 changed files with 19 additions and 0 deletions

View File

@ -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_color | text color, tuple: (light_color, dark_color) or single color
text_font | button text font, tuple: (font_name, size) text_font | button text font, tuple: (font_name, size)
hover | enable/disable hover effect: True, False 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)
```
</details> </details>
### CTkLabel ### CTkLabel

View File

@ -250,6 +250,13 @@ class CTkButton(tkinter.Frame):
if self.text_label is not None: if self.text_label is not None:
self.text_label.configure(text=self.text) 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): def on_enter(self, event=0):
for part in self.canvas_fg_parts: for part in self.canvas_fg_parts:
if type(self.hover_color) == tuple and len(self.hover_color) == 2: if type(self.hover_color) == tuple and len(self.hover_color) == 2: