码迷,mamicode.com
首页 > 编程语言 > 详细

用python qt4搞了个复制文件界面

时间:2015-06-12 18:59:49      阅读:138      评论:0      收藏:0      [点我收藏+]

标签:

技术分享

下面是部份代码:

# -*- coding: utf-8 -*-

from PyQt4.QtCore import pyqtSignature
from PyQt4.QtGui import QDialog
from PyQt4 import QtCore,QtGui
from Ui_copyfile import Ui_copyfile
import shutil
import os

class copyfile(QDialog, Ui_copyfile):
"""
Class documentation goes here.
"""
def __init__(self, parent=None):
"""
Constructor

@param parent reference to the parent widget (QWidget)
"""
QDialog.__init__(self, parent)
self.setupUi(self)
@pyqtSignature("")
def on_startButton_clicked(self):
if not self.dstlineEdit.text() and not self.srclineEdit.text():
self.textBrowser.append("Input srcdir or dstdir")
filelist = []
if not os.path.exists(self.srclineEdit.text()):
self.textBrowser.append("%s Directory not exits!"%str(self.srclineEdit.text()))
raise SystemExit
for root,dirs,files in os.walk(str(self.srclineEdit.text())):
for file in files:
filename = os.path.join(root,file)
filelist.append(filename)
num = int(len(filelist))
self.progressBar.setMinimum(0)
self.progressBar.setMaximum(num)
for i,filename in enumerate(filelist):
self.textBrowser.append("Copy %s to %s" % (filename,str(self.dstlineEdit.text())))
self.progressBar.setValue(i+1)
shutil.copy2(filename,str(self.dstlineEdit.text()))
if __name__ == "__main__":
import sys
app = QtGui.QApplication(sys.argv)
ui = copyfile()
ui.show()
sys.exit(app.exec_())

用python qt4搞了个复制文件界面

标签:

原文地址:http://www.cnblogs.com/xiewb/p/4572179.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!