import sys
from PyQt6.QtWidgets import *
class CustomDialog(QDialog):
def __init__(self):
super().__init__()
layout = QVBoxLayout()
self.setLayout(layout)
self.password_entry = QLineEdit()
layout.addWidget(self.password_entry)
self.button = QPushButton("test")
self.button.clicked.connect(self.auth)
layout.addWidget(self.button)
def auth(self):
password = self.password_entry.text()
if password == "passwd":
self.accept()
class App(QWidget):
def __init__(self):
super().__init__()
layout = QVBoxLayout()
self.setLayout(layout)
self.label = QLabel("sucsses")
layout.addWidget(self.label)
dlg = CustomDialog()
result = dlg.exec()
if result != QDialog.DialogCode.Accepted:
self.close()
return
self.show()
def main():
app = QApplication(sys.argv)
window = App()
# window.show()
sys.exit(app.exec())
if __name__ == "__main__":
main()