本文整理匯總了Python中importer.Importer.isAlive方法的典型用法代碼示例。如果您正苦於以下問題:Python Importer.isAlive方法的具體用法?Python Importer.isAlive怎麽用?Python Importer.isAlive使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類importer.Importer
的用法示例。
在下文中一共展示了Importer.isAlive方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: MyFrame
# 需要導入模塊: from importer import Importer [as 別名]
# 或者: from importer.Importer import isAlive [as 別名]
class MyFrame(wx.Frame):
""" We simply derive a new class of Frame. """
def __init__(self, parent, title, opts, sources):
wx.Frame.__init__(self, parent, title=title, size=((800 if opts.verbosity < 2 else 1100), 400))
self.lock = Lock()
self.opts = opts
self.control = wx.TextCtrl(self, style=wx.TE_MULTILINE)
self.control.SetEditable(False)
self.Show(True)
self.twiddle_mode = 2
self.twiddle_next = 0
self.twiddle_me = '|/-\\'
self.twiddle_size = len(self.twiddle_me)
self.importer = Importer(self, sources, self.opts)
self.Bind(wx.EVT_CLOSE, self.onClose)
def onClose(self, event):
self.importer.interrupt.set()
while self.importer.isAlive():
self.importer.join(1)
wx.Yield()
self.Destroy()
def __append_text(self, s):
with self.lock:
self.control.AppendText(s)
def logger(self, s):
# print s
if self.twiddle_mode != 2:
re_twiddle = True
self.twiddle(2)
else:
re_twiddle = False
self.__append_text("%s\n" % (s,))
if re_twiddle:
self.twiddle(0)
def twiddle(self, mode):
# Mode (0, 1, 2) == (start (add first twiddle), advance, erase)
self.twiddle_mode = mode
if mode == 0:
# append
self.twiddle_next = 0
self.__append_text(self.twiddle_me[self.twiddle_next])
elif mode == 1:
# replace
lastPos = self.control.GetLastPosition()
self.control.Replace(lastPos-1, lastPos, self.twiddle_me[self.twiddle_next])
elif mode == 2:
# erase
lastPos = self.control.GetLastPosition()
self.control.Remove(lastPos-1, lastPos)
# Advance
self.twiddle_next = (self.twiddle_next + 1) % self.twiddle_size