mirror of
https://github.com/TomSchimansky/CustomTkinter.git
synced 2023-08-10 21:13:13 +03:00
readme wiki
This commit is contained in:
parent
dfb50b8c95
commit
5fc3d1f271
21
Readme.md
21
Readme.md
@ -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
|
||||||
|
|
||||||
|
@ -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 |
BIN
documentation_images/simple_macOS_darkmode_test.png
Normal file
BIN
documentation_images/simple_macOS_darkmode_test.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 92 KiB |
@ -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")
|
||||||
|
Loading…
Reference in New Issue
Block a user