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

前端 未结 2 455
故里飘歌
故里飘歌 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.

    0 讨论(0)
  • 2021-01-18 06:25
    def  set_value():
        text.insert("end-1c",value)
    
    0 讨论(0)
提交回复
热议问题