當我嘗試從我的代碼中的輸入框中獲取值時,它會返回一個空值?,我該如何解決這個問題?,我已將輸入框設置爲字符串變量,但變量的值保持不變?.get()在輸入框上什麼都不返回?
import os
import sys
from Tkinter import *
import tkMessageBox
debug = Tk() #prevenets error on 'StringVar()'
debug.withdraw()
#global varables
users_entry = StringVar()
def about():
tkMessageBox.showinfo("About", "...")
def convert():
test = users_entry.get()
print test
def root_window():
#creates main window
root_window = Tk()
root_window.title("convert to binary")
root_window.geometry("600x400")
root_window.resizable(width = FALSE, height =FALSE)
root_window.configure(background = "gray")
#aboutButton
#about_button = Button(root_window, text = "about", command = about, width = 50)
#about_button.grid(row = 0, column = 0, padx = 85, pady = 3)
#entry box for text
users_entry = StringVar()
text_entry = Entry(root_window, text = "test",textvariable = users_entry, width = 70)
text_entry.grid(row = 1, column = 0, pady = 3)
#convert button
convert_button = Button(root_window, text = "convert", command = convert)
convert_button.grid()
root_window.mainloop()
root_window()
debug.mainloop()