エントリウィジェットの関数.insert()
と.delete()
を使用します。ここに例があります。
entry = tk.Entry(root)
entry.insert(END, "Hello") # this will start the entry with "Hello" in it
# you may want to add a delay or something here.
entry.delete(0, END) # this will delete everything inside the entry
entry.insert(END, "WORLD") # and this will insert the word "WORLD" in the entry.
もう1つの方法はTkinter StrVarです。 str変数の使用例を次に示します。
entry_var = tk.StrVar()
entry_var.set("Hello")
entry = tk.Entry(root, textvariable=entry_var) # when packing the widget
# it should have the world "Hello" inside.
# here is your delay or you can make a function call.
entry_var.set("World") # this sets the entry widget text to "World"
これは空白に変更されますが、デフォルトの倍精度に設定して、プログラムが変更されていない場合はどうすればよいですか? – MDub
文字列入力を使用します。入力が空白(つまり変更されていない)の場合、デフォルト値を返します。さもなければ変換されたテキスト入力を返しますか? – holdenweb