title: Tk only copies to clipboard if "paste" is used before program exits
body: <p><strong>Environment</strong></p>
  
  <ul>
  <li>Python 3.6.2</li>
  <li>Windows 10</li>
  </ul>
  
  <p><strong>The Problem</strong></p>
  
  <p>I use the tk method clipboard_append() to copy a string to the clipboard.</p>
  
  <p>When my program is run from the Python interpreter data is copied to the clipboard correctly.</p>
  
  <p>When run using "C:\Python36.exe myprogram.py" however, I get some weird behavior.</p>
  
  <ol>
  <li>If I <strong>paste</strong> the data while the program is still running, it works as expected.</li>
  <li>If I <strong>paste</strong> the data while the program is running, then close the program, I can continue to paste the data.</li>
  <li>If I close the program <strong>after</strong> copying but <strong>before</strong> pasting, the clipboard is empty.</li>
  </ol>
  
  <p><strong>Question</strong></p>
  
  <p>How do I make tk copy to the clipboard regardless of what happens to the containing window?</p>
  
  <p><strong>My Code</strong></p>
  
  <pre><code>from tkinter import *
  from tkinter import messagebox
  
  url = 'http://testServer/feature/'
  
  def copyToClipboard():
      top.clipboard_clear()
      top.clipboard_append(fullURL.get())
      top.update()
      top.destroy()
  
  def updateURL(event):
      fullURL.set(url + featureNumber.get())
  
  def submit(event):
      copyToClipboard()
  
  top = Tk()
  top.geometry("400x75")
  top.title = "Get Test URL"
  
  topRow = Frame(top)
  topRow.pack(side = TOP)
  
  bottomRow = Frame(top)
  bottomRow.pack(side = BOTTOM)
  
  featureLabel = Label(topRow, text="Feature Number")
  featureLabel.pack(side = LEFT)
  
  featureNumber =  Entry(topRow)
  featureNumber.pack(side = RIGHT)
  
  fullURL = StringVar()
  fullURL.set(url)
  
  fullLine = Label(bottomRow, textvariable=fullURL)
  fullLine.pack(side = TOP)
  
  copyButton = Button(bottomRow, text = "Copy", command = copyToClipboard)
  copyButton.pack(side = TOP)
  
  featureNumber.focus_set()
  featureNumber.bind("&lt;KeyRelease&gt;", updateURL)
  featureNumber.bind("&lt;Return&gt;", submit)
  
  top.mainloop()
  </code></pre>
  
  <p><strong>Purpose of the Program</strong></p>
  
  <p>My company has a test server we use for new features. Every time we create a new feature we need to post a url to it on the test server. The urls are identical save for the feature number, so I created this python program to generate the url for me and copy it to the clipboard.</p>
  
  <p>I can get this working if I comment out "top.destroy" and paste the url before manually closing the window, but I would really like to avoid this. In a perfect world I would press a shortcut, have the window pop up, enter my feature number, then just press enter to close the window and paste the new url, all without taking my hands off the keyboard.</p>