forked from do-something-for-fun/thesis-helper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
65 lines (57 loc) · 2.19 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
##!/usr/bin/python3
# -*- coding: utf-8 -*-
# @Time : 2019年11月4日16:56:33
# @Author : 穆华岭
# @Software: 毕业论文小助手
# @github :https://github.com/muhualing/
import os
import sys
from PyQt5.QtWebEngineWidgets import QWebEngineView
from PyQt5.QtCore import QUrl
from PyQt5 import QtWidgets
from PyQt5.QtWidgets import (QWidget, QPushButton,
QHBoxLayout, QVBoxLayout, QApplication)
from controller import con
from watch_clip import WatchClip
translate_res = None
class PDFView(QWebEngineView):
def __init__(self):
super(PDFView, self).__init__()
pdf_js_path = "file:///" + os.path.join(os.getcwd(), "pdfjs-2.2.228-dist", "web", "viewer.html")
pdf_path = ""
pdf_path = "file:///" + os.path.join(os.getcwd(), "sample.pdf")
pdf_js_path = pdf_js_path.replace('\\', '/')
pdf_path = pdf_path.replace('\\', '/')
self.load(QUrl.fromUserInput('%s?file=%s' % (pdf_js_path, pdf_path)))
class MainWindow(QtWidgets.QMainWindow):
def __init__(self):
super(MainWindow, self).__init__()
self.setWindowTitle("毕业论文小助手,有问题请联系https://github.com/muhualing/")
global translate_res
self.translate_res = QtWidgets.QTextEdit()
self.translate_res.setStyleSheet("font: 14pt Roboto")
vbox = QVBoxLayout()
vbox.addWidget(self.translate_res)
gbox = QtWidgets.QGroupBox("中文翻译结果")
gbox.setLayout(vbox)
hBoxLayout = QHBoxLayout()
hBoxLayout.addWidget(PDFView())
hBoxLayout.addWidget(gbox)
hBoxLayout.setStretch(0, 9)
hBoxLayout.setStretch(1, 3)
widget = QWidget()
widget.setLayout(hBoxLayout)
self.setCentralWidget(widget)
# self.showFullScreen() # 全屏显示,没有窗口
self.showMaximized()
def update(self, cur_text):
self.translate_res.clear()
self.translate_res.setText(cur_text)
if __name__ == '__main__':
app = QtWidgets.QApplication(sys.argv)
mainWindow = MainWindow()
mainWindow.show()
con.clip_changed.connect(mainWindow.update)
watch_clip_thread = WatchClip()
watch_clip_thread.start()
sys.exit(app.exec_())