Clear clipboard after closing window.
This commit is contained in:
parent
908a10a37f
commit
90c889fb77
1 changed files with 13 additions and 1 deletions
12
prog/tqr.py
12
prog/tqr.py
|
@ -27,7 +27,12 @@ def main():
|
|||
root = tk.Tk()
|
||||
root.title = "Qr code"
|
||||
root.state("iconic")
|
||||
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()
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue