[Tkinter-discuss] Radio Buttons

Michael Lange klappnase at web.de
Thu May 11 18:33:18 CEST 2006

On Thu, 11 May 2006 11:07:27 +0000
"Peter Lacroix" <pjlacroix at hotmail.com> wrote:

> Hi all,
> Let's say you had the following class below (MakeChoice) that was used to 
> cast a vote. When the program is running, eventually the user will confirm 
> choices made through some sort of "SUBMIT" button. When that button is 
> clicked, we want the selected value (on a few sets of radio buttons) to be 
> written to a file. What is the container of the currently selected value and 
> how does one have that value be written to a file when a button is clicked?

Hi Peter,

do you mean something like this:

def create_widgets(self):
    (... snip ...)
    self.submit_button = Button(self, text='Submit', command=self.submit)
    self.submit_button.grid(row=8, column=0)

def submit(self):
    f = open(your_filename_here, 'w')

The value of the StringVar is updated automatically each time the user changes the selection.

I hope this helps


More information about the Tkinter-discuss mailing list