Made a copy of the file interface with Python qt4.

Source: Internet
Author: User

Here's some code:

#-*-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_ ())

Made a copy of the file interface with Python qt4.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.