Skip to main content

Python - RAR file extract project

from PyQt5 import QtCore, QtGui, QtWidgets
import patoolib
import sys
import PyQt5.sip
class Ui_Frame(object):
    def setupUi(self, Frame):
        self.Frame = Frame
        Frame.setObjectName("Frame")
        Frame.resize(489, 279)
        Frame.setStyleSheet("background-color: rgb(52, 101, 164);")
        Frame.setFrameShape(QtWidgets.QFrame.StyledPanel)
        Frame.setFrameShadow(QtWidgets.QFrame.Raised)
        self.gridLayout = QtWidgets.QGridLayout(Frame)
        self.gridLayout.setObjectName("gridLayout")
        self.txtoutput = QtWidgets.QLineEdit(Frame)
        self.txtoutput.setObjectName("txtoutput")
        self.gridLayout.addWidget(self.txtoutput, 2, 4, 1, 1)
        self.btninput = QtWidgets.QPushButton(Frame)
        self.btninput.setStyleSheet("background-color: rgb(233, 185, 110);")
        self.btninput.setObjectName("btninput")

        self.btninput.clicked.connect(self.BrowseInput_Path)


        self.gridLayout.addWidget(self.btninput, 0, 5, 1, 1)
        self.btnextract = QtWidgets.QPushButton(Frame)
        self.btnextract.setStyleSheet("background-color: rgb(173, 127, 168);")
        self.btnextract.setObjectName("btnextract")
        self.gridLayout.addWidget(self.btnextract, 4, 4, 1, 1)

        self.btnextract.clicked.connect(self.Extract)


        self.label = QtWidgets.QLabel(Frame)
        self.label.setLayoutDirection(QtCore.Qt.RightToLeft)
        self.label.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
        self.label.setObjectName("label")
        self.gridLayout.addWidget(self.label, 0, 2, 1, 1)
        self.label_2 = QtWidgets.QLabel(Frame)
        self.label_2.setLayoutDirection(QtCore.Qt.RightToLeft)
        self.label_2.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
        self.label_2.setObjectName("label_2")
        self.gridLayout.addWidget(self.label_2, 2, 2, 1, 1)
        self.btnoutput = QtWidgets.QPushButton(Frame)
        self.btnoutput.setStyleSheet("background-color: rgb(233, 185, 110);")
        self.btnoutput.setObjectName("btnoutput")
        self.gridLayout.addWidget(self.btnoutput, 2, 5, 1, 1)

        self.btnoutput.clicked.connect(self.BrowseOutput_Dir)


        self.lstrarfiles = QtWidgets.QListWidget(Frame)
        self.lstrarfiles.setObjectName("lstrarfiles")
        self.gridLayout.addWidget(self.lstrarfiles, 1, 4, 1, 1)

        self.retranslateUi(Frame)
        QtCore.QMetaObject.connectSlotsByName(Frame)
        Frame.setTabOrder(self.btninput, self.txtoutput)
        Frame.setTabOrder(self.txtoutput, self.btnoutput)
        Frame.setTabOrder(self.btnoutput, self.btnextract)

    def retranslateUi(self, Frame):
        _translate = QtCore.QCoreApplication.translate
        Frame.setWindowTitle(_translate("Frame", "UnRar - Master"))
        self.btninput.setText(_translate("Frame", "Browse"))
        self.btnextract.setText(_translate("Frame", "Extract"))
        self.label.setText(_translate("Frame", "Rar File :"))
        self.label_2.setText(_translate("Frame", "Unrar Dir :"))
        self.btnoutput.setText(_translate("Frame", "Browse"))

    def BrowseInput_Path(self):
        path = QtWidgets.QFileDialog.getOpenFileNames(filter='*.rar')
        for eachfile in path:
            self.lstrarfiles.addItems(eachfile)
    def BrowseOutput_Dir(self):
        Dir_Path = str(QtWidgets.QFileDialog.getExistingDirectory())
        self.txtoutput.setText(Dir_Path)
    def Extract(self):
        lst = self.lstrarfiles
        for eachitem in range(lst.count()-1):
            RarFile = str(lst.item(eachitem).text())
            patoolib.extract_archive(RarFile, outdir=self.txtoutput.text())
        QtWidgets.QMessageBox.about(self.Frame,"Status","Completed")
if __name__ == "__main__":
   
    app = QtWidgets.QApplication(sys.argv)
    Frame = QtWidgets.QFrame()
    ui = Ui_Frame()
    ui.setupUi(Frame)
    Frame.show()
    sys.exit(app.exec_())

Comments

Popular posts from this blog

Python - PyQt5 set Background image

import sys from PyQt5.QtCore import QSize from PyQt5.QtGui import QImage, QPalette, QBrush from PyQt5.QtWidgets import * class MainWindow ( QWidget ): def __init__ ( self ): QWidget. __init__ ( self ) self .setGeometry( 100 , 100 , 300 , 200 ) oImage = QImage( "test.jpg" ) sImage = oImage.scaled(QSize( 300 , 200 )) # resize Image to widgets size palette = QPalette() palette.setBrush( 10 , QBrush(sImage)) # 10 = Windowrole self .setPalette(palette) self .show() if __name__ == "__main__" : app = QApplication(sys.argv) oMainwindow = MainWindow() sys.exit(app.exec_())

pymsgbox - python package for message box

#This tutorial for to get a confirmation from the user by promting window #Python package "pymsgbox" needs to be install before run this below code #To install "pymsgbox" package go to command prompt and type in "PIP3 INSTALL pymsgbox" import pymsgbox #Displays a message box with OK and Cancel buttons. Number and text of buttons can be customized. Returns the text of the button clicked on. replyV = pymsgbox.confirm( text = 'Please login your application and click on on okay' , title = 'Login Confirmation' , buttons =[ 'OK' , 'Cancel' ]) print (replyV) #Displays a simple message box with text and a single OK button. Returns the text of the button clicked on. replyV = pymsgbox.alert( text = '' , title = '' , button = 'OK' ) print (replyV) #Displays a message box with text input, and OK & Cancel buttons. Returns the text entered, or None if Cancel was clicked. replyV1 = pyms