Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding default value in simpledialog.askstring using tkinter in Python 3

I am trying to create a simple textbox using tkinter. Below is the code I am trying to use.

import tkinter as tk
from tkinter import simpledialog

root = tk.Tk() # Create an instance of tkinter

start_date = simpledialog.askstring(title = "Test Title",
                                    prompt = "Entire Start Date in MM/DD/YYYY format:")

Below is the output I am getting as expected.

enter image description here

My question is, how do I populate a default value in the empty slot by default, as shown below?

enter image description here

In R, I can easily do this using the below command.

start_date <- winDialogString("Entire Start Date in MM/DD/YYYY format:", "01/31/2018")
like image 902
Code_Sipra Avatar asked Mar 09 '18 09:03

Code_Sipra


1 Answers

Have you read this? You can provide initialvalue as option like

simpledialog.askstring(title = "Test Title", prompt = "Entire Start Date in MM/DD/YYYY format:", initialvalue="whateveryouwant")

like image 157
Da_Pz Avatar answered Oct 23 '22 16:10

Da_Pz