本文整理汇总了Python中importer.Importer.join方法的典型用法代码示例。如果您正苦于以下问题:Python Importer.join方法的具体用法?Python Importer.join怎么用?Python Importer.join使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类importer.Importer
的用法示例。
在下文中一共展示了Importer.join方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: MyFrame
# 需要导入模块: from importer import Importer [as 别名]
# 或者: from importer.Importer import join [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