title: How can i load a radiobutton value from a csv into a tkinter Listbox
body: <p>I am trying to load a csv file into my program to be able to import from an external file. i want to display the csv list into my list box on tab 2. however whenever i try to callback for the radio buttons i get a StringVar() error <em>&quot;TypeError: ‘StringVar’ object is not callable&quot;</em> .is there a way i can display the radio buttons value,being a string, or do i have to convert the value to an integer.</p>
  <p>The callback errors are for the sex, question1, question2 and the question3</p>
  <pre><code>EfilePath=&quot;participants_external.csv&quot;
  loadButton = Button(tab2, text=&quot;Load From 'participants_external.csv&quot;, font = (&quot;Lucida Sans Unicode&quot;, 8))
  loadButton.place(x=10, y=90)
  
  File= open(EfilePath)
  Reader = csv.reader(File)
  Data = list(Reader)
  
  
  def loadButtonCallback():
      fIn=open(EfilePath,'r')
      lines=fIn.readlines()
      participants.clear()
      for i in range(0,len(lines)):
          data=lines[i].split(&quot;,&quot;)
          if(len(data)&lt;7):
              break
          name=data[0]
          ageStr=data[1]
          age=int(ageStr)
          sex=data[2]
          ethnicityCombo=data[3]
          disabilityCombo=data[4]
          question1=data[5]
          question2=data[6]
          question3=data[7]
          participants.append(Participant(name,age,sex,ethnicity,disability,question1,question2,question3))
      participantsListbox.delete(&quot;0&quot;,&quot;end&quot;)
      for s in participants:
          participantsListbox.insert(END,s.getInfo())
      fIn.close()
  
  loadButton.config(command=loadButtonCallback,)
  </code></pre>
  <p>Full code</p>
  <pre><code>
  from tkinter import *
  from tkinter import ttk
  import csv
  
  root=Tk()
  root.title(&quot;Survey&quot;)
  root.attributes(&quot;-fullscreen&quot;, False)
  canvas = Canvas(root, width = 1920, height = 825)      
  canvas.pack()   
  img = PhotoImage(file=&quot;bg.png&quot;)      
  canvas.create_image(20,20, anchor=NW, image=img)   
  
  
  
  
  class Participant:
      def __init__(self, name, age, sex, ethnicity, disability, question1, question2, question3):
          self.name=name
          self.age=age
          self.sex=sex
          self.ethnicity=ethnicity
          self.disability=disability
          self.question1=question1
          self.question2=question2
          self.question3=question3
      
      def getInfo(self):
          infoStr = self.name+ &quot;         Aged:&quot;+str(self.age)+ &quot;        &quot;+StringVar(self.sex) + &quot;         Ethnicity:&quot; + str(self.ethnicity) + &quot;         Accessibility:&quot; + str(self.disability) + &quot;         Answer 1:&quot; + str(self.question1) + &quot;         Answer 2:&quot; + str(self.question2) + &quot;         Answer 3:&quot; + str(self.question3)
          return infoStr
  
  
  
  participants=[]
  
  for s in participants:
      print(s.getInfo())
  
  #Tab Styles
  tab_parent = ttk.Notebook(root)
  tab1 = ttk.Frame(tab_parent)
  tab2 = ttk.Frame(tab_parent)
  tab_parent.add(tab1, text=&quot;Blank Page&quot;)
  tab_parent.add(tab2, text=&quot;Data&quot;)
  tab_parent.pack(expand=1,fill=&quot;both&quot;)
  
  #tab 2 list box
  #is the main listbox for the participants data for callback
  participantsListbox = Listbox(tab2,width=200,height=50, background=&quot;SlateGray1&quot;, font = (&quot;Lucida Sans Unicode&quot;, 15))
  participantsListbox.place(x=200, y=10)
  participantsListbox.delete(&quot;0&quot;,&quot;end&quot;)
  for s in participants:
      participantsListbox.insert(END,s.getInfo())
  
  
  #Title
  canvas.create_text(235,50, text = &quot;Singing Sculpture Survey&quot;,fill=&quot;white&quot; , font = (&quot;Lucida Sans Unicode&quot;, 25))
  
  #Name 
  nameLabel = Label(canvas,text=&quot;Name:&quot;, bg=&quot;white&quot;, width=10, anchor=&quot;w&quot;, font = (&quot;Lucida Sans Unicode&quot;, 12))
  nameLabel.place(x=40,y=100)
  nameEntry = Entry(canvas,width=20)
  nameEntry.place(x=175,y=100)
  
  #Age
  ageLabel = Label(canvas,text=&quot;Age:&quot;, bg=&quot;white&quot;, width=10, anchor=&quot;nw&quot;, font = (&quot;Lucida Sans Unicode&quot;, 12))
  ageLabel.place(x=40,y=150)
  ageEntry = Entry(canvas,width=20)
  ageEntry.place(x=175,y=150)
  
  #Sex
  gender = StringVar()
  genderLabel = Label(canvas,text=&quot;Gender:&quot;, bg=&quot;white&quot;, font = (&quot;Lucida Sans Unicode&quot;, 12))
  genderLabel.place(x=40,y=200)
  rb1=Radiobutton(canvas,text=&quot;Male&quot;, bg=&quot;SlateGray1&quot;, indicatoron = 0, variable=gender, value=&quot; Male &quot;, font = (&quot;Lucida Sans Unicode&quot;, 10))
  rb1.place(x=40,y=235)
  rb2=Radiobutton(canvas,text=&quot;Female&quot;, bg=&quot;SlateGray3&quot;, indicatoron = 0, variable=gender, value=&quot; Female &quot;, font = (&quot;Lucida Sans Unicode&quot;, 10))
  rb2.place(x=100,y=235)
  
  
  #Ethnicity Combo Box
  ethnicity = canvas
  ethnicityLabel = Label(canvas,text=&quot;Ethnicity:&quot;, bg=&quot;white&quot;, width=10, anchor=&quot;w&quot;, font = (&quot;Lucida Sans Unicode&quot;, 12))
  ethnicityLabel.place(x=40,y=275)
  ethnicityCombo = ttk.Combobox(ethnicity,
  values=[
  &quot;White&quot;,
  &quot;Black&quot;,
  &quot;Chinese&quot;,
  &quot;Asian&quot;,
  &quot;Other&quot;])
  ethnicityCombo.place(x=175,y=275)
  
  #Disability Combo box
  disability = canvas
  disabilityLabel = Label(canvas,text=&quot;Accessibility:&quot;, bg=&quot;white&quot;, width=12, anchor=&quot;w&quot;, font = (&quot;Lucida Sans Unicode&quot;, 12))
  disabilityLabel.place(x=40,y=325)
  disabilityCombo = ttk.Combobox(disability,
  values=[
  &quot;None&quot;,
  &quot;Wheelchair&quot;,
  &quot;With Carer&quot;])
  disabilityCombo.place(x=175,y=325)
  
  #Question 1
  question1Var = StringVar()
  question1VarLabel = Label(canvas,text=&quot;Did you enjoy the sculpture?&quot;, bg=&quot;white&quot;, font = (&quot;Lucida Sans Unicode&quot;, 12))
  question1VarLabel.place(x=40,y=375)
  rb3=Radiobutton(canvas,text=&quot;Very Enjoyable&quot;, bg=&quot;SlateGray1&quot;, indicatoron = 0, variable=question1Var, value=&quot; Very Enjoyable &quot;, width=15, font = (&quot;Lucida Sans Unicode&quot;, 10))
  rb3.place(x=40,y=425)
  rb4=Radiobutton(canvas,text=&quot;Interesting&quot;, bg=&quot;SlateGray3&quot;, indicatoron = 0, variable=question1Var, value=&quot; Interesting &quot;, width=15, font = (&quot;Lucida Sans Unicode&quot;, 10))
  rb4.place(x=190,y=425)
  rb5=Radiobutton(canvas,text=&quot;Decent&quot;, bg=&quot;SlateGray1&quot;, indicatoron = 0, variable=question1Var, value=&quot; Decent &quot;, width=15, font = (&quot;Lucida Sans Unicode&quot;, 10))
  rb5.place(x=340,y=425)
  rb6=Radiobutton(canvas,text=&quot;Alright&quot;, bg=&quot;SlateGray3&quot;, indicatoron = 0, variable=question1Var, value=&quot; Alright &quot;, width=15, font = (&quot;Lucida Sans Unicode&quot;, 10))
  rb6.place(x=490,y=425)
  rb7=Radiobutton(canvas,text=&quot;Un-enjoyable&quot;, bg=&quot;SlateGray1&quot;, indicatoron = 0, variable=question1Var, value=&quot; Un-enjoyable &quot;, width=15, font = (&quot;Lucida Sans Unicode&quot;, 10))
  rb7.place(x=640,y=425)
  
  #Question 2
  question2Var = StringVar()
  question2VarLabel = Label(canvas,text=&quot;Where you curious how the sculpture worked?&quot;, bg=&quot;white&quot;, font = (&quot;Lucida Sans Unicode&quot;, 12))
  question2VarLabel.place(x=40,y=475)
  rb8=Radiobutton(canvas,text=&quot;Yes&quot;, bg=&quot;SlateGray1&quot;, indicatoron = 0, variable=question2Var, value=&quot; Yes &quot;, width=15, font = (&quot;Lucida Sans Unicode&quot;, 10))
  rb8.place(x=40,y=525)
  rb9=Radiobutton(canvas,text=&quot;Not Really&quot;, bg=&quot;SlateGray3&quot;, indicatoron = 0, variable=question2Var, value=&quot; Not Really &quot;, width=15, font = (&quot;Lucida Sans Unicode&quot;, 10))
  rb9.place(x=190,y=525)
  
  #Question 3
  question3Var = StringVar()
  question3VarLabel = Label(canvas,text=&quot;Would you like to understand more about the science behind it?&quot;, bg=&quot;white&quot;, font = (&quot;Lucida Sans Unicode&quot;, 12))
  question3VarLabel.place(x=40,y=575)
  rb10=Radiobutton(canvas,text=&quot;Yes&quot;, bg=&quot;SlateGray1&quot;, indicatoron = 0, variable=question3Var, value=&quot; Yes &quot;, width=15, font = (&quot;Lucida Sans Unicode&quot;, 10))
  rb10.place(x=40,y=625)
  rb11=Radiobutton(canvas,text=&quot;Not Really&quot;, bg=&quot;SlateGray3&quot;, indicatoron = 0, variable=question3Var, value=&quot; Not Really &quot;, width=15, font = (&quot;Lucida Sans Unicode&quot;, 10))
  rb11.place(x=190,y=625)
  
  #Submit button
  submitButton=Button(canvas, text=&quot;   Submit your answers&quot;, font = (&quot;Lucida Sans Unicode&quot;, 12),width=20,height=2, anchor=&quot;w&quot;)
  submitButton.place(x=40,y=675)
  
  
  def submitButtonCallback():
      name=nameEntry.get()
      ageStr=ageEntry.get()
      age=int(ageStr)
      sex=gender.get()
      ethnicity=ethnicityCombo.get()
      disability=disabilityCombo.get()
      question1=question1Var.get()
      question2=question2Var.get()
      question3=question3Var.get()
      participants.append(Participant(name,age,sex,ethnicity,disability,question1,question2,question3))
      participantsListbox.delete(&quot;0&quot;,&quot;end&quot;)
      for s in participants:
          participantsListbox.insert(END,s.getInfo())
      
  submitButton.config(command=submitButtonCallback)
  
  #ability to save and load data to/from csv file
  #csv can be converted to either a database document using sql or an excel document
  saveButton = Button(tab2, text=&quot;Save to External File&quot;, font = (&quot;Lucida Sans Unicode&quot;, 8))
  saveButton.place(x=10, y=50)
  
  
  filePath=&quot;participants_data.csv&quot;
  
  def saveButtonCallback():
      fOut=open(filePath,'w')
      for s in participants:
          data=s.name+&quot;,&quot;+str(s.age) + &quot;,&quot;+str(s.sex) + &quot;,&quot;+str(s.ethnicity) + &quot;,&quot;+str(s.disability) + &quot;,&quot;+str(s.question1) + &quot;,&quot;+str(s.question2) + &quot;,&quot;+str(s.question3)
          fOut.write(data + &quot;\n&quot;)
      fOut.close()
  
  saveButton.config(command=saveButtonCallback)
  
  #Load button
  EfilePath=&quot;participants_external.csv&quot;
  loadButton = Button(tab2, text=&quot;Load From 'participants_external.csv&quot;, font = (&quot;Lucida Sans Unicode&quot;, 8))
  loadButton.place(x=10, y=90)
  
  File= open(EfilePath)
  Reader = csv.reader(File)
  Data = list(Reader)
  
  
  def loadButtonCallback():
      fIn=open(EfilePath,'r')
      lines=fIn.readlines()
      participants.clear()
      for i in range(0,len(lines)):
          data=lines[i].split(&quot;,&quot;)
          if(len(data)&lt;7):
              break
          name=data[0]
          ageStr=data[1]
          age=int(ageStr)
          sex=data[2]
          ethnicityCombo=data[3]
          disabilityCombo=data[4]
          question1=data[5]
          question2=data[6]
          question3=data[7]
          participants.append(Participant(name,age,sex,ethnicity,disability,question1,question2,question3))
      participantsListbox.delete(&quot;0&quot;,&quot;end&quot;)
      for s in participants:
          participantsListbox.insert(END,s.getInfo())
      fIn.close()
  
  loadButton.config(command=loadButtonCallback,)
  
  root.mainloop()
  </code></pre>