tkinter radiobutton not updating variable
<p>--UPDATE: 
I changed </p>

<pre><code>variable=self.optionVal.get()
</code></pre>

<p>to</p>

<pre><code>variable=self.optionVal
</code></pre>

<p>But nothing changed.Also I wonder why it automatically call self.selected while compiling?</p>

<p>----Original:</p>

<p>I'm trying to get familiar with radiobutton, but I don't think I understand how radiobutton works. Here's a brief code for demonstration:</p>

<pre><code>     self.optionVal = StringVar()
     for text, val in OPTIONS:
         print(text,val)
         radioButton = Radiobutton(self,
                                   text=text,
                                   value=val,
                                   variable=self.optionVal.get(),
                                   command = self.selected())
        radioButton.pack(anchor=W) 

     def selected(self):
        print("this option is :"+self.optionVal.get())

In my opinion this should work like once I choose certain button, and it prints out "this option is *the value*", however now what it does is once compiled, it prints out everything, and the self.optionVal.get() is blankspace, as if value wasn't set to that variable.

I wonder what happens to my code,
Many thanks in advance. 
</code></pre>