部份代码:::
# -*- coding: utf-8 -*- """Module implementing CreateKey.""" from PyQt4.QtCore import pyqtSignaturefrom PyQt4.QtGui import QDialogfrom PyQt4 import QtGui,QtCorefrom Ui_CreateKey import Ui_CreateKeyimport base64,uuid class CreateKey(QDialog, Ui_CreateKey): """ Class documentation goes here. """ def __init__(self, parent=None): """ Constructor @param parent reference to the parent widget (QWidget) """ QDialog.__init__(self, parent) self.clipboard = QtGui.QApplication.clipboard() self.setupUi(self) QtCore.QObject.connect(self.pushButton_3,QtCore.SIGNAL("clicked()"),self.clear) QtCore.QObject.connect(self.pushButton_2,QtCore.SIGNAL("clicked()"),self.getkey) @pyqtSignature("") def on_pushButton_clicked(self): key = base64.b64encode(uuid.uuid4().bytes + uuid.uuid4().bytes) self.textBrowser.append(str(key)) @pyqtSignature("") def clear(self): self.textBrowser.clear() @pyqtSignature("") def getkey(self): self.clipboard.setText(self.textBrowser.toPlainText().split(‘\n‘)[-1]) if __name__ == "__main__": import sys app = QtGui.QApplication(sys.argv) ui = CreateKey() ui.show() sys.exit(app.exec_())
时间: 2024-11-29 09:29:26