写了一个基于WXpython的小程序,把文件快速合并功能进行打包

尴尬的是,360竟然给我报警了,说这个是勒索病毒。。。

import os
import shutil
import wx

def copy_file(event):
    old_filedir = old_path_text.GetValue()
    new_filedir = new_path_text.GetValue()
    if not os.path.exists(old_filedir):
        dlg = wx.MessageDialog(None, u"要合并的文件夹路径不存在,请确认!", u"警告",wx.OK)
        dlg.ShowModal()
        dlg.Destroy()
    else:
        try:
            os.makedirs(new_filedir)
        except:
            pass
        for root, dirs, files in os.walk(old_filedir):
            for file in files:
                try:
                    shutil.copy(os.path.join(root,file), new_filedir)
                except:
                    continue
        dlg = wx.MessageDialog(None, u"已经合并成功!", u"Mission Complete", wx.OK)
        dlg.ShowModal()
        dlg.Destroy()

app = wx.App()
frame = wx.Frame(None,title = "文件快速合并小工具",pos = (600,200),size = (500,150))

old_file_text = wx.TextCtrl(frame, style=wx.TE_READONLY, pos = (5,5),value = '要复制的文件夹路径:',size = (135, 24))
old_path_text = wx.TextCtrl(frame, pos=(140,5),size = (340,24))
new_file_text = wx.TextCtrl(frame, style=wx.TE_READONLY, pos = (5,34),value = '要黏贴的文件夹路径:',size = (135, 24))
new_path_text = wx.TextCtrl(frame,pos = (140,34),size = (340,24))
combine_button = wx.Button(frame,label = "开始合并",pos = (5,63),size = (475,48))
font = wx.Font(25, wx.SWISS, wx.NORMAL, wx.BOLD)
combine_button.SetFont(font)

combine_button.Bind(wx.EVT_BUTTON, copy_file)
frame.Show()
app.MainLoop()

注:最后打包的时候用pyinstaller -F 文件快速合并小工具.py --noconsole的话就不会用dos窗口了

猜你喜欢

转载自blog.csdn.net/weixin_42029733/article/details/85250714
今日推荐