Python/Tkinter: How to set text widget contents to the value of a variable?

前端 未结 2 483
故里飘歌
故里飘歌 2021-01-18 05:52

I am writing a program to assist with a trivial part of my job that can be automated. My purpose here is to:

  1. Copy and paste a chunk of plain text into a Tki

2条回答
  •  不知归路
    2021-01-18 06:19

    I think what you want is this, it will delete all the text, then insert a variable.

    def set_input(value):
        text.delete(1.0, "END")
        text.insert("END", value)
    

    Python 2.x only, 3 requires that "END" be END from the Tk namespace.

提交回复
热议问题