1

So I was writing a program that converts MM to inches, RA surface finishes to MM, and can also convert tolerances for dimensions from MM to inches. This is actually my first project I took on in python and I have only been learning to code for about 3 weeks and of course I chose Python3 as my first language. Anyway I was having a problem with clipboard_append (its from tkinter) lets say this was the code (obviously not the code I am working on just using this as an example, thanks to Kevin)

from tkinter import Tk
textToPaste = ("hi", "\n", "bye")
r = Tk()
r.withdraw()
r.clipboard_clear()
r.clipboard_append(textToPaste)
Inhale.Py
  • 260
  • 1
  • 5
  • 15

1 Answers1

2

The problem was the commas in textToPaste. I replaced them with + signs to get the results I was looking for As was explained to me, clipboard_append behaves unusually when you pass it a tuple instead of a string. Heres the code

from tkinter import Tk
textToPaste = "hi" + "\n" + "bye"
r = Tk()
r.withdraw()
r.clipboard_clear()
r.clipboard_append(textToPaste)

Just thought I would share this in case anyone tries using clipboard_append and the curly brackets are getting in the way.

Inhale.Py
  • 260
  • 1
  • 5
  • 15