Skip to content

Commit

Permalink
GUI
Browse files Browse the repository at this point in the history
  • Loading branch information
Lafcadia committed Jun 22, 2024
1 parent be7ea47 commit 2aea7e9
Show file tree
Hide file tree
Showing 5 changed files with 692 additions and 0 deletions.
157 changes: 157 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
.vscode/

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# CMake
CMakeFiles/
CMakeCache.txt
CMakeLists.txt
CTestTestfile.cmake
cmake_install.cmake
compile_commands.json
testing/

# Poetry
# Virtual environment
/.venv/

# .env file
.env

# Mac OS
.DS_Store

# Windows
Thumbs.db
ehthumbs.db
ehthumbs_vista.db
*.stackdump
60 changes: 60 additions & 0 deletions pse.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
from plugin.engine.minebbs import Minebbs
from plugin.engine.klpbbs import Klpbbs
from plugin.engine.spigotmc import Spigot
from plugin.engine.tinksp import Tinksp
from concurrent.futures import ThreadPoolExecutor, wait
from PySide6.QtWidgets import QMainWindow, QApplication, QMessageBox, QTreeWidgetItem
from PySide6 import QtCore
import sys
import multiprocessing as m
from multiprocessing import Process as P
from ui import Ui_MainWindow
import pyperclip

QtCore.QCoreApplication.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling)

def get_result(keyword, q):
engine = [Spigot, Tinksp, Minebbs, Klpbbs]
results = []
with ThreadPoolExecutor(max_workers=6) as executor:
future_list = []
for e in engine:
future = executor.submit(e().search, keyword)
print(0)
future_list.append(future)
wait(future_list)
for future in future_list:
for result in future.result():
results.append(result)
print(1)
q.put(results)

class MainWindow(QMainWindow):
def __init__(self):
super().__init__()
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
self.ui.searchButton.clicked.connect(self.search)
self.ui.outputTreeWidget.itemDoubleClicked.connect(self.copyUrl)

def search(self):
self.ui.outputTreeWidget.clear()
keyword = self.ui.searchLine.text()
q = m.Queue()
p = P(target=get_result, args=(keyword, q))
p.start(); p.join(); results = q.get()
for result in results:
num = results.index(result)
title = QTreeWidgetItem(self.ui.outputTreeWidget, [result.title, result.url, result.summary])

def copyUrl(self, item):
# copy a text to the clipboard.
pyperclip.copy(item.text(1))
QMessageBox.information(self, "Copied!", "已将该插件链接复制到剪贴板。")

if __name__ == "__main__":
m.freeze_support()
app = QApplication(sys.argv)
window = MainWindow()
window.show()
sys.exit(app.exec())
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cn_bing_translator
Loading

0 comments on commit 2aea7e9

Please sign in to comment.