Tk.entry возвращает пустое значение, когда используется .get () - PullRequest
0 голосов
/ 09 декабря 2018

У меня проблемы с курсовой работой в колледже.Я не могу заставить свою программу передать входные данные из моего tk.entry в другую функцию.Есть идеи?

Вот функция:

def maintest ():

global studentans
global questions
global pointer
questiontitle = str(questions[pointer][0])
questionmarks = str(questions[pointer][1])
marktitle = ("this question is " + questionmarks + " marks")

test = Tk()
test.configure(bg=white)
test.attributes("-fullscreen", True)
test.title("Student Register")
test.configure(bg=white, padx=20, pady=20)

username = StringVar()

tk.Label(test, text=questiontitle, font=("Calibri", 40), fg=black, bg=white).place(relx=0.5, rely=0.1,
                                                                                   anchor=CENTER)
tk.Label(test, text=marktitle, font=("Calibri", 20), fg=black, bg=white).place(relx=0.5, rely=0.2, anchor=CENTER)

tk.Entry(test, width=50, bg=grey, textvariable=username,
         font=("Calibri", 25)).place(relx=0.5, rely=0.3, anchor=CENTER)

tk.Button(test, text="SUBMIT", font=("Calibri", 12),
          command=lambda: openans(username.get(), test),
          height=5, width=50, bg=grey, fg=black, borderwidth=0).place(relx=0.5, rely=0.7, anchor=CENTER)
tk.Button(test, text="MAIN MENU", font=("Calibri", 12),
          command=lambda: return_login(test), height=5, width=50, bg=grey, fg=black, borderwidth=0).place(relx=0.5,
                                                                                                          rely=0.9,
                                                                                                          anchor=CENTER)
test.mainloop()
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...