0
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')

How do I change the defualt entry field from displaying 0?

Bryan Oakley
  • 370,779
  • 53
  • 539
  • 685
MDub
  • 37
  • 1
  • 4

2 Answers2

1

Use the entry widget's function, .insert() and .delete(). Here is an example.

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.

Another way to do this is with the Tkinter StrVar. Here is an example of using the str variable.

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"
Preston Hager
  • 1,514
  • 18
  • 33
  • so when I use Entry.insert(END, "1") in my entry field i get 0.01 How would i get just 0.1? – MDub Oct 05 '16 at 16:55
0

Set the value of checkVariable to '' (the empty string) before you create the Entry object? The statement to use would be

checkVariable.set('')

But then checkVariable would have to be a StringVar, and you would have to convert the input value to an integer yourself if you wanted the integer value.

holdenweb
  • 33,305
  • 7
  • 57
  • 77
  • that changes it to blank, however what if I want to set it to a default double and have the program use that unless its changed? – MDub Oct 05 '16 at 16:23
  • Use a string input. If the input is blank (i.e. unchanged) then return the default value. Otherwise return the converted text input? – holdenweb Oct 05 '16 at 16:25