python - Better way to dump the contents of ScrolledText widget -
i know how use built in method dump
, i'm trying filter dump contents text content. came ugly , inefficient 1 liner this:
list(filter(none, map(lambda line: line[1] if line[0] == "text" else none, self.text.dump(1.0, "end"))))
what's better way filter dump list text? reason i'm doing write contents log file, if that's @ relevant. 1 liner above works pretty gets text, new line characters, able write contents log file looks ugly.
to text use get
method, giving starting , ending range of characters want. whole text do:
self.text.get("1.0", "end-1c")
note: "end-1c"
means "the last character, minus 1 character", prevents getting newline tkinter adds.
Comments
Post a Comment