How do I place a preset into the text box?
Steve
Gronicus at SGA.Ninja
Fri Aug 28 06:03:15 EDT 2020
The following program compiles but does not quite do what I would like it to
do. Line 19 is the preset information but I do not seem to be able to get it
into the form by code. My purpose is to let the user make changes without
having to re-enter the entire code.
Suggestions welcome.
Steve
#===========================================================
import tkinter as tk
from tkinter import ttk
import sys
window = tk.Tk()
window.title("Python Tkinter Text Box")
window.minsize(600,400)
def Submit():
label.configure(text= 'The new code is: ' + NewCode.get())
def ClickExit():
#This exit closes the program but the form remains and is still active.
# I want only to close the form.
print("Exiting")
sys.exit()
OldCode = ("1234-abcd")
label = ttk.Label(window, text = "Enter the new code")
label.grid(column = 1, row = 1)
NewCode = tk.StringVar()
CodeEntered = ttk.Entry(window, width = 15, textvariable = NewCode)
CodeEntered.grid(column = 2, row = 3)
button = ttk.Button(window, text = "Submit", command = Submit)
button.grid(column= 2, row = 5)
button = ttk.Button(window, text = "Quit", command = ClickExit)
button.grid(column= 2, row = 7)
window.mainloop()
x = (NewCode.get())
print("The new code entered is: " + x)
#=================================================
Footnote:
Mars is the only known planet in our solar system solely inhabited by
functioning robots.
More information about the Python-list
mailing list