wxpython开发的上传下载功能

上传资料的小程序python wx

import wx
import win32api
import wmi
import os
import shutil
import threading
import time

class ExampleFrame(wx.Panel):
def init(self, parent):
wx.Panel.init(self, parent)
# self.SetBackgroundColour((random.randint(0, 255), random.randint(0, 255), random.randint(0, 255)))
self.SetBackgroundColour((248, 248, 248))
self.name = win32api.GetUserName() # 获取用户名
self.count=0
self.se_count=0
self.senamec=0
self.pang = None
self.se_name=None
self.se_path = None
self.bq_path = None
self.ie_path = None
self.fire_path = None
self.google_path = None
self.obj = wmi.WMI().Win32_OperatingSystem()[0]
self.win_banben = self.obj.OSArchitecture # 判断系统是多少位的
self.system_version = self.obj.Caption # 判断系统是win7还是win10的
menuBar = wx.MenuBar()
fileMenu = wx.Menu()
newItem = wx.MenuItem(fileMenu, id=wx.ID_NEW, text=‘查看使用说明’, kind=wx.ITEM_NORMAL)
# fileMenu.AppendItem(newItem) 被下面的方法替代了
fileMenu.Append(newItem)
menuBar.Append(fileMenu, title=‘使用说明’)
parent.SetMenuBar(menuBar)
parent.Bind(wx.EVT_MENU, self.help, newItem)
self.bianq = wx.CheckBox(self, label=“系统自带便签”, pos=(20, 10))
self.Bind(wx.EVT_CHECKBOX, self.Bianqian, self.bianq)
self.bianqf = wx.StaticText(self, label="(勾选此项将复制您的便签)", pos=(150, 10))
# wx.CheckBox.SetValue(self.bianq, True)
self.liu_IE = wx.CheckBox(self, label=“IE浏览器收藏夹”, pos=(20, 45))
self.Bind(wx.EVT_CHECKBOX, self.Liulanqi_IE, self.liu_IE)
self.liulfp = wx.StaticText(self, label="(勾选此项将复制您的IE浏览器收藏夹)", pos=(150, 45))
self.liu_GOOG = wx.CheckBox(self, label=“谷歌浏览器收藏夹”, pos=(20, 80))
self.Bind(wx.EVT_CHECKBOX, self.Liulanqi_GOOG, self.liu_GOOG)
self.liulf1 = wx.StaticText(self, label="(勾选此项将复制您的谷歌浏览器收藏夹)", pos=(150, 80))
self.liu_FIRE = wx.CheckBox(self, label=“火狐浏览器收藏夹”, pos=(20, 115))
self.Bind(wx.EVT_CHECKBOX, self.Liulanqi_fire, self.liu_FIRE)
self.liulf = wx.StaticText(self, label="(勾选此项将复制您的火狐浏览器收藏夹)", pos=(150, 115))
self.qita = wx.CheckBox(self, label=“其他文件”, pos=(20, 157))
self.Bind(wx.EVT_CHECKBOX, self.Qita, self.qita)
# self.qitaf=wx.StaticText(self, label="(勾选此项将复制您选定的文件)", pos=(130, 210))
self.selectButton = wx.Button(self, label=‘选择文件夹’, pos=(100, 154))
self.qitac= wx.StaticText(self, label="(其他文件选项也是默认勾选状态,如果没有要备份的文件夹,请取消此项勾选)", pos=(20, 194))
self.selectButton.Bind(wx.EVT_BUTTON, self.Select)
self.contents_se = wx.TextCtrl(self, style=wx.TE_READONLY, pos=(200, 154), size=(200, 30))
self.downloadButton = wx.Button(self, label=‘恢复’, pos=(140, 500))
# self.downloadButton.Bind(wx.EVT_BUTTON, self.Startdown)
self.uploadButton = wx.Button(self, label=‘上传’, pos=(30, 500))
# self.uploadButton.Bind(wx.EVT_BUTTON, self.Startup)
self.gauge = wx.Gauge(self, -1, 100, (20, 250), (460, 35), style=wx.GA_HORIZONTAL)
self.Bind(wx.EVT_BUTTON, self.Load, self.uploadButton)
self.Bind(wx.EVT_BUTTON, self.Resu, self.downloadButton)
self.contents_zt = wx.TextCtrl(self, style=wx.TE_MULTILINE | wx.TE_READONLY, pos=(20, 315), size=(460, 150))
self.contents_zt.AppendText(‘为防止意外发生,使用前请一定阅读工具栏的使用说明’)
# self.test=self.find_dir(‘places.sqlite’,‘C:\Users\%s\AppData\Roaming\Mozilla\Firefox\Profiles’%self.name)
# self.contents_zt.AppendText(self.test)
self.Bqmain()
self.qitamain()
self.firemain()
self.googmain()
self.iemain()
parent.Show()

def Startup(self):
    try:
        up_path='d:\\chuanshu\\%s' % self.name
        up_bqpath='d:\\chuanshu\\%s\\bianqian' % self.name
        up='d:\\chuanshu'
        server_path='\\\\10.4.248.130\\test\\JD\\bd\\testcopy'
        up_iepath='d:\\chuanshu\\%s\\ie' % self.name
        up_googlepath='d:\\chuanshu\\%s\\google' % self.name
        up_firepath='d:\\chuanshu\\%s\\fire' % self.name
        up_serp='\\\\10.4.248.130\\test\\JD\\bd\\testcopy\\%s\\您选的文件'% self.name
        up_serb='\\\\10.4.248.130\\test\\JD\\bd\\testcopy\\%s\\bianqian'% self.name
        up_serf = '\\\\10.4.248.130\\test\\JD\\bd\\testcopy\\%s\\fire' % self.name
        up_sepath='d:\\chuanshu\\%s\\您选的文件' % self.name
        self.count=0
        self.contents_zt.Value = ''
        if self.se_count > 2:
            wx.MessageBox("所选文件夹大小超过2G,请重新选择", "警告", wx.OK | wx.ICON_INFORMATION)
        else:
            while self.count < 6:
                if self.bq_path == None and self.ie_path == None and self.google_path == None and self.fire_path == None and self.pang == None:
                    self.contents_zt.AppendText('没有选择任何文件')
                    wx.MessageBox("未选择任一选项", "警告", wx.OK | wx.ICON_INFORMATION)
                    break
                if self.pang == True and self.senamec < 0.1:
                    wx.MessageBox("未选择文件夹,如无需备份文件夹,请取消此项勾选!", "警告", wx.OK | wx.ICON_INFORMATION)
                  
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值