mardi 23 mai 2023

Is there a way to create Radiobuttons in kivy via a loop with a dictionary and get the choosen value somewhere?

I'm trying to create an app with the code of an old tkinter program of mine. I use kivy for this, but because I never worked with it, I'm totally lost at some points. My question is, if it is possible to create radiobuttons (via Checkbox) by a loop with a dictionary just as I can do with tkinter?

sprachen = {"erste_sprache": 1, "zweite_sprache": 2, "dritte_sprache": 3, "vierte_sprache":4, "fünfte_sprache":5}
ausgewaehlt = tk.StringVar()
for einzelwert in sprachen:
    radiob = tk.Radiobutton(gruppeauswahl, text=einzelwert, value=einzelwert, variable=ausgewaehlt)
    #print("hier")
    radiob.grid(sticky = "w")
ausgewaehlt.set("erste_sprache")

I tried to just use checkbox. I got Radiobuttons via grouping. But the whole thing didn't work, because first I can't set a text, value and variable to this and second it doesn't want to create Checkboxes out of a dictionary.




Aucun commentaire:

Enregistrer un commentaire