Python >> Tutoriel Python >  >> Python GUI >> Tkinter GUI

Python 3 Tkinter Checkbutton Widget Exemple pour ajouter une liste d'options de cases à cocher dans l'application de bureau GUI

Exemple de widget Python 3 Tkinter Checkbutton pour ajouter une liste d'options de cases à cocher dans l'application de bureau GUI

from tkinter import *

from tkinter.ttk import *

window = Tk()

window.title("Welcome to LikeGeeks app")

window.geometry('350x200')

chk_state = BooleanVar()

chk_state.set(True) #set check state

chk = Checkbutton(window, text='Apple', var=chk_state)

chk.grid(column=0, row=0)

chk_state = BooleanVar()

chk_state.set(False) #set check state

chk2 = Checkbutton(window, text='Mango', var=chk_state)

chk2.grid(column=0, row=1)

window.mainloop()