readme wiki

This commit is contained in:
Tom Schimansky 2021-03-05 00:32:17 +01:00
parent dfb50b8c95
commit 5fc3d1f271
5 changed files with 24 additions and 4 deletions

View File

@ -14,23 +14,36 @@ the system appearance mode (only macOS).
### Example program (simple button): ### Example program (simple button):
```python ```python
import tkinter import tkinter
import customtkinter import customtkinter # <- import the CustomTkinter module
root_tk = tkinter.Tk() customtkinter.set_appearance_mode("Light") # Other: "Dark", "System" (only macOS)
root_tk = tkinter.Tk() # create the Tk window like you normally do
root_tk.geometry("400x240") root_tk.geometry("400x240")
root_tk.title("CustomTkinter Test") root_tk.title("CustomTkinter Test")
def button_function(): def button_function():
print("button pressed") print("button pressed")
# Use CTkButton instead of tkinter Button
button = customtkinter.CTkButton(master=root_tk, corner_radius=10, command=button_function) button = customtkinter.CTkButton(master=root_tk, corner_radius=10, command=button_function)
button.place(relx=0.5, rely=0.5, anchor=tkinter.CENTER) button.place(relx=0.5, rely=0.5, anchor=tkinter.CENTER)
root_tk.mainloop() root_tk.mainloop()
``` ```
which gives the following: which gives the following:
![](documentation_images/simple_button_test.png) ![](documentation_images/simple_button_test.png)
### Use custom colors and shapes:
If you dont specify any colors, customtkinter uses the standard blue color in the light theme.
You can change the color theme to dark by calling
```customtkinter.set_appearance_mode("Dark")```.
If you specify custom colors for CustomTkinter elements, the you can either use a
tuple in the form: (light_color, dark_color). Or you can set a single color
which will be used in light and dark theme.
### How to use macOS dark mode? ### How to use macOS dark mode?
If you have a python version with Tcl/Tk >= 8.6.9, then you can enable the macOS If you have a python version with Tcl/Tk >= 8.6.9, then you can enable the macOS
darkmode. Currently only the anaconda python versions have Tcl/Tk >= 8.6.9. darkmode. Currently only the anaconda python versions have Tcl/Tk >= 8.6.9.
@ -45,6 +58,10 @@ customtkinter.set_appearance_mode("System")
customtkinter.disable_macos_darkmode() customtkinter.disable_macos_darkmode()
``` ```
which gives the following with the above simple button program:
![](documentation_images/simple_macOS_darkmode_test.png)
## Ui-Elements ## Ui-Elements

View File

@ -1,3 +1,4 @@
import sys
class CTkColorManager: class CTkColorManager:
@ -25,5 +26,5 @@ class CTkColorManager:
elif main_color.lower() == "blue": elif main_color.lower() == "blue":
cls.set_theme_color("#1C94CF", "#5FB4DD") cls.set_theme_color("#1C94CF", "#5FB4DD")
elif main_color.lower() == "blue": else:
cls.set_theme_color("#1C94CF", "#5FB4DD") sys.stderr.write("WARNING (CTkColorManager): No such color theme available: {}\n".format(main_color))

Binary file not shown.

Before

Width:  |  Height:  |  Size: 41 KiB

After

Width:  |  Height:  |  Size: 59 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 92 KiB

View File

@ -42,6 +42,8 @@
import tkinter import tkinter
import customtkinter import customtkinter
customtkinter.enable_macos_darkmode()
root_tk = tkinter.Tk() root_tk = tkinter.Tk()
root_tk.geometry("250x150") root_tk.geometry("250x150")
root_tk.title("CustomTkinter Test") root_tk.title("CustomTkinter Test")