checkLabel = ttk.Label(win,text = " Check Amount ", foreground = "blue")
checkLabel.grid(row = 0 , column = 1)
checkEntry = ttk.Entry(win, textvariable = checkVariable)
checkEntry.grid(row = 1, column = 1, sticky = 'w')
如何更改defualt输入字段显示0?
答案 0 :(得分:1)
使用条目小部件的功能.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.
另一种方法是使用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"
答案 1 :(得分:0)
在创建checkVariable
对象之前,将''
的值设置为Entry
(空字符串)?要使用的陈述是
checkVariable.set('')
但是checkVariable
必须是StringVar
,如果你想要整数值,你必须自己将输入值转换为整数。