<filename>main.py
import urllib.request
from PyQt5.QtWidgets import QMainWindow, QApplication
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtGui import QTextCursor

client_id = ""  # 개발자센터에서 발급받은 Client ID 값
client_secret = ""  # 개발자센터에서 발급받은 Client Secret 값
context = ""
result = ""
count = 0
storedString = ""

class MyWindow(QMainWindow):
    def __init__(self):
        super().__init__()
        self.setupUi(self)
        self.box_addString.setPlaceholderText("Enter English - Sentence 1")
        self.box_addString.setFocus()
        self.Bt_Translate.clicked.connect(self.btn_clicked)
        self.Bt_New.clicked.connect(self.btn_new)
        self.box_addString.returnPressed.connect(self.btn_clicked)

    def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.setEnabled(True)
        MainWindow.resize(800, 580)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(MainWindow.sizePolicy().hasHeightForWidth())
        MainWindow.setSizePolicy(sizePolicy)
        MainWindow.setMaximumSize(QtCore.QSize(800, 580))
        MainWindow.setMinimumSize(QtCore.QSize(800, 580))
        palette = QtGui.QPalette()
        brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Base, brush)
        brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Window, brush)
        brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Base, brush)
        brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Window, brush)
        brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Base, brush)
        brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Window, brush)
        MainWindow.setPalette(palette)
        icon = QtGui.QIcon()
        icon.addPixmap(QtGui.QPixmap("image/b_icon.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        MainWindow.setWindowIcon(icon)
        MainWindow.setAutoFillBackground(False)
        MainWindow.setTabShape(QtWidgets.QTabWidget.Rounded)
        MainWindow.setDockNestingEnabled(False)
        self.centralwidget = QtWidgets.QWidget(MainWindow)
        self.centralwidget.setObjectName("centralwidget")
        self.Logo = QtWidgets.QLabel(self.centralwidget)
        self.Logo.setGeometry(QtCore.QRect(10, 0, 71, 31))
        palette = QtGui.QPalette()
        brush = QtGui.QBrush(QtGui.QColor(0, 110, 255))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.WindowText, brush)
        brush = QtGui.QBrush(QtGui.QColor(0, 85, 255))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Text, brush)
        brush = QtGui.QBrush(QtGui.QColor(0, 110, 255))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.WindowText, brush)
        brush = QtGui.QBrush(QtGui.QColor(0, 85, 255))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Text, brush)
        brush = QtGui.QBrush(QtGui.QColor(120, 120, 120))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.WindowText, brush)
        brush = QtGui.QBrush(QtGui.QColor(120, 120, 120))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Text, brush)
        self.Logo.setPalette(palette)
        font = QtGui.QFont()
        font.setFamily("Candara")
        font.setPointSize(18)
        font.setBold(True)
        font.setItalic(True)
        font.setWeight(75)
        self.Logo.setFont(font)
        self.Logo.setObjectName("Logo")
        self.Bt_Translate = QtWidgets.QPushButton(self.centralwidget)
        self.Bt_Translate.setGeometry(QtCore.QRect(750, 30, 41, 41))
        palette = QtGui.QPalette()
        brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Button, brush)
        brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Midlight, brush)
        brush = QtGui.QBrush(QtGui.QColor(0, 85, 255))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.ButtonText, brush)
        brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.AlternateBase, brush)
        brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Button, brush)
        brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Midlight, brush)
        brush = QtGui.QBrush(QtGui.QColor(0, 85, 255))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.ButtonText, brush)
        brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.AlternateBase, brush)
        brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Button, brush)
        brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Midlight, brush)
        brush = QtGui.QBrush(QtGui.QColor(120, 120, 120))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.ButtonText, brush)
        brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.AlternateBase, brush)
        self.Bt_Translate.setPalette(palette)
        font = QtGui.QFont()
        font.setFamily("Arial")
        font.setPointSize(22)
        font.setBold(True)
        font.setWeight(75)
        self.Bt_Translate.setFont(font)
        self.Bt_Translate.setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor))
        self.Bt_Translate.setObjectName("Bt_Translate")
        self.view_storedString = QtWidgets.QTextEdit(self.centralwidget)
        self.view_storedString.setEnabled(True)
        self.view_storedString.setGeometry(QtCore.QRect(10, 77, 781, 485))
        self.view_storedString.setMaximumSize(QtCore.QSize(16777215, 16777215))
        font = QtGui.QFont()
        font.setFamily("맑은 고딕")
        font.setPointSize(13)
        self.view_storedString.setFont(font)
        self.view_storedString.setMouseTracking(False)
        self.view_storedString.setTabletTracking(False)
        self.view_storedString.setAcceptDrops(True)
        self.view_storedString.setFrameShape(QtWidgets.QFrame.StyledPanel)
        self.view_storedString.setFrameShadow(QtWidgets.QFrame.Sunken)
        self.view_storedString.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded)
        self.view_storedString.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded)
        self.view_storedString.setSizeAdjustPolicy(QtWidgets.QAbstractScrollArea.AdjustIgnored)
        self.view_storedString.setObjectName("view_storedString")
        self.Chk_hideans = QtWidgets.QCheckBox(self.centralwidget)
        self.Chk_hideans.setGeometry(QtCore.QRect(645, 10, 101, 16))
        font = QtGui.QFont()
        font.setFamily("Candara")
        font.setPointSize(11)
        font.setBold(False)
        font.setItalic(True)
        font.setWeight(50)
        self.Chk_hideans.setFont(font)
        self.Chk_hideans.setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor))
        self.Chk_hideans.setChecked(True)
        self.Chk_hideans.setObjectName("Chk_hideans")
        self.Copyright = QtWidgets.QLabel(self.centralwidget)
        self.Copyright.setGeometry(QtCore.QRect(670, 560, 121, 21))
        palette = QtGui.QPalette()
        brush = QtGui.QBrush(QtGui.QColor(0, 85, 255))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.WindowText, brush)
        brush = QtGui.QBrush(QtGui.QColor(0, 85, 255))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.WindowText, brush)
        brush = QtGui.QBrush(QtGui.QColor(120, 120, 120))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.WindowText, brush)
        self.Copyright.setPalette(palette)
        font = QtGui.QFont()
        font.setFamily("Candara")
        font.setPointSize(10)
        self.Copyright.setFont(font)
        self.Copyright.setObjectName("Copyright")
        self.Bt_New = QtWidgets.QPushButton(self.centralwidget)
        self.Bt_New.setGeometry(QtCore.QRect(750, 7, 41, 21))
        font = QtGui.QFont()
        font.setFamily("Candara")
        font.setPointSize(11)
        font.setBold(False)
        font.setWeight(50)
        self.Bt_New.setFont(font)
        self.Bt_New.setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor))
        self.Bt_New.setObjectName("Bt_New")
        self.box_addString = QtWidgets.QLineEdit(self.centralwidget)
        self.box_addString.setGeometry(QtCore.QRect(10, 30, 735, 41))
        font = QtGui.QFont()
        font.setFamily("맑은 고딕")
        font.setPointSize(12)
        self.box_addString.setFont(font)
        self.box_addString.setFrame(True)
        self.box_addString.setCursorPosition(0)
        self.box_addString.setClearButtonEnabled(True)
        self.box_addString.setObjectName("box_addString")
        self.papagologo = QtWidgets.QLabel(self.centralwidget)
        self.papagologo.setGeometry(QtCore.QRect(80, 0, 21, 21))
        self.papagologo.setText("")
        self.papagologo.setPixmap(QtGui.QPixmap("image/papago.png"))
        self.papagologo.setScaledContents(True)
        self.papagologo.setObjectName("papagologo")
        MainWindow.setCentralWidget(self.centralwidget)

        self.retranslateUi(MainWindow)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)

    def retranslateUi(self, MainWindow):
        _translate = QtCore.QCoreApplication.translate
        MainWindow.setWindowTitle(_translate("MainWindow", "Bubble 1.0"))
        self.Logo.setText(_translate("MainWindow", "bubble"))
        self.Bt_Translate.setToolTip(_translate("MainWindow", "(Enter) Translate"))
        self.Bt_Translate.setText(_translate("MainWindow", "+"))
        self.Chk_hideans.setToolTip(_translate("MainWindow", "(Ctrl+E) Check if you want write with answer"))
        self.Chk_hideans.setText(_translate("MainWindow", "With English"))
        self.Chk_hideans.setShortcut(_translate("MainWindow", "Ctrl+E"))
        self.Copyright.setText(_translate("MainWindow", "ⓒ nopaqu from DKU"))
        self.Bt_New.setToolTip(_translate("MainWindow", "(Ctrl+N) Make new sheet"))
        self.Bt_New.setText(_translate("MainWindow", "New"))
        self.Bt_New.setShortcut(_translate("MainWindow", "Ctrl+N"))
        self.papagologo.setToolTip(_translate("MainWindow", "The translation use Papago NMT"))

    def btn_clicked(self):
        global context, result, storedString, count
        context = self.box_addString.text()
        if(context == ""):
            return 0
        result = self.translate(context)
        count += 1
        if(self.Chk_hideans.isChecked() == True):
            self.box_addString.setFocus()
            storedString += str(count) + ". " + result + '\n' + context + '\n\n'
        else:
            self.box_addString.setFocus()
            storedString += str(count) + ". " + result + '\n\n\n'
        self.view_storedString.setText(storedString)
        self.view_storedString.moveCursor(QTextCursor.End)
        self.box_addString.setText("")
        self.box_addString.setFocus()
        self.box_addString.setPlaceholderText("Enter English - Sentence " + str(count + 1))

    def translate(self, context):
        global client_id, client_secret
        data = "source=en&target=ko&text=" + context
        url = "https://openapi.naver.com/v1/papago/n2mt"
        request = urllib.request.Request(url)
        request.add_header("X-Naver-Client-Id", client_id)
        request.add_header("X-Naver-Client-Secret", client_secret)
        response = urllib.request.urlopen(request, data=data.encode("utf-8"))
        rescode = response.getcode()
        if (rescode == 200):
            response_body = response.read().decode('utf-8')
            res = response_body[152:len(response_body) - 41]
            return res
        else:
            return "번역 실패"

    def btn_new(self):
        global count, storedString
        storedString = ""
        self.box_addString.setText("")
        self.view_storedString.setText("")
        self.box_addString.setFocus()
        self.box_addString.setPlaceholderText("New work started - Enter English")
        count = 0


if __name__ == "__main__":
    import sys
    app = QApplication(sys.argv)
    window = MyWindow()
    window.show()
    sys.exit(app.exec_())
<filename>main.py
import urllib.request
from PyQt5.QtWidgets import QMainWindow, QApplication
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtGui import QTextCursor

client_id = ""  # 개발자센터에서 발급받은 Client ID 값
client_secret = ""  # 개발자센터에서 발급받은 Client Secret 값
context = ""
result = ""
count = 0
storedString = ""

class MyWindow(QMainWindow):
    def __init__(self):
        super().__init__()
        self.setupUi(self)
        self.box_addString.setPlaceholderText("Enter English - Sentence 1")
        self.box_addString.setFocus()
        self.Bt_Translate.clicked.connect(self.btn_clicked)
        self.Bt_New.clicked.connect(self.btn_new)
        self.box_addString.returnPressed.connect(self.btn_clicked)

    def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.setEnabled(True)
        MainWindow.resize(800, 580)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(MainWindow.sizePolicy().hasHeightForWidth())
        MainWindow.setSizePolicy(sizePolicy)
        MainWindow.setMaximumSize(QtCore.QSize(800, 580))
        MainWindow.setMinimumSize(QtCore.QSize(800, 580))
        palette = QtGui.QPalette()
        brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Base, brush)
        brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Window, brush)
        brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Base, brush)
        brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Window, brush)
        brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Base, brush)
        brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Window, brush)
        MainWindow.setPalette(palette)
        icon = QtGui.QIcon()
        icon.addPixmap(QtGui.QPixmap("image/b_icon.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        MainWindow.setWindowIcon(icon)
        MainWindow.setAutoFillBackground(False)
        MainWindow.setTabShape(QtWidgets.QTabWidget.Rounded)
        MainWindow.setDockNestingEnabled(False)
        self.centralwidget = QtWidgets.QWidget(MainWindow)
        self.centralwidget.setObjectName("centralwidget")
        self.Logo = QtWidgets.QLabel(self.centralwidget)
        self.Logo.setGeometry(QtCore.QRect(10, 0, 71, 31))
        palette = QtGui.QPalette()
        brush = QtGui.QBrush(QtGui.QColor(0, 110, 255))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.WindowText, brush)
        brush = QtGui.QBrush(QtGui.QColor(0, 85, 255))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Text, brush)
        brush = QtGui.QBrush(QtGui.QColor(0, 110, 255))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.WindowText, brush)
        brush = QtGui.QBrush(QtGui.QColor(0, 85, 255))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Text, brush)
        brush = QtGui.QBrush(QtGui.QColor(120, 120, 120))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.WindowText, brush)
        brush = QtGui.QBrush(QtGui.QColor(120, 120, 120))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Text, brush)
        self.Logo.setPalette(palette)
        font = QtGui.QFont()
        font.setFamily("Candara")
        font.setPointSize(18)
        font.setBold(True)
        font.setItalic(True)
        font.setWeight(75)
        self.Logo.setFont(font)
        self.Logo.setObjectName("Logo")
        self.Bt_Translate = QtWidgets.QPushButton(self.centralwidget)
        self.Bt_Translate.setGeometry(QtCore.QRect(750, 30, 41, 41))
        palette = QtGui.QPalette()
        brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Button, brush)
        brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Midlight, brush)
        brush = QtGui.QBrush(QtGui.QColor(0, 85, 255))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.ButtonText, brush)
        brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.AlternateBase, brush)
        brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Button, brush)
        brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Midlight, brush)
        brush = QtGui.QBrush(QtGui.QColor(0, 85, 255))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.ButtonText, brush)
        brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.AlternateBase, brush)
        brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Button, brush)
        brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Midlight, brush)
        brush = QtGui.QBrush(QtGui.QColor(120, 120, 120))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.ButtonText, brush)
        brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.AlternateBase, brush)
        self.Bt_Translate.setPalette(palette)
        font = QtGui.QFont()
        font.setFamily("Arial")
        font.setPointSize(22)
        font.setBold(True)
        font.setWeight(75)
        self.Bt_Translate.setFont(font)
        self.Bt_Translate.setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor))
        self.Bt_Translate.setObjectName("Bt_Translate")
        self.view_storedString = QtWidgets.QTextEdit(self.centralwidget)
        self.view_storedString.setEnabled(True)
        self.view_storedString.setGeometry(QtCore.QRect(10, 77, 781, 485))
        self.view_storedString.setMaximumSize(QtCore.QSize(16777215, 16777215))
        font = QtGui.QFont()
        font.setFamily("맑은 고딕")
        font.setPointSize(13)
        self.view_storedString.setFont(font)
        self.view_storedString.setMouseTracking(False)
        self.view_storedString.setTabletTracking(False)
        self.view_storedString.setAcceptDrops(True)
        self.view_storedString.setFrameShape(QtWidgets.QFrame.StyledPanel)
        self.view_storedString.setFrameShadow(QtWidgets.QFrame.Sunken)
        self.view_storedString.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded)
        self.view_storedString.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded)
        self.view_storedString.setSizeAdjustPolicy(QtWidgets.QAbstractScrollArea.AdjustIgnored)
        self.view_storedString.setObjectName("view_storedString")
        self.Chk_hideans = QtWidgets.QCheckBox(self.centralwidget)
        self.Chk_hideans.setGeometry(QtCore.QRect(645, 10, 101, 16))
        font = QtGui.QFont()
        font.setFamily("Candara")
        font.setPointSize(11)
        font.setBold(False)
        font.setItalic(True)
        font.setWeight(50)
        self.Chk_hideans.setFont(font)
        self.Chk_hideans.setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor))
        self.Chk_hideans.setChecked(True)
        self.Chk_hideans.setObjectName("Chk_hideans")
        self.Copyright = QtWidgets.QLabel(self.centralwidget)
        self.Copyright.setGeometry(QtCore.QRect(670, 560, 121, 21))
        palette = QtGui.QPalette()
        brush = QtGui.QBrush(QtGui.QColor(0, 85, 255))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.WindowText, brush)
        brush = QtGui.QBrush(QtGui.QColor(0, 85, 255))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.WindowText, brush)
        brush = QtGui.QBrush(QtGui.QColor(120, 120, 120))
        brush.setStyle(QtCore.Qt.SolidPattern)
        palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.WindowText, brush)
        self.Copyright.setPalette(palette)
        font = QtGui.QFont()
        font.setFamily("Candara")
        font.setPointSize(10)
        self.Copyright.setFont(font)
        self.Copyright.setObjectName("Copyright")
        self.Bt_New = QtWidgets.QPushButton(self.centralwidget)
        self.Bt_New.setGeometry(QtCore.QRect(750, 7, 41, 21))
        font = QtGui.QFont()
        font.setFamily("Candara")
        font.setPointSize(11)
        font.setBold(False)
        font.setWeight(50)
        self.Bt_New.setFont(font)
        self.Bt_New.setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor))
        self.Bt_New.setObjectName("Bt_New")
        self.box_addString = QtWidgets.QLineEdit(self.centralwidget)
        self.box_addString.setGeometry(QtCore.QRect(10, 30, 735, 41))
        font = QtGui.QFont()
        font.setFamily("맑은 고딕")
        font.setPointSize(12)
        self.box_addString.setFont(font)
        self.box_addString.setFrame(True)
        self.box_addString.setCursorPosition(0)
        self.box_addString.setClearButtonEnabled(True)
        self.box_addString.setObjectName("box_addString")
        self.papagologo = QtWidgets.QLabel(self.centralwidget)
        self.papagologo.setGeometry(QtCore.QRect(80, 0, 21, 21))
        self.papagologo.setText("")
        self.papagologo.setPixmap(QtGui.QPixmap("image/papago.png"))
        self.papagologo.setScaledContents(True)
        self.papagologo.setObjectName("papagologo")
        MainWindow.setCentralWidget(self.centralwidget)

        self.retranslateUi(MainWindow)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)

    def retranslateUi(self, MainWindow):
        _translate = QtCore.QCoreApplication.translate
        MainWindow.setWindowTitle(_translate("MainWindow", "Bubble 1.0"))
        self.Logo.setText(_translate("MainWindow", "bubble"))
        self.Bt_Translate.setToolTip(_translate("MainWindow", "(Enter) Translate"))
        self.Bt_Translate.setText(_translate("MainWindow", "+"))
        self.Chk_hideans.setToolTip(_translate("MainWindow", "(Ctrl+E) Check if you want write with answer"))
        self.Chk_hideans.setText(_translate("MainWindow", "With English"))
        self.Chk_hideans.setShortcut(_translate("MainWindow", "Ctrl+E"))
        self.Copyright.setText(_translate("MainWindow", "ⓒ nopaqu from DKU"))
        self.Bt_New.setToolTip(_translate("MainWindow", "(Ctrl+N) Make new sheet"))
        self.Bt_New.setText(_translate("MainWindow", "New"))
        self.Bt_New.setShortcut(_translate("MainWindow", "Ctrl+N"))
        self.papagologo.setToolTip(_translate("MainWindow", "The translation use Papago NMT"))

    def btn_clicked(self):
        global context, result, storedString, count
        context = self.box_addString.text()
        if(context == ""):
            return 0
        result = self.translate(context)
        count += 1
        if(self.Chk_hideans.isChecked() == True):
            self.box_addString.setFocus()
            storedString += str(count) + ". " + result + '\n' + context + '\n\n'
        else:
            self.box_addString.setFocus()
            storedString += str(count) + ". " + result + '\n\n\n'
        self.view_storedString.setText(storedString)
        self.view_storedString.moveCursor(QTextCursor.End)
        self.box_addString.setText("")
        self.box_addString.setFocus()
        self.box_addString.setPlaceholderText("Enter English - Sentence " + str(count + 1))

    def translate(self, context):
        global client_id, client_secret
        data = "source=en&target=ko&text=" + context
        url = "https://openapi.naver.com/v1/papago/n2mt"
        request = urllib.request.Request(url)
        request.add_header("X-Naver-Client-Id", client_id)
        request.add_header("X-Naver-Client-Secret", client_secret)
        response = urllib.request.urlopen(request, data=data.encode("utf-8"))
        rescode = response.getcode()
        if (rescode == 200):
            response_body = response.read().decode('utf-8')
            res = response_body[152:len(response_body) - 41]
            return res
        else:
            return "번역 실패"

    def btn_new(self):
        global count, storedString
        storedString = ""
        self.box_addString.setText("")
        self.view_storedString.setText("")
        self.box_addString.setFocus()
        self.box_addString.setPlaceholderText("New work started - Enter English")
        count = 0


if __name__ == "__main__":
    import sys
    app = QApplication(sys.argv)
    window = MyWindow()
    window.show()
    sys.exit(app.exec_())
# 개발자센터에서 발급받은 Client ID 값 # 개발자센터에서 발급받은 Client Secret 값