标签:
部份代码:::
# -*- coding: utf-8 -*-
"""
Module implementing CreateKey.
"""
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):
"""
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_())
标签:
原文地址:http://www.cnblogs.com/xiewb/p/4579895.html