From 30a142743bd3e72e121f5f6ea064de9c28a2aba7 Mon Sep 17 00:00:00 2001 From: David Rotermund <54365609+davrot@users.noreply.github.com> Date: Wed, 17 Jan 2024 17:37:11 +0100 Subject: [PATCH] Update README.md Signed-off-by: David Rotermund <54365609+davrot@users.noreply.github.com> --- tk/overview/README.md | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/tk/overview/README.md b/tk/overview/README.md index 60119b6..f490dd7 100644 --- a/tk/overview/README.md +++ b/tk/overview/README.md @@ -75,6 +75,37 @@ del root ## [ttk.Checkbutton](https://anzeljg.github.io/rin2/book2/2405/docs/tkinter/ttk-Checkbutton.html) +![image_checkbutton.png](image_checkbutton.png) + +```python +import tkinter as tk +from tkinter import ttk + + +def changed() -> None: + global variable + print(f"Changed: Now it is set to {variable.get()}") + + +root = tk.Tk() + +width_element: int = 10 +InitialValue: bool = True + +variable = tk.BooleanVar() +variable.set(InitialValue) + +a_button = ttk.Checkbutton( + root, text="Don't press", width=width_element, command=changed, variable=variable +) +a_button.grid(row=0, column=0, sticky="w") + + +root.mainloop() + +del root +``` + ## [ttk.Combobox](https://anzeljg.github.io/rin2/book2/2405/docs/tkinter/ttk-Combobox.html) ## [ttk.Entry](https://anzeljg.github.io/rin2/book2/2405/docs/tkinter/ttk-Entry.html)