【发布时间】:2015-02-12 16:17:59
【问题描述】:
我一直在玩 TkInter,但我无法让它退出。
我可以得到要显示的文本:
from __future__ import absolute_import
from . import BasePlugin
import os, sys
import time
from Tkinter import *
class dis(BasePlugin):
def execute(self, msg, unit, address, when, printer, print_copies):
mseg = str('%s - %s' % (msg, unit))
root = Tk()
text = Text(root, wrap = 'word', bg= 'red', font= 'times 30 bold')
text.insert(INSERT, msg)
text.pack()
root.title('Pager Printer Display')
root.after(6000, _close)
root.mainloop(0)
PLUGIN = dis
但现在我需要在 7 分钟后关闭它。
所以我已经厌倦了添加
def _close():
root.destroy()
到结尾、开头和中间但得到一个错误
Global name _close is undefined
例如
class dis(BasePlugin):
def _close():
root.destroy()
def execute(self, msg, unit, address, when, printer, print_copies):
mseg = str('%s - %s' % (msg, unit))
root = Tk()
text = Text(root, wrap = 'word', bg= 'red', font= 'times 30 bold')
text.insert(INSERT, msg)
text.pack()
root.title('Pager Printer Display')
root.after(6000, _close)
root.mainloop(0)
PLUGIN = dis
有人可以帮忙吗?
【问题讨论】:
标签: python windows python-2.7 tkinter tk