I'm using a tkinter Entry widget in a temporary window to collect information from a user. I want to be able to use that information for a variety of things: rewrite it in a Label in another window, convert it to an integer for calculations, get its value as a string for writing to a file, and so on. In this stripped down code, I've got two text variables, and I've used quotation marks to name one and not the other. As I understand it, using the quotation marks is wrong--the variable without the quotation marks works correctly with get, for example. The trouble is that the one without the quotation marks doesn't copy correctly when I use it as the textvariable for a Label in a different window. What am I missing here?
from tkinter import *
from tkinter import ttk
root = Tk()
sheetid = StringVar
sheetname = StringVar
def dosheet():
sheet = Toplevel(root)
ttk.Label(sheet, text="Sheet ID:").grid(row=0)
ttk.Label(sheet, textvariable=sheetid, font=(11)).grid(row=1)
ttk.Label(sheet, text="Sheet Name:").grid(row=2)
ttk.Label(sheet, textvariable="sheetname", font=(11)).grid(row=3)
#end dosheet
def new():
def finish():
start.destroy()
dosheet()
start = Toplevel(root)
start.title("New sheet dialog")
ttk.Label(start, text="Sheet ID:").grid(row=1)
ttk.Entry(start, textvariable=sheetid).grid(row=2)
ttk.Label(start, text="Sheet name:").grid(row=3)
ttk.Entry(start, textvariable="sheetname").grid(row=4)
ttk.Button(start, text="Close", command=finish).grid(row=5)
#end new
main = ttk.Frame(root, padding="16 12 12 12")
main.grid()
ttk.Label(main, text="Start new sheet:").grid()
ttk.Button(main, text="New", command=new).grid()
root.mainloop()