'How to automatically close the dialog after verification
I have a simple program and before running it the activation code is validated in the database (I have encrypted and checked the time and date but they are not mentioned here).
Important, if this pre-existing code has expired, the user will be prompted to enter an effective code.
And if the code is still active, QDialog will be discarded and the program will continue to run
The problem here is that the small window does not close
I have tried to use self.close(), self.accept() and self.reject() But it didn't work
from PyQt5.QtWidgets import QDialog
from PyQt5.QtCore import QDate
import sys,sqlite3
from MainWindowUi import Ui_mainUi
class MainWindow(Ui_mainUi):
def __init__(self):
super(MainWindow, self).__init__()
#........
self.checkActiv()
def checkActiv(self):
ac = checkActivation()
n = ac.exec_()
if n == QDialog.Rejected:
sys.exit()
class checkActivation(QDialog):
def __init__(self):
super().__init__()
#.................
self.checkactive()
def checkactive(self):
db = sqlite3.connect("prog_data/activation.db")
rd = db.execute("select * from activ")
s = rd.fetchone()
yrnow=str(QDate.currentDate().year())
if int(yrnow) <= int(s[2]):
# H E R E
# This window must be closed
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
