Determine which Radiobutton has been selected
Question: I am sorry for the silly question but there doesn't seem to be too much
documentation on this that is understandable.

So far I have this:

    
    
    self.firstRadioButton = Radiobutton(self.__canvas, text="ONE", fg='white', bg=BACKGROUND_COLOR, variable=self.selectedONE, value=1)
    
    self.secondRadioButton = Radiobutton(self.__canvas, text="TWO", fg='white', bg=BACKGROUND_COLOR, variable=self.selectedTWO, value=2)
    

Well first of all, the reason it's a radio button is because the user has to
pick one. So one automatically has to be selected (I think Python already does
that) good.

Second of all, I am trying to get the value of whichever one the user picks.
That is my problem, I cannot for the life of me figure this out.


Answer: The key is to make sure that both radiobuttons share the same variable. Then,
to know which one is selected you simply need to get the value of the
variable.

Here is an example:

    
    
    import tkinter
    
    # function that is called when you select a certain radio button
    def selected():
        print(var.get())
    
    
    root = tkinter.Tk()
    
    var = tkinter.StringVar() #used to get the 'value' property of a tkinter.Radiobutton
    
    # Note that I added a command to each radio button and a different 'value'
    # When you press a radio button, its corresponding 'command' is called.
    # In this case, I am linking both radio buttons to the same command: 'selected'
    
    rb1 = tkinter.Radiobutton(text='Radio Button 1', variable=var, 
                              value="Radio 1", command=selected)
    rb1.pack()
    rb2 = tkinter.Radiobutton(text='Radio Button 2', variable=var, 
                              value="Radio 2", command=selected)
    rb2.pack()
    
    root.mainloop()
    

