You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

131 lines
3.5 KiB

import math
import os.path
import sys
import json
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
from langueageExport import Ui_MainWindow
UI = None
configPath = "./LanguageMergeConfig.json"
config = None
slected_list = {}
def ReadJson(filename):
with open(filename, 'r', encoding='utf-8') as fp:
json_data = json.load(fp)
return json_data
def WriteJson(jsonData, filename):
data = json.dumps(jsonData, indent=4)
with open(filename, 'w', encoding='utf-8') as fp:
fp.write(data)
def BtnState(i):
btn = UI.LanLayout.sender()
str = btn.text()
slected_list[btn.text()] = True if i == 2 else False
def CreateLanSelect():
lan_list = config["languages"]
lan_selects = config["selectLanguages"]
for i in range(0, len(lan_selects)):
slected_list[lan_selects[i]] = True
maxCol = 6;
x = 0
y = 0
for i in range(0, len(lan_list)):
checkBtn = QtWidgets.QCheckBox()
checkBtn.setText(lan_list[i])
if (lan_list[i] in slected_list) and slected_list[lan_list[i]]:
checkBtn.setChecked(True)
else:
checkBtn.setChecked(False)
checkBtn.stateChanged.connect(BtnState)
x = math.floor(i / maxCol)
y = i % maxCol
UI.LanLayout.addWidget(checkBtn, x, y)
UI.LanLayout.update()
def ShowTip(tipsStr):
QMessageBox.warning(UI.centralwidget, "2333333", tipsStr, QMessageBox.Cancel)
def OnClick():
if not UI.srcLineEdit.text().endswith(".xlsx"):
ShowTip("格式写正确啊!!!!")
return
if not UI.dstLineEdit.text().endswith(".xlsx"):
ShowTip("格式写正确啊!!!!")
return
if not UI.reslutLineEdit.text().endswith(".xlsx"):
ShowTip("格式写正确啊!!!!")
return
config["srcFile"] = UI.srcLineEdit.text()
config["dstFile"] = UI.dstLineEdit.text()
(resultPath, resultFile) = os.path.split(UI.reslutLineEdit.text())
config["resultFilePath"] = resultPath
config["resultFile"] = resultFile
config["selectLanguages"] = []
for key in slected_list.keys():
if slected_list[key]:
config["selectLanguages"].append(key)
WriteJson(config, configPath)
# abd = "cd .."
# d = os.system(abd)
# print(d)
abd = ".\\run_Merge.bat"
d = os.system(abd)
print(d)
sys.exit()
FillMode_Cover = 0
FillMode_OnlyBlank = 1
def CheckFillMode(i):
btn = UI.LanLayout.sender()
str = btn.text()
isCover = True if i == 2 else False
if isCover:
config["fillMode"] = FillMode_Cover
else:
config["fillMode"] = FillMode_OnlyBlank
def InitFillModelView(fillMode):
UI.fillModeCheckBox
if FillMode_Cover == fillMode:
UI.fillModeCheckBox.setChecked(True)
else:
UI.fillModeCheckBox.setChecked(False)
UI.fillModeCheckBox.stateChanged.connect(CheckFillMode)
if __name__ == "__main__":
app = QtWidgets.QApplication(sys.argv)
widget = QtWidgets.QMainWindow()
UI = Ui_MainWindow()
UI.setupUi(widget)
widget.setWindowTitle("语言合入懒人工具")
config = ReadJson(configPath)
UI.srcLineEdit.setText(config["srcFile"])
UI.dstLineEdit.setText(config["dstFile"])
UI.reslutLineEdit.setText(config["resultFilePath"] + "/" + config["resultFile"])
UI.exportBtn.clicked.connect(OnClick)
CreateLanSelect()
#填充模式
InitFillModelView(config["fillMode"])
widget.show()
sys.exit(app.exec_())