所以我今天调试我的一些代码,发现在输出新的消息:SO关于它不能援引“事件”命令:应用程序已经被破坏
can't invoke "event" command: application has been destroyed
while executing
"event generate $w <<ThemeChanged>>"
(procedure "ttk::ThemeChanged" line 6)
invoked from within
"ttk::ThemeChanged"
我看了看问题但它们并没有涉及这个错误的实例。至于ttk小部件,我没有在我的代码中使用过一次ttk,在我的代码中搜索字符串“ttk”不会产生任何结果。
的代码块,它输出这样的:
def GoToEvent(self, controller, driver):
wait = WebDriverWait(driver, 600)
var = Vars()
entertain = var.GetVars("Link")
if type(entertain) == type(""):
event = var.GetVars("Event")
entertain = driver.find_element_by_partial_link_text(event)
entertain.click()
try:
# we have to wait for the page to refresh, the last thing that seems to be updated is the title
wait.until(EC.title_contains("Entertain"))
finally:
# the page is ajaxy so the title is originally this:
msg = driver.title
label = tk.Label(self, text=msg, cursor='spinning', font="courier 24", bg="#c63f17")
label.place(x=self.winfo_width()/2, y=self.winfo_height()/2, anchor="center")
self.update() # <--- This is where the problem is
label.destroy()
这似乎并不实际抛出任何错误,我的代码运行的精绝。我无法提供足够的代码来重新定位问题,因为在此之前它只是代码太多,但如果有帮助,我可以告诉你所有测试。我调试了这个代码块,发现在增加一个断点仍然会出现这个错误,但是放置一个之前的任何地方并且跳到都不会打印这个,导致我相信这是self.update()
的某种类型的定时错误,但是当我在self.update()
之前和之后放置了time.sleep(5)
,错误依然存在。因此,单步执行代码并未显示错误,但time.sleep()仍显示错误。这使我感到困惑,我不知道为什么会这样做,我一直在写这个程序2周,这是第一次发生这种情况。如果没有人知道这很好,代码仍然运行完好,我只是好奇这是什么意思,为什么它发生。谢谢!
开头的代码:
# !/usr/bin/python
# coding: utf-8
'''
Created on Jun 23, 2017
@author: jacob <---------------- Line 6
'''
from selenium import webdriver
#from selenium.common.exceptions import TimeoutException
from selenium.webdriver.support.ui import WebDriverWait # available since 2.4.0
from selenium.webdriver.support import expected_conditions as EC# available since 2.26.0
from selenium.webdriver.common.by import By
from selenium.common.exceptions import NoSuchElementException
import os
import platform
import pwd
import re
import time
#import datetime
from time import strftime
import Tkinter as tk
import tkFont as tkfont
from Tkinter import Entry, Menu, Menubutton, Canvas
只有一个想法,但你尝试'update_idletasks()'? – Gribouillis
错误似乎相当清楚:在根窗口被销毁后,某些东西正在触发回调。不可能说出什么,因为错误提示ttk小部件,并且在您发布的代码中没有任何地方使用ttk小部件。 –
@Gribouillis是的我试过了,没有修复它 – Jake