title: cv2.imshow() function does not show the image if user input is taken, but works otherwise
body: <p>I'm writing a code to generate user-defined grids on a 500x500 white image.
  The program should request the user for input on grid size and draw vertical and horizontal lines accordingly and finally display the image.</p>
  
  <p>The problem I am facing is that the image is not displayed whenever I call the "getGridSize()" function. But the image display works when I manually assign a value to the variable 'num'</p>
  
  <p>I have tried using cv2.waitKey(0) and cv2.destroyAllWindows() too but in vain.</p>
  
  <pre><code>import cv2
  import numpy as np
  
  width = 500 # Dimensions of the blank, white image
  
  def main():
  ##    getGridSize()
      num = 4
  
      generateWhiteImg()
      lineImg = whiteImg.copy() # Create a copy of the white image to draw upon
  
      for i in range(0, num):
          spacing = int(width / (num + 1))    # Specify the width between each line, for uniform placement
          point = (i + 1) * spacing   # Change the coordinate of the lines to be drawn by fixed amounts
          lineImg = cv2.line(lineImg, (0, point), (width, point), (0, 0, 0), 3)   # Draw horizontal lines
          lineImg = cv2.line(lineImg, (point, 0), (point, width), (0, 0, 0), 3)   # Draw vertical lines
  
      cv2.imshow('LINES', lineImg)
  
  ## Function to get grid size from user
  def getGridSize():
      global num # Stores the size of grid to be drawn
      num = input("Enter the size of blank grid: ")
      num = int(num) # To convert string to integer
  
  ## Function to generate a blank, white image
  def generateWhiteImg():
      global whiteImg
      img = np.zeros((width, width, 3), np.uint8) # Generate a zeros list, i.e., a black image
      img[:width] = (255, 255, 255) # Convert black image to white
      cv2.imwrite('whiteImg.png', img) # Save the white image
      whiteImg = cv2.imread('whiteImg.png')   # Load the same from directory
  
  if __name__ == "__main__":
      main()
  </code></pre>
  
  <p>There are no error messages.
  I expected the code to work as it is. I'm thinking the problem is inside the getGridSize() function</p>
  
  <p>UPDATE 1 : I am using python 3.5.4 for this</p>