Python - customtkinter CheckBox

Опубликовано: 29 Сентябрь 2024
на канале: ANDREEs
87
2

import customtkinter as ctk

import tkinter as tk


#Fenster
window = ctk.CTk()
window.title("Startseite")
window.geometry("800*600")


#Erscheinungsbild "system", "light" oder "dark"
ctk.set_appearance_mode("dark") # "light" or "dark or "system"
ctk.set_default_color_theme("dark-blue") # Themes: "blue" (standard), "green", "dark-blue"


def ausgefunktion_1():
ausgabe_1 = ctk.CTkLabel(window, text = auswahl_1.get()).pack()
print("Deine Auswahl: " + auswahl_1.get())




auswahl_1 = ctk.StringVar()
checkbox_1 = ctk.CTkCheckBox(window, text="PKW",command=ausgefunktion_1, variable=auswahl_1, onvalue="Kosten: 99 € / Tag",
offvalue=" ", border_color="turquoise").pack()


#Schleife
window.mainloop()


"""
Argumente
master root, tkinter.Frame or CTkFrame
width Breite des kompletten Widgets in px
height Höhe des kompletten Widgets in px
checkbox_width Breite der checkbox in px
checkbox_height Höhe der checkbox in px
corner_radius Eckenradius in px
border_width Rendbreite in px
fg_color Vordergrund (innen) Farbe, tuple: (light_color, dark_color) oder einzelne Farbe
border_color Randfarbe, tuple: (light_color, dark_color) oder einzelne Farbe
hover_color hover - Farbe, tuple: (light_color, dark_color) oder einzelne Farbe
text_color Textfarbe, tuple: (light_color, dark_color) oder einzelne Farbe
text_color_disabled Textfarbe wenn deaktiviert, tuple: (light_color, dark_color) oder einzelne Farbe
textvariable Tkinter StringVar zur Steuerung des Textes

font Schaltflächen - Text-Art, tuple: (font_name, size)
hover enable/disable hover effect: True, False
state tkinter.NORMAL (standard) oder tkinter.DISABLED (nicht anklickbar, dunklere Farbe)
command Die Funktion wird aufgerufen, wenn das Kontrollkästchen angeklickt wird
variable Tkinter-Variable zum Steuern oder Lesen des Kontrollkästchenstatus
onvalue string oder int für Variable im geprüften Zustand
offvalue string oder int für Variable im ungeprüften Zustand

"""