How to retrieve copied file name with tkinter? How to retrieve copied file name with tkinter? tkinter tkinter

How to retrieve copied file name with tkinter?


I've run into the same exception, when the clipboard is empty or contains a different type. My solution was to use try & except:

def print_filename():    try:        clipboard = Tk().clipboard_get(type="FILE_NAME")    except:        clipboard = ""    print(clipboard)