-
Notifications
You must be signed in to change notification settings - Fork 0
/
surface.py
104 lines (84 loc) · 3.95 KB
/
surface.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'Surface.ui'
#
# Created by: PyQt5 UI code generator 5.15.2
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again. Do not edit this file unless you know what you are doing.
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtGui import QPalette, QBrush, QPixmap
from PyQt5.QtWidgets import QMessageBox
import ProgressBar
import time
import file
class Ui_Form(object):
def setupUi(self, Form):
Form.setObjectName("Form")
Form.resize(400, 300)
Form.setLayoutDirection(QtCore.Qt.LeftToRight)
Form.setAutoFillBackground(False)
self.verticalLayout = QtWidgets.QVBoxLayout(Form)
self.verticalLayout.setObjectName("verticalLayout")
# self.widget = QtWidgets.QWidget(Form)
self.widget = MyWeight(Form)
self.widget.setAcceptDrops(True)
self.widget.setObjectName("widget")
self.widget.setAutoFillBackground(True)
palette = QPalette()
palette.setBrush(self.widget.backgroundRole(), QtGui.QBrush(
QtGui.QPixmap(file.resource_path('pic/drop-files-here-extra.jpg')).scaled(self.widget.width() * 3.8,
self.widget.height() * 9))) # 设置背景图片
self.widget.setPalette(palette)
self.verticalLayout.addWidget(self.widget)
# self.pushButton = QtWidgets.QPushButton(Form)
# self.pushButton.setMinimumSize(QtCore.QSize(0, 40))
# self.pushButton.setMaximumSize(QtCore.QSize(100, 16777215))
# self.pushButton.setObjectName("pushButton")
# self.verticalLayout.addWidget(self.pushButton, 0, QtCore.Qt.AlignHCenter)
# self.pushButton.clicked.connect(self.diy_C)
self.retranslateUi(Form)
QtCore.QMetaObject.connectSlotsByName(Form)
def retranslateUi(self, Form):
_translate = QtCore.QCoreApplication.translate
Form.setWindowTitle(_translate("pptx_Unlocker", "pptx_Unlocker"))
# self.pushButton.setText(_translate("Form", "Start!"))
class MyWeight(QtWidgets.QWidget):
url_list = []
def __init__(self, parent=None):
super().__init__(parent)
self.setAcceptDrops(True) # 必须有(当然,图标模式的列表控件已默认打开)
# 拖动时依次调用
# dragEnterEvent不是必需的
# dragMoveEvent也不是必需的,没它的副作用是拖动图标有个禁止的小标志
# dragMoveEvent会在拖动的过程中频繁调用,计算量大的代码不宜放在此处
def dragEnterEvent(self, event): # 拖动开始时,以及刚进入目标控件时调用
# print("进入%s" % self.objectName())
if event.mimeData().hasUrls():
urls = event.mimeData().urls() # 返回一个ulr路径列表
# print(urls)
self.url_list = urls
event.accept()
# def dragMoveEvent(self, event):
# # print("在%s中开始移动" % self.objectName())
# event.accept()
def dropEvent(self, event):
# print("目标控件是%s" % self.objectName())
# print(event.mimeData().formats())
bar = ProgressBar.pyqtbar() # 创建实例
# total_number = self.url_list.len() # 总任务数
# print(len(self.url_list))
total_number = len(self.url_list)
# print(self.url_list)
for index, url in enumerate(self.url_list):
file_path = url.toString().replace("file:///", "")
# print(index)
# print(file_path)
file.unlock_pptx(file_path)
for process in range(1, 100):
time.sleep(0.005)
bar.set_value(index + 1, total_number, process)
# print("finish")
bar.close
QMessageBox.information(self, # 使用infomation信息框
"Finish",
"文件解锁已完成,快去编辑试试吧")