Skip to content

Commit

Permalink
Update: 更新Python至3.10
Browse files Browse the repository at this point in the history
  • Loading branch information
CberYellowstone committed Jun 14, 2023
1 parent 5b43395 commit 41428f6
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 35 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/pyInstaller.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ __pycache__
build
dist
TranslatorConfig.yaml
*.log
*.log
.conda
25 changes: 16 additions & 9 deletions GUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 = {
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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)

Expand All @@ -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)
Expand Down
7 changes: 4 additions & 3 deletions Segmentation.py
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
40 changes: 20 additions & 20 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -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
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

0 comments on commit 41428f6

Please sign in to comment.