New example
I'm updating the question after user2554330's comment. Since I updated my R version, the tkinsert function from package tcltk does not recognize the flag "\n". How can I write different lines?
New example. This is a real example that used to work, writing 3 lines of asterisks and 3 empty lines:
library(tcltk)
tt <- tktoplevel()
tkpack(txt.w <- tktext(tt))
endL <- paste0("***************************************",
"*************************")
tcltk::tkinsert(txt.w , "end", endL, collapse = "\\n")
tcltk::tkinsert(txt.w , "end", endL, collapse = "\\n")
tcltk::tkinsert(txt.w , "end", endL, collapse = "\\n")
tcltk::tkinsert(txt.w , "end", paste("\\n\\n"))
tcltk::tkinsert(txt.w , "end", paste("\\n\\n"))
tcltk::tkinsert(txt.w , "end", paste("\\n\\n"))
Now I get this (I replace multiple asterisks by dots, otherwise the message is not shown properly).
"...\n**************...\n*****...***\n\n\n\n\n\n\n"
Instead of three lines of asterisks and three empty lines.
Actually I could have written this, but the result is the same.
library(tcltk)
tt <- tktoplevel()
tkpack(txt.w <- tktext(tt))
endL <- paste0("***************************************",
"*************************")
tcltk::tkinsert(txt.w , "end", endL, collapse = "\\n")
tcltk::tkinsert(txt.w , "end", endL, collapse = "\\n")
tcltk::tkinsert(txt.w , "end", endL, collapse = "\\n")
tcltk::tkinsert(txt.w , "end", "\\n\\n")
tcltk::tkinsert(txt.w , "end", "\\n\\n")
tcltk::tkinsert(txt.w , "end", "\\n\\n")
With this other version the result is still the same
library(tcltk)
tt <- tktoplevel()
tkpack(txt.w <- tktext(tt))
endL <- paste0("***************************************",
"*************************")
tcltk::tkinsert(txt.w , "end", endL, collapse = "\\n")
tcltk::tkinsert(txt.w , "end", endL, collapse = "\\n")
tcltk::tkinsert(txt.w , "end", endL, collapse = "\\n")
tcltk::tkinsert(txt.w , "end", "\\n")
tcltk::tkinsert(txt.w , "end", "\\n")
tcltk::tkinsert(txt.w , "end", "\\n")
Old example
Since I updated my R version, the tkinsert function from package tcltk does not recognize the flag "\n". I want to write different lines, but "\n" does not work and neither do other options (I get all the numbers likes this: OneTwoThreeFourFiveSix.
tt <- tktoplevel()
tkpack(txt.w <- tktext(tt))
tcltk::tkinsert(txt.w, "end", paste("One", collapse = "\\n"))
tcltk::tkinsert(txt.w, "end", paste("Two", collapse = "\n"))
tcltk::tkinsert(txt.w, "end", paste("Three", collapse = "\n\r"))
tcltk::tkinsert(txt.w, "end", paste("Four", collapse = "\t"))
tcltk::tkinsert(txt.w, "end", paste("Five", collapse = "\\t"))
tcltk::tkinsert(txt.w, "end", paste("Six", collapse = "\r\n"))
I'm working on Windows.
This works now (at least on Windows):
This works too:
Old example now working: