def open_wallet():
    app = QtGui.QApplication([])
wallet = KWallet.Wallet.openWallet(KWallet.Wallet.LocalWallet(), 0)
if not wallet.hasFolder('kwallet_example'):
    wallet.createFolder('kwallet_example')
wallet.setFolder('kwallet_example')
return wallet

def get_password(wallet):
    key, qstr_password = wallet.readPassword('mykey')
return str(qstr_password)

def set_password(wallet, password):
    wallet.writePassword('mykey', password)
Using KWallet in PyQt4