Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/python-2.7/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 可重复tkinter按钮命令。。。?_Python_Python 2.7_User Interface_Tkinter_Messagebox - Fatal编程技术网

Python 可重复tkinter按钮命令。。。?

Python 可重复tkinter按钮命令。。。?,python,python-2.7,user-interface,tkinter,messagebox,Python,Python 2.7,User Interface,Tkinter,Messagebox,基本上,问题就在这里 所有用户界面都在tkinter消息框中。 我有一个程序,用户在变量中输入一个字符串。检查字符串是否为整数。若有,;打印这是一个int,如果否,启动另一个带有警告消息的消息框,并显示“确定”按钮 这就是问题所在 到目前为止,我已经为整个事件编写了代码,下面是警告消息框的代码: from Tkinter import * __author__ = 'Super' def close_program(): root.destroy() def number_chec

基本上,问题就在这里

所有用户界面都在tkinter消息框中。 我有一个程序,用户在变量中输入一个字符串。检查字符串是否为整数。若有,;打印这是一个int,如果否,启动另一个带有警告消息的消息框,并显示“确定”按钮

这就是问题所在

到目前为止,我已经为整个事件编写了代码,下面是警告消息框的代码:

from Tkinter import *
__author__ = 'Super'

def close_program():
    root.destroy()


def number_checker():
    global vehicle_distance
    global vehicle_time
    try:
    vehicle_distance = float(vehicle_distance)
    correct_text_distance()
except ValueError:
    failed_text_distance()
try:
    vehicle_time = float(vehicle_time)
    correct_text_time()
except ValueError:
    failed_text_time()


def failed_text_time():
    global root
    root = Tk()
    root.title("Fatal Error")
    root.geometry("300x30")

    error_label = Label(root, text="Please input an integer for the field 'time'")
    error_label.pack()

    ok_button = Button(root, text="Ok", command=close_program)
    ok_button.pack()
    root.mainloop()
当按下“确定”按钮时,警告窗口关闭,但当我重新输入值并再次按下enter按钮时,它将运行整数检查器,然后部署警告消息,但失败

文件C:\Python27\lib\lib tk\Tkinter.py,第2036行,在uu init中__ widgetName,self._w+extra+self._选项CNF Tcl错误:无法调用label命令:应用程序已被销毁

我不知道为什么它不想再次启动同一个消息框。。。这可能与“应用程序已被销毁”有关


如果有人能提供帮助,那将是非常有用的

您是否意识到在销毁应用程序后仍在尝试继续使用它?我建议你找一本关于如何正确设置Tkinter应用程序的教程。那是一次试图关闭窗口的尝试,它不起作用。。。。。它在那里终止代码。。。。你知道关闭tkinter窗口而不终止那段代码或整个程序的方法吗?我想这就是我需要的…请在你的答案中添加一些解释!这种批评是学究式的胡说八道。任何能够阅读的人,以及能够在最基础的水平上编程的人,都可以理解我的回答是如何回答OP的问题的。你只是想让我加上一些毫无意义的无聊废话。
import tkSimpleDialog
result = tkSimpleDialog.askinteger(title, prompt [,options])