#coding=utf-8'''Created on 2010-10-12@author: lxd'''importwximportwin32conimporttimeimportthreadingclassWorkThread(threading.Thread):def__init__(self):threading.Thread.__init__(self)self.timeToQuit=threading.Event()self.timeToQuit.clear()defstop(self):self.timeToQuit.set()defrun(self):whileTrue:ifnotself.timeToQuit.isSet():print'work'time.sleep(1)else:breakclassFrameWithHotKey(wx.Frame):def__init__(self,*args,**kwargs):wx.Frame.__init__(self,*args,**kwargs)self.regHotKey()self.Bind(wx.EVT_HOTKEY,self.OnHotKeyStart,id=self.hotKeyId_start)self.Bind(wx.EVT_HOTKEY,self.OnHotKeyEnd,id=self.hotKeyId_end)self.Bind(wx.EVT_HOTKEY,self.OnHotKeyQuit,id=self.hotKeyId_quit)self.work=NonedefregHotKey(self):self.hotKeyId_start=100self.RegisterHotKey(self.hotKeyId_start,win32con.MOD_ALT,win32con.VK_F1)self.hotKeyId_end=101self.RegisterHotKey(self.hotKeyId_end,win32con.MOD_ALT,win32con.VK_F2)self.hotKeyId_quit=102self.RegisterHotKey(self.hotKeyId_quit,win32con.MOD_ALT,win32con.VK_F3)defOnHotKeyStart(self,evt):ifnotself.work:self.work=WorkThread()self.work.setDaemon(True)self.work.start()defOnHotKeyEnd(self,evt):ifself.work:self.work.stop()self.work=NonedefOnHotKeyQuit(self,evt):exit()app=wx.App()FrameWithHotKey(None)app.MainLoop()
importosdefjoin(pathname):fdoc=open('doc.txt','a')fordirpath,dirnames,filenamesinos.walk(pathname):forfileinfilenames:iffile.split('.')[-1].lower()=='txt':wholeFile=os.path.join(pathname,file)f=open(wholeFile,'r')fdoc.write(f.read())f.close()print'%s is over'%filefdoc.close()print'all over'if__name__=='__main__':pathname=ur'D:\Program Files\HWOCR60\IMAGE'join(pathname)