Tkinter as indexed Radiobutton in cycle



  • code

    Otvet = [("Круглая", 1),("Квадртная",2),("Это Марс",3),("Вообще-то Луна",4)]
    

    GlobalVar_Int = IntVar()
    relY = float(0.1)

    for Str_Otvet,Value_Otvet in Otvet:
    _Radiobutton = Radiobutton(windows, variable=GlobalVar_Int, fg="black", text=Str_Otvet, value=Value_Otvet, command=select)
    relY += 0.1
    _Radiobutton.place(relx=0.1,rely=relY)

    Question:
    How will the cycle be indexed...Radiobutton? How am I allowed to turn specifically to the very first...Radiobutton that was created in the cycle? I want to remove all four radiobutton-a but also because I don't know how they're indexed only the 4th element if I write...Radiobutton.destroy()



  • Otvet = [("Круглая", 1),("Квадртная",2),("Это Марс",3),("Вообще-то Луна",4)]
    
    GlobalVar_Int = IntVar()
    relY = float(0.1)
    
    R={} #словарь для хранения кнопкев 
    for Str_Otvet,Value_Otvet in Otvet: #читай как правильно назыввать переменные
       R[Str_Otvet]=Radiobutton(windows, variable=GlobalVar_Int, fg="black", text=Str_Otvet, value=Value_Otvet, command=select)
        relY += 0.1 #хз чо тута
        R[Str_Otvet].place(relx=0.1,rely=relY)
    
    R[("Круглая", 1)].destroy()
    
    

    the vocabulary, the names may be any, including the first element of the correlation.



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2