Pastebin
API
tools
faq
paste
Login
Sign up
Please fix the following errors:
New Paste
Syntax Highlighting
#---------------- # --- main.py --- #---------------- import tkinter as tk from tkinter import ttk, messagebox import re import locale from businesslogic import BusinessLogic from dataaccesslayer import DataAccessLayer def main(): # create main window window = tk.Tk() window.title('Create new account...') window.geometry('600x225') window.minsize(600, 225) # create an instance of the BusinessLogic & DataAccessLayer classes bl = BusinessLogic(window) dal = DataAccessLayer(window) def createAccount(): #routingNumber, accountNumber, openingDeposit): routingNumber = txtRoutingNumber.get() accountNumber = txtAccountNumber.get() openingDeposit = formatAsCurrency(float(txtOpeningDeposit.get())) # dal.insertNewAccount() print(f"\nCreating new account...\n" f"\tRouting #: {routingNumber}\n" f"\tAccount #: {accountNumber}\n" f"\t Deposit: {formatAsCurrency(openingDeposit)}\n\n") return True def formatAsCurrency(amount): return '{:.2f}'.format(float(amount)) # create label/prompt for the routing number lblRoutingNumber = ttk.Label(window, text="ABA routing number: ", justify="right", borderwidth=0, font="Tahoma 12", relief="solid") lblRoutingNumber.place(x=85, y=42) # create entry box for routing number txtRoutingNumber = ttk.Entry( window, validate="key", width=10, justify="left", name="routingNumber", font="Tahoma 12", validatecommand=(window.register(bl.validateRoutingNumber), '%S', # character(s) just entered or deleted '%s', # text already in the textbox, before any changes '%P', # text in the textbox if the insertion/deletion is allowed '%d', # action code, see above "txtRoutingNumber", 9 # maximum number of digits allowed ) ) txtRoutingNumber.place(x=307, y=40) # create label/prompt for the account number lblAcctNumber = ttk.Label(window, text="Account number: ", justify="right", borderwidth=0, font="Tahoma 12", relief="solid") lblAcctNumber.place(x=124, y=82) # create entry object for the account number txtAccountNumber = ttk.Entry(window, validate="key", width=19, justify="left", name="accountNumber", font="Tahoma 12", validatecommand=(window.register(bl.validateInputIsDigit), '%S', False) #, '%W', 9, 18) ) txtAccountNumber.place(x=307, y=80) # create label/prompt for the opening deposit lblOpeningDeposit = ttk.Label(window, text="Opening deposit: $", justify="right", borderwidth=0, font="Tahoma 12", relief="solid") lblOpeningDeposit.place(x=111, y=122) # create entry object for the opening deposit txtOpeningDeposit = ttk.Entry(window, validate="key", width=10, justify="left", name="openingDeposit", font="Tahoma 12", validatecommand=(window.register(bl.validateIsCurrency), '%S', '%s', '%P', True) ) txtOpeningDeposit.place(x=307, y=120) # create "Submit" button btnOK = ttk.Button(window, name="btnOK", text="Submit", width=10, command=createAccount(), #createAccount()) ).place(x=80, y=180) # create "Cancel" button btnCancel = ttk.Button(window, name="btnCancel", text="Cancel", width=10, command=window.destroy ).place(x=400, y=180) # set initial focus to the ABA routing number Entry() widget txtRoutingNumber.focus() # run ininite loop window.mainloop() # EOFunc main() if __name__ == "__main__": main() #------------------------- # --- businesslogic.py --- #------------------------- import tkinter as tk from tkinter import ttk, messagebox import re import locale class BusinessLogic: def __init__(self, parentGUI): self.parent = parentGUI def validateRoutingNumber(self, inputText, # text that was entered or deleted currentText, # text that currently in the textbox, *before* any change proposedText, # text that will be in the textbox, *if* the change is allowed actionCode, # see block comment abovew widgetName, # name of the widget object maxLength): # maximum number of digits # if number of digits currently in the textbox is less than the maximum length... if (len(proposedText) < int(maxLength)): # make sure text entered is a digit, not a character if (inputText.isdigit()): return True else: return False # length of text currently in the textbox is -eq or -gt the maximum length else: if (len(proposedText) > int(maxLength)): return False if (self.isValidRoutingNumber(proposedText)): return True # accept the input else: return False # reject it return def isValidRoutingNumber(self, routingNumber): n = 0 for i in range(0, len(str(routingNumber)), 3): n += int(str(routingNumber)[i]) * 3 + \ int(str(routingNumber)[i+1]) * 7 + \ int(str(routingNumber)[i+2]) if (n != 0 and n % 10 == 0): #print(f"{routingNumber} is a valid ABA routing number.") # messagebox.showinfo("Information", f"\"{routingNumber}\" is a valid ABA routing number.") # print(f"Routing number {routingNumber} is valid") return True else: print(f"{routingNumber} is *not* a valid ABA routing number!") # messagebox.showerror("Error", f"\"{routingNumber}\" is not a valid ABA routing number!") return False return def validateInputIsDigit(self, insertText, acceptDecimalPoint): if (acceptDecimalPoint and insertText == "."): return True else: if insertText.isdigit(): return True else: return False def isValidAccountNumber(accountNumber): if accountNumber is None: return False else: regEx = r'^[0-9]{9,18}$' # account number must be contain between 9 and 18 digits if re.match(regEx, accountNumber): return True else: return False return def validateIsCurrency( self, userInput, # amount that was entered or deleted currentAmount, # amount that's currently in the textbox, *before* any change proposedAmount, # amount that will be in the textbox, *if* the change is allowed acceptDecimal = True, # accept a decimal point? acceptMinus = False): # accept a minus sign? charsToReject = [",", "$", "."] if not acceptMinus: charsToReject.append("-") if acceptDecimal: charsToReject.remove(".") # TODO: add currency symbol for the user's locale if (userInput in charsToReject): return False # if the *proposed* amount already contains a decimal point... if ("." in proposedAmount): # and it would have more than 2 decimal places should the insertion/deletion be accepted if (len(str(proposedAmount).split(".")[1]) > 2): return False if (acceptDecimal and userInput == "."): # if the proposed amount would contain more than 1 decimal point if (proposedAmount.count(".") > 1): return False return True else: if (self.isValidCurrency(proposedAmount)): return True else: return False def isValidCurrency(self, amount): rePattern = r'^[1-9]\d*(\.\d{1,2})?$' try: if re.match(rePattern, "{:.2f}".format(float(amount))): return True else: return False except: return False return #--------------------------- # --- dataaccesslayer.py --- #--------------------------- #import re #import locale # TODO: Implement Sqlite class DataAccessLayer: def __init__(self, parentGUI): self.parent = parentGUI pass # stub function until Sqlite is implemented def insertNewAccount(self): routingNumber = self.parent.txtRoutingNumber.get(), accountNumber = self.parent.txtAccountNumber.get() openingDeposit = self.parent.txtOpeningDeposit.get() print(f"\nCreating new account...\n" f"\tRouting #: {routingNumber}\n" f"\tAccount #: {accountNumber}\n" f"\t Deposit: ${openingDeposit}\n\n")
Optional Paste Settings
Category:
None
Cryptocurrency
Cybersecurity
Fixit
Food
Gaming
Haiku
Help
History
Housing
Jokes
Legal
Money
Movies
Music
Pets
Photo
Science
Software
Source Code
Spirit
Sports
Travel
TV
Writing
Tags:
Syntax Highlighting:
None
Bash
C
C#
C++
CSS
HTML
JSON
Java
JavaScript
Lua
Markdown (PRO members only)
Objective C
PHP
Perl
Python
Ruby
Swift
4CS
6502 ACME Cross Assembler
6502 Kick Assembler
6502 TASM/64TASS
ABAP
AIMMS
ALGOL 68
APT Sources
ARM
ASM (NASM)
ASP
ActionScript
ActionScript 3
Ada
Apache Log
AppleScript
Arduino
Asymptote
AutoIt
Autohotkey
Avisynth
Awk
BASCOM AVR
BNF
BOO
Bash
Basic4GL
Batch
BibTeX
Blitz Basic
Blitz3D
BlitzMax
BrainFuck
C
C (WinAPI)
C Intermediate Language
C for Macs
C#
C++
C++ (WinAPI)
C++ (with Qt extensions)
C: Loadrunner
CAD DCL
CAD Lisp
CFDG
CMake
COBOL
CSS
Ceylon
ChaiScript
Chapel
Clojure
Clone C
Clone C++
CoffeeScript
ColdFusion
Cuesheet
D
DCL
DCPU-16
DCS
DIV
DOT
Dart
Delphi
Delphi Prism (Oxygene)
Diff
E
ECMAScript
EPC
Easytrieve
Eiffel
Email
Erlang
Euphoria
F#
FO Language
Falcon
Filemaker
Formula One
Fortran
FreeBasic
FreeSWITCH
GAMBAS
GDB
GDScript
Game Maker
Genero
Genie
GetText
Go
Godot GLSL
Groovy
GwBasic
HQ9 Plus
HTML
HTML 5
Haskell
Haxe
HicEst
IDL
INI file
INTERCAL
IO
ISPF Panel Definition
Icon
Inno Script
J
JCL
JSON
Java
Java 5
JavaScript
Julia
KSP (Kontakt Script)
KiXtart
Kotlin
LDIF
LLVM
LOL Code
LScript
Latex
Liberty BASIC
Linden Scripting
Lisp
Loco Basic
Logtalk
Lotus Formulas
Lotus Script
Lua
M68000 Assembler
MIX Assembler
MK-61/52
MPASM
MXML
MagikSF
Make
MapBasic
Markdown (PRO members only)
MatLab
Mercury
MetaPost
Modula 2
Modula 3
Motorola 68000 HiSoft Dev
MySQL
Nagios
NetRexx
Nginx
Nim
NullSoft Installer
OCaml
OCaml Brief
Oberon 2
Objeck Programming Langua
Objective C
Octave
Open Object Rexx
OpenBSD PACKET FILTER
OpenGL Shading
Openoffice BASIC
Oracle 11
Oracle 8
Oz
PARI/GP
PCRE
PHP
PHP Brief
PL/I
PL/SQL
POV-Ray
ParaSail
Pascal
Pawn
Per
Perl
Perl 6
Phix
Pic 16
Pike
Pixel Bender
PostScript
PostgreSQL
PowerBuilder
PowerShell
ProFTPd
Progress
Prolog
Properties
ProvideX
Puppet
PureBasic
PyCon
Python
Python for S60
QBasic
QML
R
RBScript
REBOL
REG
RPM Spec
Racket
Rails
Rexx
Robots
Roff Manpage
Ruby
Ruby Gnuplot
Rust
SAS
SCL
SPARK
SPARQL
SQF
SQL
SSH Config
Scala
Scheme
Scilab
SdlBasic
Smalltalk
Smarty
StandardML
StoneScript
SuperCollider
Swift
SystemVerilog
T-SQL
TCL
TeXgraph
Tera Term
TypeScript
TypoScript
UPC
Unicon
UnrealScript
Urbi
VB.NET
VBScript
VHDL
VIM
Vala
Vedit
VeriLog
Visual Pro Log
VisualBasic
VisualFoxPro
WHOIS
WhiteSpace
Winbatch
XBasic
XML
XPP
Xojo
Xorg Config
YAML
YARA
Z80 Assembler
ZXBasic
autoconf
jQuery
mIRC
newLISP
q/kdb+
thinBasic
Paste Expiration:
Never
Burn after read
10 Minutes
1 Hour
1 Day
1 Week
2 Weeks
1 Month
6 Months
1 Year
Paste Exposure:
Public
Unlisted
Private
Folder:
(members only)
Password
NEW
Enabled
Disabled
Burn after read
NEW
Paste Name / Title:
Create New Paste
Hello
Guest
Sign Up
or
Login
Sign in with Facebook
Sign in with Twitter
Sign in with Google
You are currently not logged in, this means you can not edit or delete anything you paste.
Sign Up
or
Login
Public Pastes
This month smells like money
CSS | 25 min ago | 1.05 KB
✅ API Flaw Money Method
CSS | 26 min ago | 1.05 KB
⭐ Exploit Documentation ⭐
CSS | 26 min ago | 1.05 KB
Untitled
21 hours ago | 0.71 KB
Custom em_booking_validate for dependent_even...
2 days ago | 1.15 KB
Untitled
2 days ago | 22.13 KB
[TLF 18.III] "PROJECT BLACKWIGHT" F...
2 days ago | 10.98 KB
[TLF 18.II] CLEARANCE
2 days ago | 2.21 KB
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the
Cookies Policy
.
OK, I Understand
Not a member of Pastebin yet?
Sign Up
, it unlocks many cool features!