diff --git a/prog/tqr.py b/prog/tqr.py index 6099b87..167411f 100644 --- a/prog/tqr.py +++ b/prog/tqr.py @@ -27,7 +27,12 @@ def main(): root = tk.Tk() root.title = "Qr code" root.state("iconic") - data = root.clipboard_get() + try: + data = root.clipboard_get() + except Exception as e: + messagebox.showerror("Qr code", f"Cannot get content of clipboard.\n«{e}»") + exit(1) + try: code = qr.create(data) except ValueError as e: @@ -47,6 +52,13 @@ def main(): img.config(background="white") label = tk.Label(root, image=img) label.pack() + + def empty_clipboard(): + root.clipboard_clear() + root.destroy() + + root.protocol("WM_DELETE_WINDOW", empty_clipboard) + root.mainloop()