samedi 4 septembre 2021

How can I make checkbox from txt.file or list by Python

if .txt or list is data = ['apple', 'banana', 'orange']

from tkinter import *

root = Tk()
root.title("check box")
root.geometry("640x480")
root.resizable(True,True)

data = ['apple', 'banana', 'orange']

for i in range(len(data)):
   globals()['variable{}'.format(i)] = IntVar()
   globals()['box{}'.format(i)] = Checkbutton(root, text = data[i], variable = globals()['variable{}'.format(i)])
   globals()['box{}'.format(i)].pack()

root.mainloop()

but it's not work... how can I make many checkbox from list?




Aucun commentaire:

Enregistrer un commentaire