-
Notifications
You must be signed in to change notification settings - Fork 2
/
508.py
135 lines (113 loc) · 5.87 KB
/
508.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'mainwindow2.ui'
#
# Created by: PyQt5 UI code generator 5.5.1
#
# WARNING! All changes made in this file will be lost!
#encoding:utf-8
from PyQt5 import QtCore, QtGui, QtWidgets
import sys
import baidutranslate
import requests
import string
import time
import hashlib
import json
class Ui_MainWindow2(object):
def setupUi(self, MainWindow2):
MainWindow2.setObjectName("MainWindow2")
MainWindow2.resize(800, 600)
self.centralwidget = QtWidgets.QWidget(MainWindow2)
self.centralwidget.setObjectName("centralwidget")
self.verticalLayoutWidget = QtWidgets.QWidget(self.centralwidget)
self.verticalLayoutWidget.setGeometry(QtCore.QRect(60, 100, 181, 111))
self.verticalLayoutWidget.setObjectName("verticalLayoutWidget")
self.verticalLayout = QtWidgets.QVBoxLayout(self.verticalLayoutWidget)
self.verticalLayout.setObjectName("verticalLayout")
self.textEdit = QtWidgets.QTextEdit(self.verticalLayoutWidget)
self.textEdit.setObjectName("textEdit")
self.verticalLayout.addWidget(self.textEdit)
self.verticalLayoutWidget_2 = QtWidgets.QWidget(self.centralwidget)
self.verticalLayoutWidget_2.setGeometry(QtCore.QRect(370, 100, 191, 111))
self.verticalLayoutWidget_2.setObjectName("verticalLayoutWidget_2")
self.verticalLayout_2 = QtWidgets.QVBoxLayout(self.verticalLayoutWidget_2)
self.verticalLayout_2.setObjectName("verticalLayout_2")
self.textEdit_2 = QtWidgets.QTextEdit(self.verticalLayoutWidget_2)
self.textEdit_2.setObjectName("textEdit_2")
self.verticalLayout_2.addWidget(self.textEdit_2)
self.pushButton = QtWidgets.QPushButton(self.centralwidget)
self.pushButton.setGeometry(QtCore.QRect(160, 220, 51, 27))
self.pushButton.setObjectName("pushButton")
self.pushButton_2 = QtWidgets.QPushButton(self.centralwidget)
self.pushButton_2.setGeometry(QtCore.QRect(270, 140, 81, 27))
self.pushButton_2.setObjectName("pushButton_2")
self.pushButton_3 = QtWidgets.QPushButton(self.centralwidget)
self.pushButton_3.setGeometry(QtCore.QRect(410, 220, 51, 27))
self.pushButton_3.setObjectName("pushButton_3")
self.label = QtWidgets.QLabel(self.centralwidget)
self.label.setGeometry(QtCore.QRect(250, 40, 211, 20))
self.label.setObjectName("label")
self.pushButton_4 = QtWidgets.QPushButton(self.centralwidget)
self.pushButton_4.setGeometry(QtCore.QRect(80, 220, 51, 27))
self.pushButton_4.setObjectName("pushButton_4")
self.pushButton_7 = QtWidgets.QPushButton(self.centralwidget)
self.pushButton_7.setGeometry(QtCore.QRect(480, 220, 51, 27))
self.pushButton_7.setObjectName("pushButton_7")
self.comboBox = QtWidgets.QComboBox(self.centralwidget)
self.comboBox.setGeometry(QtCore.QRect(100, 70, 85, 27))
self.comboBox.setObjectName("comboBox")
self.comboBox.addItem("")
self.comboBox.addItem("")
self.comboBox.addItem("")
self.comboBox.addItem("")
self.comboBox_2 = QtWidgets.QComboBox(self.centralwidget)
self.comboBox_2.setGeometry(QtCore.QRect(420, 70, 85, 27))
self.comboBox_2.setObjectName("comboBox_2")
self.comboBox_2.addItem("")
self.comboBox_2.addItem("")
self.comboBox_2.addItem("")
self.comboBox_2.addItem("")
MainWindow2.setCentralWidget(self.centralwidget)
self.menubar = QtWidgets.QMenuBar(MainWindow2)
self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 31))
self.menubar.setObjectName("menubar")
MainWindow2.setMenuBar(self.menubar)
self.statusbar = QtWidgets.QStatusBar(MainWindow2)
self.statusbar.setObjectName("statusbar")
MainWindow2.setStatusBar(self.statusbar)
self.retranslateUi(MainWindow2)
QtCore.QMetaObject.connectSlotsByName(MainWindow2)
def retranslateUi(self, MainWindow2):
_translate = QtCore.QCoreApplication.translate
MainWindow2.setWindowTitle(_translate("MainWindow2", "MainWindow"))
self.pushButton.setText(_translate("MainWindow2", "录音"))
self.pushButton_2.setText(_translate("MainWindow2", "翻译"))
self.pushButton_3.setText(_translate("MainWindow2", "播报"))
self.label.setText(_translate("MainWindow2", "多功能翻译系统"))
self.pushButton_4.setText(_translate("MainWindow2", "打开"))
self.pushButton_7.setText(_translate("MainWindow2", "关闭"))
self.comboBox.setItemText(0, _translate("MainWindow2", "文字"))
self.comboBox.setItemText(1, _translate("MainWindow2", "文档"))
self.comboBox.setItemText(2, _translate("MainWindow2", "语音"))
self.comboBox.setItemText(3, _translate("MainWindow2", "视频"))
self.comboBox_2.setItemText(0, _translate("MainWindow2", "文字"))
self.comboBox_2.setItemText(1, _translate("MainWindow2", "文档"))
self.comboBox_2.setItemText(2, _translate("MainWindow2", "语音"))
self.comboBox_2.setItemText(3, _translate("MainWindow2", "视频"))
def setupFunction(self): #set function for the button
self.pushButton_2.clicked.connect(self.translateapi)
def translateapi(self,word): #baiduapi translate mode
while True:
#word = input("输入你想翻译的内容: ")
word = self.textEdit.toPlainText()
#requests_for_dst(word)
#result = baidutranslate.requests_for_dst(word)
self.textEdit_2.setText((baidutranslate.requests_for_dst(word)))
if __name__ == "__main__":
app = QtWidgets.QApplication(sys.argv)
MainWindow = QtWidgets.QMainWindow()
ui = Ui_MainWindow2()
ui.setupUi(MainWindow)
ui.setupFunction()
MainWindow.show()
sys.exit(app.exec_())