文件名称:PYTHON写的文件比较
文件大小:27.98MB
文件格式:RAR
更新时间:2021-09-30 08:10:16
文件比较
# -*- coding: utf-8 -*- ''' 事件传播有两种类型事件:基本事件和命令事件。它们不同于传播方式。事件传播是指事件从子部件 传到父部件和父窗口的父窗口等。基本事件不传播,命令事件传播。比如wx.CloseEvent是一个基本事件。 它没有传到父窗口的一样。默认情况下, 这种事件在一个事件处理器里就停止传播。如果想继续传播, 我们必须调用Skip()方法。 用event.Skip()方法调用事件默认处理程序 ''' import wx import threading from os.path import getsize def CompFile(win,file1,file2): try: if getsize(file1) != getsize(file2): win.m_staticText4.SetFont(win.font) win.m_staticText4.SetForegroundColour(wx.Colour(255,0,0)) win.m_staticText4.SetLabelText('文件比较结果:两个文件比较结果不一样') win.m_button4.SetFocus() win.m_button4.SetDefault() return f1=open(file1,'rb') f2=open(file2,'rb') except Exception as e: win.m_staticText4.SetFont(win.font) win.m_staticText4.SetForegroundColour(wx.Colour(255,0,255)) win.m_staticText4.SetLabelText('打开文件错误:'+e.strerror) win.m_button4.SetFocus() win.m_button4.SetDefault() else: for f11,f22 in zip(f1.read(),f2.read()): if f11 != f22: win.m_staticText4.SetFont(win.font) win.m_staticText4.SetForegroundColour(wx.Colour(255,0,0)) win.m_staticText4.SetLabelText('文件比较结果:两个文件比较结果不一样') win.m_button4.SetFocus() win.m_button4.SetDefault() return else: win.m_staticText4.SetFont(win.font) win.m_staticText4.SetForegroundColour(wx.Colour(0,155,0)) win.m_staticText4.SetLabelText('文件比较结果:两个文件比较结果一模一样') win.m_button4.SetFocus() win.m_button4.SetDefault() finally: try: f1.close() f1.close() except: pass class FileDrop(wx.FileDropTarget): def __init__(self, textctrl): wx.FileDropTarget.__init__(self) self.textctrl = textctrl def OnDropFiles(self, x, y, filePath): # 当文件被拖入grid后,会调用此方法 self.textctrl.SetValue(''.join(filePath)) return 1 class Mywin(wx.Dialog): def __init__(self,parent,title): super().__init__(parent,title=title,size=(500,200),style=wx.DEFAULT_FRAME_STYLE|wx.STAY_ON_TOP) self.InitUI() def InitUI(self): icon = wx.Icon('33.ico', wx.BITMAP_TYPE_ICO) self.SetIcon(icon) self.SetSizeHints( wx.DefaultSize, wx.DefaultSize ) bSizer7 = wx.BoxSizer( wx.VERTICAL ) bSizer8 = wx.BoxSizer( wx.HORIZONTAL ) self.m_staticText2 = wx.StaticText( self, wx.ID_ANY, u"第一个文件", wx.DefaultPosition, wx.DefaultSize, 0 ) self.m_staticText2.Wrap( -1 ) bSizer8.Add( self.m_staticText2, 0, wx.ALL, 10 ) self.m_textCtrl3 = wx.TextCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 ) self.m_textCtrl3.Bind(wx.EVT_TEXT_ENTER,self.onTextChange) self.fileDrop = FileDrop(self.m_textCtrl3) self.m_textCtrl3.SetDropTarget(self.fileDrop) bSizer8.Add( self.m_textCtrl3, 1, wx.ALL, 5 ) bSizer7.Add( bSizer8, 0, wx.EXPAND, 5 ) bSizer9 = wx.BoxSizer( wx.HORIZONTAL ) self.m_staticText3 = wx.StaticText( self, wx.ID_ANY, u"第二个文件", wx.DefaultPosition, wx.DefaultSize, 0 ) self.m_staticText3.Wrap( -1 ) bSizer9.Add( self.m_staticText3, 0, wx.ALL, 10 ) self.m_textCtrl4 = wx.TextCtrl( self, 5001, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 ) self.fileDrop1 = FileDrop(self.m_textCtrl4) self.m_textCtrl4.SetDropTarget(self.fileDrop1) bSizer9.Add( self.m_textCtrl4, 1, wx.ALL, 5 ) bSizer7.Add( bSizer9, 0, wx.EXPAND, 5 ) bSizer11 = wx.BoxSizer( wx.HORIZONTAL ) self.m_button4 = wx.Button( self, wx.ID_ANY, u"文件比较", wx.DefaultPosition, wx.DefaultSize, 0 ) self.m_button4.Bind(wx.EVT_BUTTON,self.OnButton) self.m_button4.SetFocus() self.m_button4.SetDefault() bSizer11.Add( self.m_button4, 0, wx.ALL|wx.ALIGN_CENTER_HORIZONTAL, 5 ) self.m_button5 = wx.Button( self, wx.ID_ANY, u"清空文本", wx.DefaultPosition, wx.DefaultSize, 0 ) self.m_button5.Bind(wx.EVT_BUTTON,self.OnClear) bSizer11.Add( self.m_button5, 0, wx.ALL|wx.ALIGN_CENTER_HORIZONTAL, 5 ) bSizer7.Add( bSizer11, 0, wx.ALIGN_CENTER|wx.ALIGN_LEFT, 5 ) bSizer12 = wx.BoxSizer( wx.VERTICAL ) self.font=wx.Font(16,wx.ROMAN,wx.NORMAL,wx.NORMAL) self.font.FaceName="微软雅黑" self.m_staticText4 = wx.StaticText( self, wx.ID_ANY, u"文件比较结果:", wx.DefaultPosition, wx.DefaultSize, 0 ) self.m_staticText4.SetFont(self.font) self.m_staticText4.Wrap( -1 ) bSizer12.Add( self.m_staticText4, 0, wx.ALL, 5 ) bSizer7.Add( bSizer12, 1, wx.EXPAND, 5 ) self.SetSizer( bSizer7 ) self.Layout() self.Bind(wx.EVT_CLOSE,self.onClose) self.Centre( wx.BOTH ) self.Show() def onTextChange(self,evt): self.m_button4.SetFocus() self.m_button4.SetDefault() def OnButton(self,event): file1=self.m_textCtrl3.GetValue() file2=self.m_textCtrl4.GetValue() t1=threading.Thread(target=CompFile,args=(self,file1,file2),name="CompFile") t1.start() self.m_staticText4.SetLabelText('正在比较文件请稍后!...') #CompFile(self,file1,file2) def OnClear(self,event): self.m_staticText4.SetForegroundColour(wx.Colour(0,0,0)) self.m_staticText4.SetLabelText('文件比较结果:') self.m_textCtrl3.SetValue('') self.m_textCtrl4.SetValue('') self.m_button4.SetFocus() self.m_button4.SetDefault() def onClose(self,e): self.Destroy() app=wx.App() Mywin(None,'文件比较') app.MainLoop()
【文件预览】:
文件比较
----文件比较.exe(1.43MB)
----api-ms-win-core-handle-l1-1-0.dll(3KB)
----api-ms-win-crt-string-l1-1-0.dll(17KB)
----_hashlib.pyd(1.38MB)
----wx.siplib.pyd(111KB)
----api-ms-win-crt-environment-l1-1-0.dll(12KB)
----api-ms-win-crt-locale-l1-1-0.dll(12KB)
----api-ms-win-core-datetime-l1-1-0.dll(3KB)
----api-ms-win-core-localization-l1-2-0.dll(14KB)
----_lzma.pyd(242KB)
----api-ms-win-core-file-l1-1-0.dll(5KB)
----_socket.pyd(64KB)
----api-ms-win-core-sysinfo-l1-1-0.dll(4KB)
----api-ms-win-core-synch-l1-2-0.dll(12KB)
----api-ms-win-core-memory-l1-1-0.dll(4KB)
----wx._core.pyd(7.12MB)
----unicodedata.pyd(878KB)
----api-ms-win-crt-convert-l1-1-0.dll(15KB)
----api-ms-win-core-errorhandling-l1-1-0.dll(3KB)
----api-ms-win-core-synch-l1-1-0.dll(4KB)
----base_library.zip(721KB)
----api-ms-win-crt-math-l1-1-0.dll(20KB)
----api-ms-win-core-processthreads-l1-1-0.dll(5KB)
----api-ms-win-crt-conio-l1-1-0.dll(12KB)
----api-ms-win-core-file-l1-2-0.dll(11KB)
----api-ms-win-crt-utility-l1-1-0.dll(12KB)
----api-ms-win-crt-filesystem-l1-1-0.dll(13KB)
----api-ms-win-core-profile-l1-1-0.dll(3KB)
----33.ico(4KB)
----api-ms-win-core-timezone-l1-1-0.dll(11KB)
----api-ms-win-core-string-l1-1-0.dll(3KB)
----api-ms-win-core-processenvironment-l1-1-0.dll(4KB)
----_ssl.pyd(1.96MB)
----pyexpat.pyd(185KB)
----api-ms-win-core-debug-l1-1-0.dll(3KB)
----api-ms-win-crt-multibyte-l1-1-0.dll(19KB)
----api-ms-win-core-util-l1-1-0.dll(3KB)
----api-ms-win-crt-time-l1-1-0.dll(14KB)
----api-ms-win-core-namedpipe-l1-1-0.dll(4KB)
----api-ms-win-crt-process-l1-1-0.dll(12KB)
----api-ms-win-core-libraryloader-l1-1-0.dll(4KB)
----wxbase30u_net_vc140_x64.dll(186KB)
----api-ms-win-crt-stdio-l1-1-0.dll(17KB)
----api-ms-win-crt-runtime-l1-1-0.dll(16KB)
----MSVCP140.dll(625KB)
----api-ms-win-core-heap-l1-1-0.dll(4KB)
----api-ms-win-core-interlocked-l1-1-0.dll(3KB)
----api-ms-win-core-processthreads-l1-1-1.dll(12KB)
----wxmsw30u_core_vc140_x64.dll(5.8MB)
----api-ms-win-core-rtlsupport-l1-1-0.dll(4KB)
----ucrtbase.dll(961KB)
----wxbase30u_vc140_x64.dll(2.48MB)
----api-ms-win-core-file-l2-1-0.dll(11KB)
----select.pyd(20KB)
----_bz2.pyd(86KB)
----22.exe.manifest(1KB)
----VCRUNTIME140.dll(86KB)
----api-ms-win-core-console-l1-1-0.dll(3KB)
----api-ms-win-crt-heap-l1-1-0.dll(12KB)
----python36.dll(3.4MB)