Commit 0f347ed8 authored by dovahkiin's avatar dovahkiin

复制一份excel文件到处理好的图片的路径之中。

parent 2cf75cd4
......@@ -166,7 +166,7 @@ if __name__ == '__main__':
else:
while True:
try:
wb.save('image coordinate size.xlsx')
wb.save(excel_file_name)
break
except PermissionError:
print("please close the Excel file")
......@@ -265,4 +265,8 @@ if __name__ == '__main__':
sheet1[translation_index] = translation
sheet1[Original_index] = Original
start_line_number += 1
wb.save('image coordinate size.xlsx')
wb.save(excel_file_name)
wb.close()
# 将本地的表格复制过去
......@@ -14,7 +14,7 @@ from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(571, 368)
MainWindow.resize(640, 400)
icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap("pic/cut_pic.ico"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
MainWindow.setWindowIcon(icon)
......@@ -34,6 +34,11 @@ class Ui_MainWindow(object):
self.horizontalLayout = QtWidgets.QHBoxLayout(self.widget_3)
self.horizontalLayout.setObjectName("horizontalLayout")
self.widget_2 = QtWidgets.QWidget(self.widget_3)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Preferred)
sizePolicy.setHorizontalStretch(5)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.widget_2.sizePolicy().hasHeightForWidth())
self.widget_2.setSizePolicy(sizePolicy)
self.widget_2.setObjectName("widget_2")
self.horizontalLayout_3 = QtWidgets.QHBoxLayout(self.widget_2)
self.horizontalLayout_3.setObjectName("horizontalLayout_3")
......@@ -58,7 +63,18 @@ class Ui_MainWindow(object):
self.btn_analysis.setObjectName("btn_analysis")
self.horizontalLayout_3.addWidget(self.btn_analysis)
self.horizontalLayout.addWidget(self.widget_2)
self.widget = QtWidgets.QWidget(self.widget_3)
self.stk_set_cut_type = QtWidgets.QStackedWidget(self.widget_3)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Preferred)
sizePolicy.setHorizontalStretch(1)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.stk_set_cut_type.sizePolicy().hasHeightForWidth())
self.stk_set_cut_type.setSizePolicy(sizePolicy)
self.stk_set_cut_type.setObjectName("stk_set_cut_type")
self.page_4 = QtWidgets.QWidget()
self.page_4.setObjectName("page_4")
self.verticalLayout_5 = QtWidgets.QVBoxLayout(self.page_4)
self.verticalLayout_5.setObjectName("verticalLayout_5")
self.widget = QtWidgets.QWidget(self.page_4)
self.widget.setObjectName("widget")
self.verticalLayout = QtWidgets.QVBoxLayout(self.widget)
self.verticalLayout.setObjectName("verticalLayout")
......@@ -81,12 +97,91 @@ class Ui_MainWindow(object):
self.cbx_auto_1 = QtWidgets.QCheckBox(self.widget)
self.cbx_auto_1.setObjectName("cbx_auto_1")
self.verticalLayout.addWidget(self.cbx_auto_1)
self.btn_selfset = QtWidgets.QPushButton(self.widget)
self.btn_selfset.setObjectName("btn_selfset")
self.verticalLayout.addWidget(self.btn_selfset)
self.cbx_english.raise_()
self.cbx_equal_position.raise_()
self.cbx_show.raise_()
self.cbx_equal_size.raise_()
self.cbx_auto_1.raise_()
self.horizontalLayout.addWidget(self.widget)
self.btn_selfset.raise_()
self.verticalLayout_5.addWidget(self.widget)
self.stk_set_cut_type.addWidget(self.page_4)
self.page_5 = QtWidgets.QWidget()
self.page_5.setObjectName("page_5")
self.verticalLayout_6 = QtWidgets.QVBoxLayout(self.page_5)
self.verticalLayout_6.setObjectName("verticalLayout_6")
self.win_range_cut_x = QtWidgets.QWidget(self.page_5)
self.win_range_cut_x.setObjectName("win_range_cut_x")
self.horizontalLayout_2 = QtWidgets.QHBoxLayout(self.win_range_cut_x)
self.horizontalLayout_2.setObjectName("horizontalLayout_2")
self.label = QtWidgets.QLabel(self.win_range_cut_x)
self.label.setObjectName("label")
self.horizontalLayout_2.addWidget(self.label)
self.sbx_x = QtWidgets.QSpinBox(self.win_range_cut_x)
self.sbx_x.setPrefix("")
self.sbx_x.setMaximum(65535)
self.sbx_x.setObjectName("sbx_x")
self.horizontalLayout_2.addWidget(self.sbx_x)
self.verticalLayout_6.addWidget(self.win_range_cut_x)
self.win_range_cut_y = QtWidgets.QWidget(self.page_5)
self.win_range_cut_y.setObjectName("win_range_cut_y")
self.horizontalLayout_5 = QtWidgets.QHBoxLayout(self.win_range_cut_y)
self.horizontalLayout_5.setObjectName("horizontalLayout_5")
self.label_2 = QtWidgets.QLabel(self.win_range_cut_y)
self.label_2.setObjectName("label_2")
self.horizontalLayout_5.addWidget(self.label_2)
self.sbx_y = QtWidgets.QSpinBox(self.win_range_cut_y)
self.sbx_y.setMaximum(65535)
self.sbx_y.setObjectName("sbx_y")
self.horizontalLayout_5.addWidget(self.sbx_y)
self.verticalLayout_6.addWidget(self.win_range_cut_y)
self.win_range_cut_w = QtWidgets.QWidget(self.page_5)
self.win_range_cut_w.setObjectName("win_range_cut_w")
self.horizontalLayout_6 = QtWidgets.QHBoxLayout(self.win_range_cut_w)
self.horizontalLayout_6.setObjectName("horizontalLayout_6")
self.label_3 = QtWidgets.QLabel(self.win_range_cut_w)
self.label_3.setObjectName("label_3")
self.horizontalLayout_6.addWidget(self.label_3)
self.sbx_w = EvenSpinBox(self.win_range_cut_w)
self.sbx_w.setMinimum(2)
self.sbx_w.setMaximum(65534)
self.sbx_w.setSingleStep(2)
self.sbx_w.setObjectName("sbx_w")
self.horizontalLayout_6.addWidget(self.sbx_w)
self.verticalLayout_6.addWidget(self.win_range_cut_w)
self.win_range_cut_h = QtWidgets.QWidget(self.page_5)
self.win_range_cut_h.setObjectName("win_range_cut_h")
self.horizontalLayout_7 = QtWidgets.QHBoxLayout(self.win_range_cut_h)
self.horizontalLayout_7.setObjectName("horizontalLayout_7")
self.label_4 = QtWidgets.QLabel(self.win_range_cut_h)
self.label_4.setObjectName("label_4")
self.horizontalLayout_7.addWidget(self.label_4)
self.sbx_h = EvenSpinBox(self.win_range_cut_h)
self.sbx_h.setMinimum(2)
self.sbx_h.setMaximum(65534)
self.sbx_h.setSingleStep(2)
self.sbx_h.setObjectName("sbx_h")
self.horizontalLayout_7.addWidget(self.sbx_h)
self.verticalLayout_6.addWidget(self.win_range_cut_h)
self.cbb_range_group = QtWidgets.QComboBox(self.page_5)
self.cbb_range_group.setInsertPolicy(QtWidgets.QComboBox.InsertAtBottom)
self.cbb_range_group.setMinimumContentsLength(1)
self.cbb_range_group.setObjectName("cbb_range_group")
self.cbb_range_group.addItem("")
self.verticalLayout_6.addWidget(self.cbb_range_group)
self.btn_new_range_group = QtWidgets.QPushButton(self.page_5)
self.btn_new_range_group.setObjectName("btn_new_range_group")
self.verticalLayout_6.addWidget(self.btn_new_range_group)
self.btn_del_range_group = QtWidgets.QPushButton(self.page_5)
self.btn_del_range_group.setObjectName("btn_del_range_group")
self.verticalLayout_6.addWidget(self.btn_del_range_group)
self.btn_selfset_return = QtWidgets.QPushButton(self.page_5)
self.btn_selfset_return.setObjectName("btn_selfset_return")
self.verticalLayout_6.addWidget(self.btn_selfset_return)
self.stk_set_cut_type.addWidget(self.page_5)
self.horizontalLayout.addWidget(self.stk_set_cut_type)
self.horizontalLayout_4.addWidget(self.widget_3)
self.stackedWidget.addWidget(self.page)
self.page_2 = QtWidgets.QWidget()
......@@ -98,7 +193,7 @@ class Ui_MainWindow(object):
self.scrollArea.setWidgetResizable(True)
self.scrollArea.setObjectName("scrollArea")
self.scrollAreaWidgetContents = QtWidgets.QWidget()
self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, 0, 533, 256))
self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, 0, 98, 113))
self.scrollAreaWidgetContents.setMinimumSize(QtCore.QSize(0, 0))
self.scrollAreaWidgetContents.setObjectName("scrollAreaWidgetContents")
self.verticalLayout_4 = QtWidgets.QVBoxLayout(self.scrollAreaWidgetContents)
......@@ -145,7 +240,7 @@ class Ui_MainWindow(object):
self.verticalLayout_3.addWidget(self.stackedWidget)
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtWidgets.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 571, 23))
self.menubar.setGeometry(QtCore.QRect(0, 0, 640, 23))
self.menubar.setObjectName("menubar")
self.menu = QtWidgets.QMenu(self.menubar)
self.menu.setObjectName("menu")
......@@ -160,6 +255,7 @@ class Ui_MainWindow(object):
self.retranslateUi(MainWindow)
self.stackedWidget.setCurrentIndex(0)
self.stk_set_cut_type.setCurrentIndex(1)
self.lwg_confirmed.setCurrentRow(-1)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
MainWindow.setTabOrder(self.let_psd_name, self.btn_analysis)
......@@ -182,6 +278,20 @@ class Ui_MainWindow(object):
self.cbx_show.setText(_translate("MainWindow", "显示"))
self.cbx_auto_1.setText(_translate("MainWindow", "智能\n"
"等大"))
self.btn_selfset.setText(_translate("MainWindow", "自定义"))
self.label.setText(_translate("MainWindow", "x:"))
self.sbx_x.setSuffix(_translate("MainWindow", "px"))
self.label_2.setText(_translate("MainWindow", "y:"))
self.sbx_y.setSuffix(_translate("MainWindow", "px"))
self.label_3.setText(_translate("MainWindow", "w:"))
self.sbx_w.setSuffix(_translate("MainWindow", "px"))
self.label_4.setText(_translate("MainWindow", "h:"))
self.sbx_h.setSuffix(_translate("MainWindow", "px"))
self.cbb_range_group.setItemText(0, _translate("MainWindow", "范围1"))
self.btn_new_range_group.setText(_translate("MainWindow", "新建"))
self.btn_del_range_group.setText(_translate("MainWindow", "删除"))
self.btn_selfset_return.setText(_translate("MainWindow", "返回"))
self.lib_info_data.setText(_translate("MainWindow", "你好世界"))
self.menu.setTitle(_translate("MainWindow", "设置"))
self.act_set_order.setText(_translate("MainWindow", "替换规则"))
from EvenSpinBox import EvenSpinBox
# import resource
import os
import shutil
import sys
import time
from ctypes import *
......@@ -225,6 +226,23 @@ class Pyqt5_Cut_psd(QtWidgets.QMainWindow, Ui_Form):
pass
def cut_pic_ok(self):
# 复制一份excel到每个psd的路径下方
paths = set()
for psd_name_i in self.let_psd_name.text().split(","):
psd_name = psd_name_i.replace("'","").strip()
# paths.add(os.path.split(psd_name)[0])
paths.add(os.path.splitext(psd_name)[0])
print(paths)
excel_file_name = 'image coordinate size.xlsx'
for psd_path in paths:
# 判断psd_path是否等于当前路径
if os.path.samefile(psd_path, os.getcwd()):
continue
# 判断是否存在excel文件
if os.path.exists(os.path.join(psd_path, excel_file_name)):
os.remove(os.path.join(psd_path, excel_file_name))
shutil.copy(excel_file_name, psd_path)
QMessageBox.information(self, "成功", '图片已经切成功放入对应文件夹中,\n坐标位于《image coordinate size.xlsx》文件中。', QMessageBox.Yes, QMessageBox.Yes)
self.statusbar.clearMessage()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment