标签:python
# -*- coding: utf-8 -*- from PyQt4.QtCore import pyqtSignature from PyQt4.QtGui import QDialog from PyQt4 import QtGui,QtCore from Ui_CreateKey import Ui_CreateKey import base64,uuid class CreateKey(QDialog, Ui_CreateKey): def __init__(self, parent=None): 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_())
本文出自 “xwb” 博客,请务必保留此出处http://xiewb.blog.51cto.com/11091636/1792299
标签:python
原文地址:http://xiewb.blog.51cto.com/11091636/1792299