samedi 13 avril 2019

How can I delete some checkboxes and create another checkboxes with a single button?

I'm new in python and I'm trying to make a quiz in which the user check a checkbox, and then, by pressing a button, delete those checkboxes and create different ones. The problem is that I can't find the way to do it.

I've tried by typing the name of the command that the button will run and then-" .delete, .remove, .del, .destroy". I tried with all of them, but maybe I'm using it wrong.

I don't want to disable them because I want the to disappear and appear with a single button.

from tkinter import *

#Screen
screen  = Tk()
screen.title("Prueba n° 1.000.000.000")
screen.geometry("500x250")

#Functions
def b_next():
    #I don't know what to write here

def del_cb():
    quit()


#1° Questions
c_1 = Checkbutton(text = "1° Option")
c_1.place(y = 20, x = 125)

c_2 = Checkbutton(text = "2° Option")
c_2.place(y = 40, x = 125)

c_3 = Checkbutton(text = "3° Option")
c_3.place(y = 60, x = 125)

c_4 = Checkbutton(text = "4° Option")
c_4.place(y = 80, x = 125)

c_5 = Checkbutton(text = "5° Option")
c_5.place(y = 100, x = 125)


#2° Questions
c_6 = Checkbutton(text = "6° Option")
c_6.place(y = 20, x = 125)

c_7 = Checkbutton(text = "7° Option")
c_7.place(y = 40, x = 125)

c_8 = Checkbutton(text = "8° Option")
c_8.place(y = 60, x = 125)

c_9 = Checkbutton(text = "9° Option")
c_9.place(y = 80, x = 125)

c_10 = Checkbutton(text = "10° Option")
c_10.place(y = 100, x = 125)


#Buttons
b_next = Button(text = "Siguiente Pregunta", command = b_next).place(y = 125, x = 125)

b_del = Button(text = "Borrar", command = del_cb).place(y = 155, x = 125)


screen.resizable (False, False)
screen.mainloop()

I hope you can help with this tiny problem!

P.D: I'm not very good at writing in english so there may be some grammar mistakes, sorry for that!




Aucun commentaire:

Enregistrer un commentaire