I've been trying to make a choice menu with Radiobutton using *kwargs
.
Unfortunately the sent variable order is not kept as wished for: Easy, Medium, Hard, Extreme. And, even though I did set v to a specific value, all the choices are selected at once.
Am I missing something here?
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import Tkinter as tk
from Tkinter import *
class MainApplication(tk.Frame):
def __init__(self, parent, *args, **kwargs):
tk.Frame.__init__(self, parent, *args, **kwargs)
self.parent = parent
def onClick(self, event):
print("Clicked")
def qChoice(self, **kwargs):
v = IntVar()
v.set(1)
for key, value in kwargs.iteritems():
self.Rbutton = Radiobutton(text=key, variable=v, value=value)
self.Rbutton.grid(sticky=W)
def basics(self):
self.label = Label(text="Enter name:")
self.label.grid(column=0, row=0, sticky="E")
self.entry = Entry()
self.entry.grid(column=1, row=0)
self.button = Button(text="Enter")
self.button.bind("<Button-1>", self.onClick)
self.button.grid(column=3, row=0)
self.qChoice(Easy=1,Medium=2,Hard=3,Extreme=4)
if __name__ == "__main__":
root = tk.Tk()
App = MainApplication(root)
App.basics()
root.mainloop()