pyqt5寫的摩斯密碼
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'QMainwindowUI.ui'
#
# Created by: PyQt5 UI code generator 5.15.0
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again. Do not edit this file unless you know what you are doing.
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(417, 359)
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.pushButton = QtWidgets.QPushButton(self.centralwidget)
self.pushButton.setGeometry(QtCore.QRect(0, 240, 151, 23))
self.pushButton.setObjectName("pushButton")
self.pushButton_2 = QtWidgets.QPushButton(self.centralwidget)
self.pushButton_2.setGeometry(QtCore.QRect(290, 100, 101, 23))
self.pushButton_2.setObjectName("pushButton_2")
self.pushButton_3 = QtWidgets.QPushButton(self.centralwidget)
self.pushButton_3.setGeometry(QtCore.QRect(290, 150, 101, 23))
self.pushButton_3.setObjectName("pushButton_3")
self.widget = QtWidgets.QWidget(self.centralwidget)
self.widget.setGeometry(QtCore.QRect(1, 24, 281, 171))
self.widget.setObjectName("widget")
self.gridLayout = QtWidgets.QGridLayout(self.widget)
self.gridLayout.setContentsMargins(0, 0, 0, 0)
self.gridLayout.setObjectName("gridLayout")
self.radioButton = QtWidgets.QRadioButton(self.widget)
self.radioButton.setChecked(False)
self.radioButton.setObjectName("radioButton")
self.gridLayout.addWidget(self.radioButton, 0, 0, 1, 1)
self.radioButton_2 = QtWidgets.QRadioButton(self.widget)
self.radioButton_2.setCheckable(True)
self.radioButton_2.setChecked(False)
self.radioButton_2.setObjectName("radioButton_2")
self.gridLayout.addWidget(self.radioButton_2, 0, 1, 1, 1)
self.lineEdit = QtWidgets.QLineEdit(self.widget)
self.lineEdit.setObjectName("lineEdit")
self.gridLayout.addWidget(self.lineEdit, 1, 0, 1, 2)
self.label = QtWidgets.QLabel(self.widget)
self.label.setObjectName("label")
self.gridLayout.addWidget(self.label, 2, 0, 1, 2)
self.label_2 = QtWidgets.QLabel(self.widget)
self.label_2.setEnabled(True)
self.label_2.setMouseTracking(False)
self.label_2.setTabletTracking(True)
self.label_2.setAcceptDrops(False)
self.label_2.setToolTip("")
self.label_2.setAutoFillBackground(True)
self.label_2.setScaledContents(False)
self.label_2.setWordWrap(False)
self.label_2.setObjectName("label_2")
self.gridLayout.addWidget(self.label_2, 3, 0, 1, 2)
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtWidgets.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 417, 21))
self.menubar.setObjectName("menubar")
MainWindow.setMenuBar(self.menubar)
self.statusbar = QtWidgets.QStatusBar(MainWindow)
self.statusbar.setObjectName("statusbar")
MainWindow.setStatusBar(self.statusbar)
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", "摩斯密碼"))
MainWindow.setToolTip(_translate("MainWindow", "袁少澤最帥"))
self.pushButton.setText(_translate("MainWindow", "開始"))
self.pushButton_2.setText(_translate("MainWindow", "複製label"))
self.pushButton_3.setText(_translate("MainWindow", "複製label_2"))
self.radioButton.setText(_translate("MainWindow", "加密"))
self.radioButton_2.setToolTip(_translate("MainWindow", "解密只能用label_2"))
self.radioButton_2.setText(_translate("MainWindow", "解密"))
self.lineEdit.setPlaceholderText(_translate("MainWindow", "只能輸入數字字母和空格"))
self.label.setText(_translate("MainWindow", "label"))
self.label_2.setText(_translate("MainWindow", "label_2"))
import sys
from PyQt5.QtWidgets import *
import pyperclip
direct_keys=['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
'Q', 'R', 'S', 'T', 'U', 'V',
'W', 'X', 'Y', 'Z', ' ', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0']
direct_values=['.-', '-...', '- .-.', '- ..', '.', '..-.', '--.', '....', '..', '.━ ━ ━', '━.',
'-..', '-', '-.', '---', '.--.', '--.-', '.-.', '...', '-', '..-',
'...-', '.--', '-..-', '-.--', '--..', ' ', '----', '. .---',
'. . .--', '. . . .-',
'. . . . .', '-. . . .', '--. . .', '---. .', '----.', '-----']
def jiami(miwen):
list1 = []
for i in miwen.upper():
list1.append(direct_values[direct_keys.index(i)])
return ''.join(list1)
def jiami_2(miwen):
list3 = []
for i in miwen.upper():
list3.append(direct_values[direct_keys.index(i)])
return '/'.join(list3)
def jiemi(miwen):
list2 = []
list4 = []
list2=miwen.split('/')
for i in list2:
list4.append(direct_keys[direct_values.index(i)])
return ''.join(list4)
class win(QMainWindow):
def __init__(self):
super(win, self).__init__()
self.initUI()
self.caoradioButton()
def initUI(self):
# self.ui=uic.loadUi('QMainwindowUI.ui')
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
self.ui.pushButton.clicked.connect(self.caoradioButton)
self.ui.pushButton_2.clicked.connect(self.caobtn2)
self.ui.pushButton_3.clicked.connect(self.caobtn3)
def caoradioButton(self):
if self.ui.radioButton.isChecked() == True:
self.ui.label.setText(jiami(self.ui.lineEdit.text()))
self.ui.label_2.setText(jiami_2(self.ui.lineEdit.text()))
elif self.ui.radioButton_2.isChecked() == True:
print(self.ui.lineEdit.text())
self.ui.label.setText(jiemi(str(self.ui.lineEdit.text())))
self.ui.label_2.setText('製作者QQ:1653490853 ')
def caobtn2(self):
pyperclip.copy(self.ui.label.text())
def caobtn3(self):
pyperclip.copy(self.ui.label_2.text())
if __name__ == '__main__':
app = QApplication(sys.argv)
main = win()
main.show()
sys.exit(app.exec_())
相關文章
- RxJS 實現摩斯密碼(Morse) 【內附腦圖】JS密碼
- PHP實現摩斯電碼加密解密PHP加密解密
- 密碼區分大小寫密碼
- 寫好程式碼的10個祕密
- C編寫的簡單密碼程式密碼
- 用 Tk 寫個密碼器密碼
- [轉]寫好程式碼的10個祕密
- PyQt5 編寫一個UDP ServerQTUDPServer
- 達芬奇密碼 寫在前面密碼
- 11G 新特性:密碼大小寫策略密碼
- 《密碼學系列》|| 密碼學中的流密碼是怎麼回事?密碼學
- Oracle 11gR2密碼區分大小寫Oracle密碼
- Oracle11g 特性——密碼區分大小寫Oracle密碼
- 11G開始 密碼區分大小寫密碼
- 設定Oracle的使用者密碼不區分大小寫Oracle密碼
- oralce密碼檔案要注意SID的大小寫問題密碼
- pyqt5的mdimainwindowQTAI
- 希爾密碼(hill密碼)密碼
- 心底的密碼密碼
- PbootCMS忘記密碼後的重置密碼流程boot密碼
- 密碼安全:密碼設定要求,密碼爆破辦法,密碼歸類使用,密碼處置方案密碼
- 自己寫的一個 java 解壓 rar zip 帶密碼 檔案Java密碼
- 【11gR2新特性】密碼區分大小寫密碼
- oracle 11g新特性之密碼大小寫敏感Oracle密碼
- 11G使用者密碼大小寫處理密碼
- Oracle11g新特性——密碼區分大小寫Oracle密碼
- 古典密碼的演化 (一)— 密碼學複習(二)密碼學
- 古典密碼的演化 (二)— 密碼學複習(三)密碼學
- 顯示密碼編輯框中的密碼 (轉)密碼
- mysql學習之-密碼管理(預設密碼,修改密碼,解決忘記密碼)MySql密碼
- PowerShell 指令碼中的密碼指令碼密碼
- 序列密碼與分組密碼密碼
- U盾密碼密碼重置方法密碼
- 隱藏密碼?顯示密碼?密碼
- 應用密碼學——古典密碼密碼學
- 被曝光的密碼密碼
- 在 Lotus Domino 8.5 ID Vaullt 中編寫密碼重置程式密碼
- 【密碼學系列】|| 分組密碼的工作模式詳解密碼學模式