-
Notifications
You must be signed in to change notification settings - Fork 0
/
MULTI_DECODER_GUI_RUN.py
64 lines (52 loc) · 1.92 KB
/
MULTI_DECODER_GUI_RUN.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
from PyQt5.QtCore import QEvent,QPoint
from PyQt5 import QtWidgets as qt
from PyQt5 import QtGui as gui
from PyQt5 import QtCore
from MULTI_DECODER_GUI_UI import Ui_Dialog as ui
import codext
class Window(qt.QMainWindow):
def __init__(self):
super(Window, self).__init__()
self.ui = ui()
self.ui.setupUi(self) # Initalize UI
self.ui.btnENC.clicked.connect(self.encodeText)
self.ui.btnDEC.clicked.connect(self.decodeText)
self.ui.btnCLEAR.clicked.connect(self.clearText)
self.ui.btnCOPY.clicked.connect(self.copy_To_Clipboard)
def encodeText(self):
try:
result = codext.encode(self.ui.txtIN.text(),encoding=self.ui.ENC_METHOD.currentText())
except Exception as e:
msg1 = qt.QMessageBox()
msg1.setIcon(qt.QMessageBox.Warning)
msg1.setText(str(e))
msg1.setWindowTitle("Error")
msg1.setStandardButtons(qt.QMessageBox.Ok)
msg1.exec_()
else:
self.ui.txtOut.setText(result)
def decodeText(self):
try:
result = codext.decode(self.ui.txtIN.text(),encoding=self.ui.ENC_METHOD.currentText())
except Exception as e:
msg1 = qt.QMessageBox()
msg1.setIcon(qt.QMessageBox.Warning)
msg1.setText(str(e))
msg1.setWindowTitle("Error")
msg1.setStandardButtons(qt.QMessageBox.Ok)
msg1.exec_()
else:
self.ui.txtOut.setText(result)
def clearText(self):
self.ui.txtIN.setText('')
self.ui.txtOut.setText('')
def copy_To_Clipboard(self):
import clipboard
copytext = self.ui.txtOut.text()
if len(copytext) > 0 :
clipboard.copy(copytext)
# Run Application
app = qt.QApplication([])
application = Window()
application.show()
app.exec()