diff --git a/.github/workflows/pyInstaller.yml b/.github/workflows/pyInstaller.yml index f156fe7..59b0364 100644 --- a/.github/workflows/pyInstaller.yml +++ b/.github/workflows/pyInstaller.yml @@ -11,10 +11,10 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Set up Python 3.7 + - name: Set up Python 3.10 uses: actions/setup-python@v3 with: - python-version: '3.7' + python-version: '3.10' architecture: 'x64' cache: 'pip' - name: Display Python version diff --git a/.gitignore b/.gitignore index b6f1ca8..7f13d50 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,5 @@ __pycache__ build dist TranslatorConfig.yaml -*.log \ No newline at end of file +*.log +.conda \ No newline at end of file diff --git a/GUI.py b/GUI.py index f588397..e597648 100644 --- a/GUI.py +++ b/GUI.py @@ -56,7 +56,7 @@ class getSecretWidget_class(QtWidgets.QWidget, Ui_getSecretWidget): def __init__(self, parent) -> None: super().__init__() self.setupUi(self) - self.parent = parent + self.parent = parent # type: ignore def setupUi(self, Config): super().setupUi(Config) @@ -96,7 +96,7 @@ def __init__(self, parent) -> None: super().__init__() self.setupUi(self) self.ListWidget_SelectedSource.setDragDropMode(QtWidgets.QAbstractItemView.DragDropMode.InternalMove) - self.parent = parent + self.parent = parent # type: ignore self.Hotkey_OCR = parent.Hotkey_OCR self.OCRKeyEdit.hide(); self.cancelHotKeyButton.hide(); self.confirmHotKeyButton.hide() self.LineEditMapping = { @@ -201,8 +201,8 @@ def saveConfig(self): QtWidgets.QMessageBox.critical(self,"配置有误","至少选择一个翻译源!") return data = {each: self.LineEditMapping[each].text() for each in self.LineEditMapping} - data.update({each: self.FreeRiderMapping[each].isChecked() for each in self.FreeRiderMapping}) - data['SELECTED_TRANSLATORS'] = self.getCurrentSelectedTranslator() + data.update({each: self.FreeRiderMapping[each].isChecked() for each in self.FreeRiderMapping}) # type: ignore + data['SELECTED_TRANSLATORS'] = self.getCurrentSelectedTranslator() # type: ignore data['Hotkey_OCR'] = self.Hotkey_OCR writeConfig(data) self.parent.changeHotkey(self.Hotkey_OCR) @@ -300,7 +300,7 @@ def setupUi(self, Config): Config.OCRButton.setEnabled(self.AreaInit) Config.OCRButtonPlus.setEnabled(self.AreaInit) DesktopSize = self.screen().availableSize() - Config.move(DesktopSize.width() * 0.54, DesktopSize.height() * 0.41) + Config.move((DesktopSize.width() * 0.54).__int__(), (DesktopSize.height() * 0.41).__int__()) # Config.setAttribute(QtCore.Qt.WA_TranslucentBackground,True) def __init__(self): @@ -452,16 +452,23 @@ def updateResults(self): def updateTranslatorList(self, _list:list): self.TranslatorList = _list print(f'当前翻译源为:{self.TranslatorList}') - [self.resultTextEditList[n].setPlaceholderText(eachTranslator) for n, eachTranslator in enumerate(self.TranslatorList)] + + for n, eachTranslator in enumerate(self.TranslatorList): + self.resultTextEditList[n].setPlaceholderText(eachTranslator) + _len = _list.__len__() if _len < 4: if _len == 0: _len = 1 - [each.setVisible(False) for each in self.resultTextEditList[_len-4:]] + + for each in self.resultTextEditList[_len-4:]: + each.setVisible(False) + n = 80*(4-_len) self.setFixedSize(self.defaultWidth, self.defaultHeight-n) self.move(self.defaultX, self.defaultY+n) else: - [each.setVisible(True) for each in self.resultTextEditList] + for each in self.resultTextEditList: + each.setVisible(True) self.setFixedSize(self.defaultWidth, self.defaultHeight) self.move(self.defaultX, self.defaultY) @@ -472,7 +479,7 @@ def updateSplitMode(self, mode): def updateSplitTextEdit(self,Force=False): source = self.OCRResultTextEdit.toPlainText() if(source and (Force or self.SplitMode != 'kuromoji')): - self.splitTextEdit.setPlainText(splitWords(source, self.SplitMode)) + self.splitTextEdit.setPlainText(splitWords(source, self.SplitMode)) # type: ignore def showDictWindow(self): self.selectionTextChange.emit(self.selectionText) diff --git a/Segmentation.py b/Segmentation.py index 103a69e..2bcb6b9 100644 --- a/Segmentation.py +++ b/Segmentation.py @@ -1,14 +1,15 @@ -from fugashi import Tagger # from MeCab import Tagger +from typing import Generator +from fugashi import Tagger # from MeCab import Tagger # type: ignore from sudachipy import tokenizer,dictionary import requests import json from urllib3 import disable_warnings from os import path -import importlib +import importlib.util disable_warnings() from Config import isPacked, NOPROXIES -def _kuromoji(s: str) -> list: +def _kuromoji(s: str) -> Generator: url = "https://www.atilika.org/kuromoji/rest/tokenizer/tokenize" datas = {"text": s, "mode": 0} req = requests.post(url, data=datas, verify=False, proxies=NOPROXIES) diff --git a/requirements.txt b/requirements.txt index 8a45951..9afe3e2 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,20 +1,20 @@ -keyboard == 0.13.5 -PyQt6>=6.3.0 -requests==2.31.0 -unidic==1.1.0 -unidic-lite==1.0.8 -SudachiDict-full==20211220 -SudachiDict-core==20211220 -SudachiDict-small==20211220 -SudachiPy==0.6.3 -opencv-python==4.5.5.64 -PyAutoGUI==0.9.53 -numpy==1.22.0 -fugashi==1.1.2 -tencentcloud-sdk-python==3.0.598 -pyinstaller==5.1 -PyWin32==303 -mecab-python3==1.0.4 -PyYAML==6.0 -aliyun-python-sdk-core-v3==2.13.33 -aliyun-python-sdk-alimt==3.1.1 \ No newline at end of file +keyboard +PyQt6 +requests +unidic +unidic-lite +SudachiDict-full +SudachiDict-core +SudachiDict-small +SudachiPy +opencv-python +PyAutoGUI +numpy +fugashi +tencentcloud-sdk-python +pyinstaller +PyWin32 +mecab-python3 +PyYAML +aliyun-python-sdk-core-v3 +aliyun-python-sdk-alimt \ No newline at end of file