def _getCurrentText(widget, clipboard=False):The mechanics of that
'''
Given a Tkinter widget, return the currently selected text (clipboard
is False) or the current contents of the system clipboard (clipboard
is True) or None if no text is currently available.
'''
try:
if clipboard:
return widget.selection_get(selection='CLIPBOARD')
else:
return widget.selection_get()
except TclError:
pass
selection_get() method reach through Tk all the way to to the ICCCM standard and the X protocol!