'Create a new ``CanvasFrame``.
:type parent: Tkinter.BaseWidget or Tkinter.Tk
:param parent: The parent ``Tkinter`` widget.  If no parent is
specified, then ``CanvasFrame`` will create a new main
window.
:param kw: Keyword arguments for the new ``Canvas``.  See the
documentation for ``Tkinter.Canvas`` for more information.'

def __init__(self, parent=None, **kw):

    if (parent is None):
        self._parent = Tk()
        self._parent.title('NLTK')
        self._parent.bind('<Control-p>', (lambda e: self.print_to_file()))
        self._parent.bind('<Control-x>', self.destroy)
        self._parent.bind('<Control-q>', self.destroy)
    else:
        self._parent = parent
    self._frame = frame = Frame(self._parent)
    self._canvas = canvas = Canvas(frame, **kw)
    xscrollbar = Scrollbar(self._frame, orient='horizontal')
    yscrollbar = Scrollbar(self._frame, orient='vertical')
    xscrollbar['command'] = canvas.xview
    yscrollbar['command'] = canvas.yview
    canvas['xscrollcommand'] = xscrollbar.set
    canvas['yscrollcommand'] = yscrollbar.set
    yscrollbar.pack(fill='y', side='right')
    xscrollbar.pack(fill='x', side='bottom')
    canvas.pack(expand=1, fill='both', side='left')
    scrollregion = ('0    0    %s    %s' % (canvas['width'], canvas['height']))
    canvas['scrollregion'] = scrollregion
    self._scrollwatcher = ScrollWatcherWidget(canvas)
    if (parent is None):
        self.pack(expand=1, fill='both')
        self._init_menubar()
