<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def set_renderer(self, renderer):
 """ Set the viewport widget. """

        viewport = None
        if renderer == 'opengl':
            from enaml.qt.QtWidgets import QOpenGLWidget
            viewport = QOpenGLWidget()
        elif renderer == 'default':
            try:
                from enaml.qt.QtWidgets import QOpenGLWidget
                viewport = QOpenGLWidget()
            except ImportError as e:
                warnings.warn(
                    "QOpenGLWidget could not be imported: {}".format(e))
        self.widget.setViewport(viewport)