File: kpassworddialog.py

package info (click to toggle)
kf6-kwidgetsaddons 6.20.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 32,880 kB
  • sloc: cpp: 32,333; python: 767; xml: 258; ansic: 85; sh: 14; makefile: 7
file content (36 lines) | stat: -rw-r--r-- 1,035 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# SPDX-FileCopyrightText: 2024 Manuel Alcaraz Zambrano <manuelalcarazzam@gmail.com>
# SPDX-License-Identifier: BSD-2-Clause

import sys

from KWidgetsAddons import KPasswordDialog
from PySide6 import QtWidgets


class KPasswordDialogDemo(QtWidgets.QWidget):
    def __init__(self):
        super().__init__()

        self.text = QtWidgets.QLabel("KPasswordDialog example")

        self.button = QtWidgets.QPushButton("Change password")
        self.button.clicked.connect(self.open_dialog)

        self.layout = QtWidgets.QVBoxLayout(self)
        self.layout.addWidget(self.text)
        self.layout.addWidget(self.button)
    
    def open_dialog(self):
        self.dialog = KPasswordDialog(self)
        self.dialog.setPrompt("Enter a password")
        self.dialog.gotPassword.connect(lambda password: self.text.setText(f"Your password is: {password}"))
        self.dialog.show()


if __name__ == "__main__":
    app = QtWidgets.QApplication([])

    widget = KPasswordDialogDemo()
    widget.show()

    sys.exit(app.exec())