Skip to content

Commit

Permalink
Add funny error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
CaptainStabs committed Jul 24, 2024
1 parent a3c2f9e commit e4874c4
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 7 deletions.
54 changes: 51 additions & 3 deletions gui.py
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_()
8 changes: 4 additions & 4 deletions not_malware.ui
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ credit card information, p-please?</string>
<bool>false</bool>
</property>
</widget>
<widget class="QPushButton" name="pushButton">
<widget class="QPushButton" name="thanks_button">
<property name="geometry">
<rect>
<x>300</x>
Expand All @@ -85,7 +85,7 @@ credit card information, p-please?</string>
<string>Th-thanks</string>
</property>
</widget>
<widget class="QLineEdit" name="lineEdit">
<widget class="QLineEdit" name="card_number">
<property name="geometry">
<rect>
<x>352</x>
Expand All @@ -95,7 +95,7 @@ credit card information, p-please?</string>
</rect>
</property>
</widget>
<widget class="QLineEdit" name="lineEdit_2">
<widget class="QLineEdit" name="expiry_date">
<property name="geometry">
<rect>
<x>350</x>
Expand All @@ -105,7 +105,7 @@ credit card information, p-please?</string>
</rect>
</property>
</widget>
<widget class="QLineEdit" name="lineEdit_3">
<widget class="QLineEdit" name="security_code">
<property name="geometry">
<rect>
<x>350</x>
Expand Down

0 comments on commit e4874c4

Please sign in to comment.