title: Populate Option Menu from a variable
body: <p>The following is a part of my code.  I have a function that scans the com ports and pulls the available com ports that are connected.  I want to list these com ports as different selections in an Option Menu.  When I run this code, the only option available is COM2 COM4, is there a simple way to separate these into two different options?  I am not looking only for how to populate the option menu with a list, but how to convert the data I have to a list.  Thanks.</p>
  
  <pre><code>    global model
      model = StringVar(master)
      self.option = StringVar()
      w = OptionMenu(master, self.option, ())
  </code></pre>
  
  <p>From the scan of com ports, the print statement returns ['COM2', 'COM4'].</p>
  
  <pre><code>    print(serial_ports())
      global com
      com = list(serial_ports())
      self.option.set(com)
  </code></pre>
  
  <p>Below is the full code for scanning the com port.  </p>
  
  <pre><code>    def serial_ports():
          """ Lists serial port names
  
              :raises EnvironmentError:
                  On unsupported or unknown platforms
              :returns:
                  A list of the serial ports available on the system
          """
          if sys.platform.startswith('win'):
              ports = ['COM%s' % (i + 1) for i in range(256)]
          elif sys.platform.startswith('linux') or sys.platform.startswith('cygwin'):
              # this excludes your current terminal "/dev/tty"
              ports = glob.glob('/dev/tty[A-Za-z]*')
          elif sys.platform.startswith('darwin'):
              ports = glob.glob('/dev/tty.*')
          else:
              raise EnvironmentError('Unsupported platform')
  
          result = []
          for port in ports:
              try:
                  s = serial.Serial(port)
                  s.close()
                  result.append(port)
              except (OSError, serial.SerialException):
                  pass
          return result
  
      if __name__ == '__main__':
          print(serial_ports())
          global com
          com = serial_ports()
  
          self.option.set(com)
  </code></pre>