我在使用Python-GnuGP lib的GPG密钥生成程序员中工作(只是为了让我的生活更轻松)。我为UI和获取值使用了PyQt,并使用了两个类(一个用于主up,另一个用于对话框)来生成我的键。问题是,当我执行GenButton时,我在终端中得到以下错误:
Key-Type: RSA
Key-Length: 4096
Passphrase: 1202
Name-Real: TestUser
Name-Email: test@gmail.com
Expire-Date: 2019-3-3
%commit
key not created下面是我的代码:我使用内置的值对其进行了测试,一切工作正常,但是当我从QlineEdit框传递值时,我得到了上面的错误。
class GenKeyDialog(QtGui.QDialog, Ui_GPGGenerateWindow):
def __init__(self):
QtGui.QMainWindow.__init__(self)
self.setupUi(self)
self.gpg = gnupg.GPG(homedir='keys')
self.gpg.encoding = 'utf-8'
self.GenButton.clicked.connect(self.genkey)
def genkey(self):
type = "RSA"
length = 4096
name = str(self.NameEdit.text())
email = str(self.EmailEdit.text())
if str(self.PassEdit.text()) == str(self.RPassEdit.text()):
passs = str(self.PassEdit.text())
else:
print "passwords do not match"
return
expire = str(self.ExpireEdit.text())
input_data = self.gpg.gen_key_input(key_type=type, key_length=length, name_real=name, name_email=email, passphrase=passs, expire_date=expire)
print input_data
key = self.gpg.gen_key(input_data)
print key
class Main_window_ex(QMainWindow, Ui_MainWindow):
def createPGP(self):
dialog = GenKeyDialog()
ret = dialog.exec_()
def __init__(self, parent = None):
"""
Default Constructor. It can receive a top window as parent.
"""截图:

发布于 2016-10-28 16:18:06
您正在将Main_window_ex.__init__实现为一个空函数。当该类的实例被初始化时,不会发生任何事情。
我怀疑您想要的是让Main_window_ex实例完全像它的父类一样初始化。如果这是您想要的,就不要实现特定的Main_window_ex.__init__。
您在学习the Python tutorial时就已经了解到了这一点,特别是它关于classes and inheritance的章节。希望这是一个提醒:-)
https://stackoverflow.com/questions/33855429
复制相似问题