dynamically update text on buttons in tkinter
<p>I'm working on an application right now and am having some difficulty with something. I would like to have the key from the dictionary as the label and the four numbers in the list are the value to the corresponding key and show be put in the buttons. When I press a button, I want to change the label and the button so that it goes to the next element in the dictionary and keep repeating the process until there are no more elements in the dictionary. </p>

<p>Here is my code so far: </p>

<pre><code>import tkinter as tk
q_a = {"label":[1,2,3,4],"label 2":[5,6,7,8]}
class ExampleApp(tk.Tk):
    def __init__(self):
        tk.Tk.__init__(self)
        self.label = tk.Label(self)
        self.label.pack()
        self.remaining = len(q_a)
        self.countdown(self.remaining-1)

    def loop(self, remaining=None):
        if self.remaining &lt;= 0:
            self.label.configure(text="The end")
        else:
            self.label.configure(text=(list(q_a.keys())[self.remaining-1]))
            dictionary_index = list(q_a.keys())[self.remaining-1]
            self.remaining = self.remaining - 1
            button1 = tk.Button(self, text=q_a[dictionary_index][0],
                           command=lambda: self.loop).pack()
            button2 = tk.Button(self, text=q_a[dictionary_index][1],
                           command=lambda: self.loop).pack()
            button3 = tk.Button(self, text=q_a[dictionary_index][2],
                           command=lambda: self.loop).pack()
            button4 = tk.Button(self, text=q_a[dictionary_index][3],
                           command=lambda: self.loop).pack()


if __name__ == "__main__":
    app = ExampleApp()
    app.mainloop()
</code></pre>