title: Only consider values when available in Tkinter GUI
body: <p>I am working on a simple GUI on Tkinter. What I want is add up all the filled blanks, if there are. If there are empty fields, just take them as “0”.</p>
  
  <p><img src="https://i.stack.imgur.com/YRTEB.jpg" alt="enter image description here"></p>
  
  <p>However it’s not successful and the problem lies on: </p>
  
  <pre><code>value2 = float(c.get())
  </code></pre>
  
  <p>the error is:</p>
  
  <pre><code>ValueError: could not convert string to float:
  </code></pre>
  
  <p>Here is the codes:</p>
  
  <pre><code>from Tkinter import *
  import ttk
  
  
  def plus(*args):
      value = float(a.get())
      value1 = float(b.get())
      if c:
          value2 = float(c.get())
      else:
          value2 == float(0.0)
      if d:
          value3 = float(d.get())
      else:
          value3 == float(0.0)
  
      result.set(value + value1 + value2 + value3)
  
  root = Tk()
  root.title("Plus them")
  
  mainframe = ttk.Frame(root, padding="10 10 10 10")
  mainframe.grid(column=0, row=0, sticky=(N, W, E, S))
  mainframe.columnconfigure(0, weight=1)
  mainframe.rowconfigure(0, weight=1)
  
  a = StringVar()
  b = StringVar()
  c = StringVar()
  d = StringVar()
  result = StringVar()
  
  feet_entry = ttk.Entry(mainframe, width=5, textvariable=a)
  feet_entry.grid(column=2, row=1, sticky=(W, E))
  
  feet_entry1 = ttk.Entry(mainframe, width=5, textvariable=b)
  feet_entry1.grid(column=5, row=1, sticky=(W, E))
  
  feet_entry2 = ttk.Entry(mainframe, width=5, textvariable=c)
  feet_entry2.grid(column=2, row=2, sticky=(W, E), pady = 5)
  
  feet_entry3 = ttk.Entry(mainframe, width=5, textvariable=d)
  feet_entry3.grid(column=5, row=2, sticky=(W, E), pady = 5)
  
  ttk.Label(mainframe, text="the result is").grid(column=3, row=3, sticky=W)
  ttk.Label(mainframe, textvariable = result).grid(column=5, row=3, sticky=(W, E))
  
  ttk.Button(mainframe, text="Plus", command=plus).grid(column=3, row=4, sticky=W)
  
  feet_entry.focus()
  root.bind('&lt;Return&gt;', plus)
  root.mainloop()
  </code></pre>
  
  <p>I think the problem lies in the function defining part. And I tried below:</p>
  
  <pre><code>def plus(*args):
      try:
          value = float(a.get())
          value1 = float(b.get())
          value2 = float(c.get())
          value3 = float(d.get())
  
          result.set(value + value1 + value2 + value3)
  
      except ValueError:
          pass
  </code></pre>
  
  <p>but it doesn't help. What’s the way to put them correctly?</p>