在这个脚本的实现过程中使用到的内置库就是os库,没有通过其他的三方插件进行实现。所以也不用下载其他的python模块,直接调用内置库就OK了。
import os
因为我们使用界面化的处理,这里导入一下pyqt5的模块来实现UI界面布局。
from PyQt5.QtGui import *
from PyQt5.QtCore import *
from PyQt5.QtWidgets import *
import sys
先将需要使用的UI界面编写完成,还是使用前面涉及到的界面开发的编写方式。
class FileDestory(QWidget):
def __init__(self):
super(FileDestory, self).__init__()
self.init_ui()
def init_ui(self):
self.setWindowTitle('电脑垃圾清理器 公众号:[Python 集中营]')
self.setWindowIcon(QIcon('垃圾桶.ico'))
self.setFixedWidth(550)
self.setFixedHeight(80)
self.process = QProgressBar()
self.process.setRange(0, 5)
self.start_btn = QPushButton()
self.start_btn.setText('开始清理')
self.start_btn.clicked.connect(self.start_btn_click)
hbox = QHBoxLayout()
hbox.addWidget(self.process)