From d9480d7fef87e92d78971223b37ba1a7dfb9824b Mon Sep 17 00:00:00 2001 From: Tom Schimansky Date: Thu, 4 Mar 2021 23:39:09 +0100 Subject: [PATCH] readme wiki --- Readme.md | 171 ++++++++++++++++++++- customtkinter/customtkinter_frame.py | 4 +- customtkinter/customtkinter_progressbar.py | 3 - 3 files changed, 171 insertions(+), 7 deletions(-) diff --git a/Readme.md b/Readme.md index a558255..0454f3d 100644 --- a/Readme.md +++ b/Readme.md @@ -3,7 +3,7 @@ With CustomTkinter you can create modern looking user interfaces in python with tkinter. CustomTkinter is a -tkinter extension which provides extra ui-elements like +tkinter extension which provides extra ui-elements like the CTkButton, which can be used like a normal tkinter.Button, but can be customized with a border and corner_radius. @@ -11,4 +11,171 @@ CustomTkinter also supports a light and dark theme, which can either be set manually or get controlled by the system appearance mode (only macOS). -Detailed documentation is coming soon.... +## Ui-Elements + +### CTkButton +Examle Code: +```python +def button_event(): + print("button pressed") + +button = customtkinter.CTkButton(master=root_tk, + text="CTkButton", + command=button_event, + width=120, + height=32, + border_width=0, + corner_radius=8) +button.place(relx=0.5, rely=0.5, anchor=tkinter.CENTER) +``` +
+Show all arguments: + +argument | value +--- | --- +master | root, tkinter.Frame or CTkFrame +text | string +command | callback function +width | button width in px +height | button height in px +corner_radius | corner radius in px +border_width | button border width in px +fg_color | forground color, tuple: (light_color, dark_color) or single color +bg_color | background color, tuple: (light_color, dark_color) or single color +border_color | border color, tuple: (light_color, dark_color) or single color +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 +
+ +### CTkLabel +Example Code: +```python +button = customtkinter.CTkButton(master=root_tk, + text="CTkLabel", + width=120, + height=25, + corner_radius=8) +button.place(relx=0.5, rely=0.5, anchor=tkinter.CENTER) +``` +
+Show all arguments: + +argument | value +--- | --- +master | root, tkinter.Frame or CTkFrame +text | string +width | label width in px +height | label height in px +corner_radius | corner radius in px +fg_color | forground color, tuple: (light_color, dark_color) or single color +bg_color | background color, tuple: (light_color, dark_color) or single color +text_color | label text color, tuple: (light_color, dark_color) or single color +text_font | label text font, tuple: (font_name, size) +
+ +### CTkEntry +Example Code: +```python +entry = customtkinter.CTkEntry(master=root_tk, + width=120, + height=25, + corner_radius=10) +entry.place(relx=0.5, rely=0.5, anchor=tkinter.CENTER) + +text = entry.get() +``` +
+Show all arguments: + +argument | value +--- | --- +master | root, tkinter.Frame or CTkFrame +width | entry width in px +height | entry height in px +corner_radius | corner radius in px +fg_color | forground color, tuple: (light_color, dark_color) or single color +bg_color | background color, tuple: (light_color, dark_color) or single color +text_color | entry text color, tuple: (light_color, dark_color) or single color +text_font | entry text font, tuple: (font_name, size) +
+ +### CTkSlider +Example Code: +```python +def slider_event(value): + print(value) + +slider = customtkinter.CTkSlider(master=root_tk, + width=160, + height=16, + border_width=5.5, + command=slider_event) +slider.place(relx=0.5, rely=0.5, anchor=tkinter.CENTER) +``` +
+Show all arguments: + +argument | value +--- | --- +master | root, tkinter.Frame or CTkFrame +command | callback function, gest called when slider gets changed +width | slider width in px +height | slider height in px +border_width | space around the slider rail in px +fg_color | forground color, tuple: (light_color, dark_color) or single color +bg_color | background color, tuple: (light_color, dark_color) or single color +border_color | slider border color, normally transparent (None) +button_color | color of the slider button, tuple: (light_color, dark_color) or single color +button_hover_color | hover color, tuple: (light_color, dark_color) or single color +
+ +### CTkProgressBar +Example Code: +```python +progressbar = customtkinter.CTkSlider(master=root_tk, + width=160, + height=20, + border_width=5) +progressbar.place(relx=0.5, rely=0.5, anchor=tkinter.CENTER) + +progressbar.set(value) +``` +
+Show all arguments: + +argument | value +--- | --- +master | root, tkinter.Frame or CTkFrame +width | slider width in px +height | slider height in px +border_width | border width in px +fg_color | forground color, tuple: (light_color, dark_color) or single color +bg_color | background color, tuple: (light_color, dark_color) or single color +border_color | slider border color, tuple: (light_color, dark_color) or single color +progress_color | progress color, tuple: (light_color, dark_color) or single color +
+ +### CTkFrame +Example Code: +```python +frame = customtkinter.CTkSlider(master=root_tk, + width=200, + height=200, + corner_radius=10) +frame.place(relx=0.5, rely=0.5, anchor=tkinter.CENTER) +``` +
+Show all arguments: + +argument | value +--- | --- +master | root, tkinter.Frame or CTkFrame +width | slider width in px +height | slider height in px +fg_color | forground color, tuple: (light_color, dark_color) or single color +bg_color | background color, tuple: (light_color, dark_color) or single color +
+ +# \ No newline at end of file diff --git a/customtkinter/customtkinter_frame.py b/customtkinter/customtkinter_frame.py index 16b28a2..2f211ee 100644 --- a/customtkinter/customtkinter_frame.py +++ b/customtkinter/customtkinter_frame.py @@ -9,8 +9,8 @@ class CTkFrame(tkinter.Frame): bg_color=None, fg_color=None, corner_radius=10, - width=50, - height=20, + width=200, + height=200, **kwargs): super().__init__(*args, **kwargs) diff --git a/customtkinter/customtkinter_progressbar.py b/customtkinter/customtkinter_progressbar.py index ea5763b..9b66c38 100644 --- a/customtkinter/customtkinter_progressbar.py +++ b/customtkinter/customtkinter_progressbar.py @@ -11,7 +11,6 @@ class CTkProgressBar(tkinter.Frame): border_color=None, fg_color=CTkColorManager.PROGRESS_BG, progress_color=CTkColorManager.MAIN, - function=None, width=160, height=20, border_width=5, @@ -46,8 +45,6 @@ class CTkProgressBar(tkinter.Frame): height=self.height) self.canvas.place(x=0, y=0) - self.function = function - self.border_parts = [] self.fg_parts = [] self.progress_parts = []