【发布时间】:2018-03-25 20:09:07
【问题描述】:
"""我已经定义了某些函数来执行密码加密。虽然加密功能正常,但我无法使用使用 PyQt5 编写的 GUI。更具体地说,我无法执行我的函数基于用户在下拉框/QCombobox中选择的加密类型。 """
class App(QMainWindow):
def __init__(self):
super().__init__()
self.title = 'Password encryption'
self.left = 10
self.top = 10
self.width = 400
self.height = 200
self.initUI()
def initUI(self):
self.setWindowTitle(self.title)
self.setGeometry(self.left, self.top, self.width, self.height)
# Create textbox
self.textbox = QLineEdit(self)
self.textbox.move(30, 35)
self.textbox.resize(350, 30)
# Create a button in the window
drop = QComboBox(self)
drop.addItem("None")
drop.addItem("modlensq")
drop.addItem("fishcrypt")
drop.addItem("bitman")
drop.addItem("caesarcipher")
drop.addItem("encryptcipher2")
drop.addItem("blowfishencryption")
drop.addItem("AES")
drop.move(45, 90)
inp = QLabel(self)
inp.setText("Enter the password:")
inp.move(5, 5)
# Create a drop down list to select in the window
self.button = QPushButton('Encrypt', self)
self.button.move(135, 150)
# connect button to function on_click
self.button.clicked.connect(self.on_click)
self.show()
@pyqtSlot()
def on_click(self):
textboxValue = self.textbox.text()
QMessageBox.question(self, 'password after encryption', "encrypted form: " + textboxValue , QMessageBox.Ok,
QMessageBox.Ok)
self.textbox.setText("")
if __name__ == '__main__':
app = QApplication(sys.argv)
ex = App()
sys.exit(app.exec_())
【问题讨论】:
标签: python python-3.x combobox pyqt5 qcombobox