Interacting with system’s clipboard#
You can access your system’s clipboard using tkinter
library.
import tkinter as tk
root = tk.Tk()
root.withdraw()
Now you can have access to your systems clipboard. Just copy some text to your clipboard then you can retrieve it like so:
txt = root.clipboard_get()
After you’re done with the process, you should close the access as follows:
root.destroy()
This only works for Linux-based systems, if you use MacOS or Windows you have to use another approach. You can find more info here.