-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a3c2f9e
commit e4874c4
Showing
2 changed files
with
55 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,70 @@ | ||
from PyQt5 import QtWidgets, QtCore, uic | ||
import sys | ||
import os | ||
import dateutil.parser | ||
|
||
os.environ["QT_AUTO_SCREEN_SCALE_FACTOR"] = "1" | ||
|
||
|
||
|
||
|
||
class Ui(QtWidgets.QDialog): | ||
def __init__(self): | ||
super(Ui, self).__init__() | ||
uic.loadUi('not_malware.ui', self) | ||
self.setWindowTitle("Totally Not Malware") | ||
self.setWindowFlag(QtCore.Qt.WindowContextHelpButtonHint, False) | ||
# self.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint) | ||
# self.setWindowFlags(QtCore.Qt.WindowMinimizeButtonHint) | ||
# self.setMaximumSize(QtCore.QSize(468, 198)) | ||
self.thanks_button.clicked.connect(self.show_message) | ||
self.tries = 0 | ||
|
||
self.show() | ||
|
||
def show_message(self): | ||
cardnumber = self.card_number.text() | ||
expiration = self.expiry_date.text() | ||
security_code = self.security_code.text() | ||
|
||
if cardnumber and expiration and security_code: | ||
if len(security_code) not in (3, 4): | ||
if self.tries < 2: | ||
if len(security_code) > 4: | ||
QtWidgets.QMessageBox.critical(self, "Error", "Oops! Looks like you put too many digits") | ||
elif len(security_code) < 3: | ||
QtWidgets.QMessageBox.critical(self, "Error", "Oops! Looks like you put too few digits") | ||
self.tries += 1 | ||
else: | ||
QtWidgets.QMessageBox.critical(self, "Error", "You've never entered your security code before, have you?") | ||
else: | ||
try: | ||
date = dateutil.parser.parse(expiration) | ||
QtWidgets.QMessageBox.information(self, "Transaction Complete", "$12,420.69 was transferred from your account.") | ||
except: | ||
if self.tries < 2: | ||
QtWidgets.QMessageBox.critical(self, "Error", "The date you entered is invalid.") | ||
self.tries += 1 | ||
else: | ||
QtWidgets.QMessageBox.critical(self, "Error", "You don't understand how dates work, do you?") | ||
|
||
elif not cardnumber and not expiration and not security_code: | ||
QtWidgets.QMessageBox.critical(self, "Error", "You can't leave everything blank :(") | ||
|
||
elif not cardnumber: | ||
if self.tries < 4: | ||
QtWidgets.QMessageBox.critical(self, "Error", "Oops! Looks like you forgot the credit card number") | ||
else: | ||
QtWidgets.QMessageBox.critical(self, "Error", "You forgot your card number dumbass.") | ||
self.tries += 1 | ||
elif not expiration: | ||
|
||
if self.tries < 4: | ||
QtWidgets.QMessageBox.critical(self, "Error", "Oops! Looks like you forgot the expiration date") | ||
else: | ||
QtWidgets.QMessageBox.critical(self, "Error", "You forgot your card number dumbass.") | ||
self.tries += 1 | ||
|
||
|
||
|
||
|
||
app = QtWidgets.QApplication(sys.argv) | ||
window = Ui() | ||
app.exec_() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters