title: Tkinter entry returns ValueError: invalid literal for int() with base 10: ''
body: <p>So today I've been working on a new GUI with tkinter and came across and issue with parsing a string from an entry into an int and I get this error.</p>
  
  <pre><code>Traceback (most recent call last):
    File "/Users/g.shiner21/Desktop/Python/P2PFile/P2PFileServer.py", line 47, in &lt;module&gt;
      bStartServer = Button(f1, text="Start Server", command=startServer(host))
    File "/Users/g.shiner21/Desktop/Python/P2PFile/P2PFileServer.py", line 28, in startServer
      intport = int(port)
  ValueError: invalid literal for int() with base 10: ''
  </code></pre>
  
  <p>Here is the function, </p>
  
  <pre><code>def startServer(host):
      port = ePort.get()
      intport = int(port)
      s = socket.socket()
      s.bind((host, intport))
      s.listen(4)
  </code></pre>
  
  <p>The most confusing part is that when I test something like this,</p>
  
  <pre><code>strTest = "10000"
  intTest = int(strTest)
  </code></pre>
  
  <p>I get no errors. So I don't think I'm doing my parsing wrong. But at this point I'm not too sure. Any help would be greatly appreciated! :)</p>
  
  <p>Edit: For those that it helps here is the full program(or at least what I have so far. I commented out the second part of it while I was building the GUI because I didn't want to have to deal with any interferences.</p>
  
  <pre><code># server.py
  
  import socket                   # Import socket module
  import sys
  from tkinter import *
  from tkinter import ttk
  
  port = 0                  # Reserve a port for your service.
  s = socket.socket()             # Create a socket object
  host = "0.0.0.0" 
  
  root=Tk()
  root.title("Test Window")
  
  c = '#ececec'
  
  n = ttk.Notebook(root)  #Create notebook
  f1 = ttk.Frame(n)   #Create frames for notebook
  f2 = ttk.Frame(n)
  f3 = ttk.Frame(n)
  n.add(f1, text='Server')    #Add frames to notebook
  n.add(f2, text='File')
  n.add(f3, text='Playback')
  n.pack(expand=1, fill='both')   #Pack notebook
  
  def startServer(host):
      port = ePort.get()
      intport = int(port)
      s = socket.socket()
      s.bind((host, intport))
      s.listen(4)
  
  lservType = Label(f1, text="Select Server Type: ", bg=c)
  lservType.grid(columnspan=2, row=0)
  
  R1 = Radiobutton(f1, text="Local Host", variable=host, value="localhost", bg=c)
  R1.grid(row=1, column=0)
  R2 = Radiobutton(f1, text="Wireless Host", variable=host, value="0.0.0.0", bg=c)
  R2.grid(row=1, column=1)
  
  lPort = Label(f1, text="Port: ", bg=c)
  ePort = Entry(f1)
  
  lPort.grid(row=2, column=0, sticky='e')
  ePort.grid(row=2, column=1)
  
  bStartServer = Button(f1, text="Start Server", command=startServer(host))
  bStartServer.grid(row=3, columnspan=2)
  
  """
  port = 60000                    # Reserve a port for your service.
  s = socket.socket()             # Create a socket object
  host = "0.0.0.0"                # Get local machine name
  s.bind((host, port))            # Bind to the port
  s.listen(4)                     # Now wait for client connection.
  #print("Your IP address is: " + socket.gethostbyname(socket.gethostname()))
  
  print ('Server listening....')
  
  while True:
      conn, addr = s.accept()     # Establish connection with client.
  `    print ('Got connection from', addr)
      input ('Press the enter key to send')
  
      filename = 'send.mov'
      print ('File Assigned')
      f = open(filename,'rb')
      print ('File Oppened')
      l = f.read(131072)
      print ('Reading')
      while (l):
          conn.send(l)
          print('Sent ',repr(l))
          l = f.read(131072)
          print ('Reading')
      f.close()
  
      print('Done sending')
      conn.close()
  #sys.exit()
  """
  root.mainloop()
  </code></pre>