所以我今天調試我的一些代碼,發現在輸出新的消息: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