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
d9480d7fef
commit
dfb50b8c95
37
Readme.md
37
Readme.md
@ -11,6 +11,41 @@ CustomTkinter also supports a light and dark theme,
|
|||||||
which can either be set manually or get controlled by
|
which can either be set manually or get controlled by
|
||||||
the system appearance mode (only macOS).
|
the system appearance mode (only macOS).
|
||||||
|
|
||||||
|
### Example program (simple button):
|
||||||
|
```python
|
||||||
|
import tkinter
|
||||||
|
import customtkinter
|
||||||
|
|
||||||
|
root_tk = tkinter.Tk()
|
||||||
|
root_tk.geometry("400x240")
|
||||||
|
root_tk.title("CustomTkinter Test")
|
||||||
|
|
||||||
|
def button_function():
|
||||||
|
print("button pressed")
|
||||||
|
|
||||||
|
button = customtkinter.CTkButton(master=root_tk, corner_radius=10, command=button_function)
|
||||||
|
button.place(relx=0.5, rely=0.5, anchor=tkinter.CENTER)
|
||||||
|
|
||||||
|
root_tk.mainloop()
|
||||||
|
```
|
||||||
|
which gives the following:
|
||||||
|
![](documentation_images/simple_button_test.png)
|
||||||
|
|
||||||
|
### How to use macOS dark mode?
|
||||||
|
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.
|
||||||
|
```python
|
||||||
|
import tkinter
|
||||||
|
import customtkinter
|
||||||
|
|
||||||
|
customtkinter.enable_macos_darkmode()
|
||||||
|
customtkinter.set_appearance_mode("System")
|
||||||
|
|
||||||
|
... the program ...
|
||||||
|
|
||||||
|
customtkinter.disable_macos_darkmode()
|
||||||
|
```
|
||||||
|
|
||||||
## Ui-Elements
|
## Ui-Elements
|
||||||
|
|
||||||
### CTkButton
|
### CTkButton
|
||||||
@ -163,7 +198,7 @@ Example Code:
|
|||||||
frame = customtkinter.CTkSlider(master=root_tk,
|
frame = customtkinter.CTkSlider(master=root_tk,
|
||||||
width=200,
|
width=200,
|
||||||
height=200,
|
height=200,
|
||||||
corner_radius=10)
|
corner_radius=10)
|
||||||
frame.place(relx=0.5, rely=0.5, anchor=tkinter.CENTER)
|
frame.place(relx=0.5, rely=0.5, anchor=tkinter.CENTER)
|
||||||
```
|
```
|
||||||
<details>
|
<details>
|
||||||
|
BIN
documentation_images/simple_button_test.png
Normal file
BIN
documentation_images/simple_button_test.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 41 KiB |
@ -1,39 +1,55 @@
|
|||||||
|
# import tkinter
|
||||||
|
# import customtkinter
|
||||||
|
#
|
||||||
|
# customtkinter.enable_macos_darkmode()
|
||||||
|
# #customtkinter.set_appearance_mode("Light")
|
||||||
|
#
|
||||||
|
# app = tkinter.Tk()
|
||||||
|
# app.geometry("400x240")
|
||||||
|
# app.title("CustomTkinter Test")
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# def button_function():
|
||||||
|
# print("button pressed")
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# def slider_function(value):
|
||||||
|
# progressbar_1.set(value)
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# frame_1 = customtkinter.CTkFrame(master=app, width=300, height=200, corner_radius=15)
|
||||||
|
# frame_1.place(relx=0.5, rely=0.5, anchor=tkinter.CENTER)
|
||||||
|
#
|
||||||
|
# label_1 = customtkinter.CTkLabel(master=frame_1)
|
||||||
|
# label_1.place(relx=0.5, rely=0.1, anchor=tkinter.CENTER)
|
||||||
|
#
|
||||||
|
# progressbar_1 = customtkinter.CTkProgressBar(master=frame_1)
|
||||||
|
# progressbar_1.place(relx=0.5, rely=0.25, anchor=tkinter.CENTER)
|
||||||
|
#
|
||||||
|
# button_1 = customtkinter.CTkButton(master=frame_1, corner_radius=10, command=button_function)
|
||||||
|
# button_1.place(relx=0.5, rely=0.5, anchor=tkinter.CENTER)
|
||||||
|
#
|
||||||
|
# slider_1 = customtkinter.CTkSlider(master=frame_1, command=slider_function)
|
||||||
|
# slider_1.place(relx=0.5, rely=0.7, anchor=tkinter.CENTER)
|
||||||
|
#
|
||||||
|
# entry_1 = customtkinter.CTkEntry(master=frame_1)
|
||||||
|
# entry_1.place(relx=0.5, rely=0.85, anchor=tkinter.CENTER)
|
||||||
|
#
|
||||||
|
# app.mainloop()
|
||||||
|
# customtkinter.disable_macos_darkmode()
|
||||||
|
#
|
||||||
|
|
||||||
import tkinter
|
import tkinter
|
||||||
import customtkinter
|
import customtkinter
|
||||||
|
|
||||||
customtkinter.enable_macos_darkmode()
|
root_tk = tkinter.Tk()
|
||||||
#customtkinter.set_appearance_mode("Light")
|
root_tk.geometry("250x150")
|
||||||
|
root_tk.title("CustomTkinter Test")
|
||||||
app = tkinter.Tk()
|
|
||||||
app.geometry("400x240")
|
|
||||||
app.title("CustomTkinter Test")
|
|
||||||
|
|
||||||
|
|
||||||
def button_function():
|
def button_function():
|
||||||
print("button pressed")
|
print("button pressed")
|
||||||
|
|
||||||
|
button = customtkinter.CTkButton(master=root_tk, corner_radius=10, command=button_function)
|
||||||
|
button.place(relx=0.5, rely=0.5, anchor=tkinter.CENTER)
|
||||||
|
|
||||||
def slider_function(value):
|
root_tk.mainloop()
|
||||||
progressbar_1.set(value)
|
|
||||||
|
|
||||||
|
|
||||||
frame_1 = customtkinter.CTkFrame(master=app, width=300, height=200, corner_radius=15)
|
|
||||||
frame_1.place(relx=0.5, rely=0.5, anchor=tkinter.CENTER)
|
|
||||||
|
|
||||||
label_1 = customtkinter.CTkLabel(master=frame_1)
|
|
||||||
label_1.place(relx=0.5, rely=0.1, anchor=tkinter.CENTER)
|
|
||||||
|
|
||||||
progressbar_1 = customtkinter.CTkProgressBar(master=frame_1)
|
|
||||||
progressbar_1.place(relx=0.5, rely=0.25, anchor=tkinter.CENTER)
|
|
||||||
|
|
||||||
button_1 = customtkinter.CTkButton(master=frame_1, corner_radius=10, command=button_function)
|
|
||||||
button_1.place(relx=0.5, rely=0.5, anchor=tkinter.CENTER)
|
|
||||||
|
|
||||||
slider_1 = customtkinter.CTkSlider(master=frame_1, command=slider_function)
|
|
||||||
slider_1.place(relx=0.5, rely=0.7, anchor=tkinter.CENTER)
|
|
||||||
|
|
||||||
entry_1 = customtkinter.CTkEntry(master=frame_1)
|
|
||||||
entry_1.place(relx=0.5, rely=0.85, anchor=tkinter.CENTER)
|
|
||||||
|
|
||||||
app.mainloop()
|
|
||||||
customtkinter.disable_macos_darkmode()
|
|
Loading…
Reference in New Issue
Block a user