Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 23

Python is a powerful general-purpose programming language.

It is used in web development, data


science, creating software prototypes, and so on. Fortunately for beginners, Python has simple easy-
to-use syntax. This makes Python an excellent language to learn to program for beginners.
Python is a general-purpose interpreted, interactive, object-oriented, and high-level programming
language. It was created by Guido van Rossum during 1985- 1990. Like Perl, Python source code is
also available under the GNU General Public License (GPL).
Why to Learn Python?
Python is a high-level, interpreted, interactive and object-oriented scripting language. Python is
designed to be highly readable. It uses English keywords frequently where as other languages use
punctuation, and it has fewer syntactical constructions than other languages.
Python is a MUST for students and working professionals to become a great Software Engineer
specially when they are working in Web Development Domain. I will list down some of the key
advantages of learning Python:
Python is Interpreted − Python is processed at runtime by the interpreter. You do not need to
compile your program before executing it. This is similar to PERL and PHP.
Python is Interactive − You can actually sit at a Python prompt and interact with the interpreter
directly to write your programs.
Python is Object-Oriented − Python supports Object-Oriented style or technique of programming
that encapsulates code within objects.
Python is a Beginner's Language − Python is a great language for the beginner-level programmers
and supports the development of a wide range of applications from simple text processing to WWW
browsers to games.
Characteristics of Python
Following are important characteristics of Python Programming −
It supports functional and structured programming methods as well as OOP.
It can be used as a scripting language or can be compiled to byte-code for building large applications.
It provides very high-level dynamic data types and supports dynamic type checking.
It supports automatic garbage collection.
It can be easily integrated with C, C++, COM, ActiveX, CORBA, and Java.
Hello World using Python.
Just to give you a little excitement about Python, I'm going to give you a small conventional Python
Hello World program, You can try it using Demo link.
Live Demo
print ("Hello, Python!");
Applications of Python
As mentioned before, Python is one of the most widely used language over the web. I'm going to list
few of them here:
Easy-to-learn − Python has few keywords, simple structure, and a clearly defined syntax. This allows
the student to pick up the language quickly.
Easy-to-read − Python code is more clearly defined and visible to the eyes.
Easy-to-maintain − Python's source code is fairly easy-to-maintain.
A broad standard library − Python's bulk of the library is very portable and cross-platform
compatible on UNIX, Windows, and Macintosh.
Interactive Mode − Python has support for an interactive mode which allows interactive testing and
debugging of snippets of code.
Portable − Python can run on a wide variety of hardware platforms and has the same interface on
all platforms.
Extendable − You can add low-level modules to the Python interpreter. These modules enable
programmers to add to or customize their tools to be more efficient.
Databases − Python provides interfaces to all major commercial databases.
GUI Programming − Python supports GUI applications that can be created and ported to many
system calls, libraries and windows systems, such as Windows MFC, Macintosh, and the X Window
system of Unix.
Scalable − Python provides a better structure and support for large programs than shell scripting.

What is a Database?
A database is a separate application that stores a collection of data. Each database has one or more
distinct APIs for creating, accessing, managing, searching and replicating the data it holds.
Other kinds of data stores can also be used, such as files on the file system or large hash tables in
memory but data fetching and writing would not be so fast and easy with those type of systems.
Nowadays, we use relational database management systems (RDBMS) to store and manage huge
volume of data. This is called relational database because all the data is stored into different tables
and relations are established using primary keys or other keys known as Foreign Keys.
A Relational DataBase Management System (RDBMS) is a software that −
Enables you to implement a database with tables, columns and indexes.
Guarantees the Referential Integrity between rows of various tables.
Updates the indexes automatically.
Interprets an SQL query and combines information from various tables.
RDBMS Terminology
Before we proceed to explain the MySQL database system, let us revise a few definitions related to
the database.
Database − A database is a collection of tables, with related data.
Table − A table is a matrix with data. A table in a database looks like a simple spreadsheet.
Column − One column (data element) contains data of one and the same kind, for example the
column postcode.
Row − A row (= tuple, entry or record) is a group of related data, for example the data of one
subscription.
Redundancy − Storing data twice, redundantly to make the system faster.
Primary Key − A primary key is unique. A key value can not occur twice in one table. With a key, you
can only find one row.
Foreign Key − A foreign key is the linking pin between two tables.
Compound Key − A compound key (composite key) is a key that consists of multiple columns,
because one column is not sufficiently unique.
Index − An index in a database resembles an index at the back of a book.
Referential Integrity − Referential Integrity makes sure that a foreign key value always points to an
existing row.
MySQL Database
MySQL is a fast, easy-to-use RDBMS being used for many small and big businesses. MySQL is
developed, marketed and supported by MySQL AB, which is a Swedish company. MySQL is becoming
so popular because of many good reasons −
MySQL is released under an open-source license. So you have nothing to pay to use it.
MySQL is a very powerful program in its own right. It handles a large subset of the functionality of
the most expensive and powerful database packages.
MySQL uses a standard form of the well-known SQL data language.
MySQL works on many operating systems and with many languages including PHP, PERL, C, C++,
JAVA, etc.
MySQL works very quickly and works well even with large data sets.
MySQL is very friendly to PHP, the most appreciated language for web development.
MySQL supports large databases, up to 50 million rows or more in a table. The default file size limit
for a table is 4GB, but you can increase this (if your operating system can handle it) to a theoretical
limit of 8 million terabytes (TB).
MySQL is customizable. The open-source GPL license allows programmers to modify the MySQL
software to fit their own specific environments.

from tkinter import *


import mysql.connector as sql
import matplotlib
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
from matplotlib.figure import Figure
from PIL import ImageTk, Image
import numpy as np
from base64 import b64encode, b64decode
class startpage :

def __init__(self, win) :

''' It is a reserved function in Python class which makes all the function initialize the attributes
inside
the class. It is also called as a constructor is object oriented terminology. '''

self.win = win
self.win.geometry("800x500+300+150")
self.win.title("Salary Manager")
# self.win.configure(bg = "#15350204f")

st = StringVar()
self.intt = IntVar()

def main_table() :

self.cur.execute("create table main"


"("
"Name varchar(25), "
"Age mediumint, "
"Gender char(7), "
"Password varchar(100) NOT NULL, "
"Job char(5), "
"Job_Interval char(5), "
"Salary int, "
"Extra_Income "
"mediumint, "
"House_Rent mediumint, "
"Electric_Bill mediumint, "
"Food mediumint, "
"Cooking mediumint, "
"Health mediumint, "
"Education mediumint, "
"Water_Supply mediumint, "
"Shopping mediumint, "
"Travelling mediumint, "
"Internet mediumint,"
"Savings mediumint, "
"Loan mediumint, "
"Extra mediumint, "
"Donations mediumint"
")"
"")

self.db = sql.connect(host = "localhost", user = "root", passwd = "18180612")


self.cur = self.db.cursor()

try :

self.cur.execute("create database salarymanagement")


self.db = sql.connect(host = "localhost", user = "root", passwd = "18180612", database =
"salarymanagement")
self.cur = self.db.cursor()

except sql.errors.DatabaseError :
self.db = sql.connect(host = "localhost", user = "root", passwd = "18180612", database =
"salarymanagement")
self.cur = self.db.cursor()

try :

main_table()

except sql.errors.ProgrammingError :
pass

finally :

try :

main_table()

except sql.errors.ProgrammingError :

pass

self.home_frame = Frame(win, width = 800, height = 500, bg = "#17616E")


self.home_frame.place(x = 0, y = 0)

self.lab1 = Label(self.home_frame, text = "Name :", bg = "#17616E", fg = "white", font =


"agencyfb")
self.lab2 = Label(self.home_frame, text = "Age :", bg = "#17616E", fg = "white", font =
"agencyfb")
self.labp = Label(self.home_frame, text = "Password :", bg = "#17616E")
self.labp.configure(fg = "white", font = "agencyfb")
self.labo = Label(self.home_frame, text = "Please Login / Sign Up to continue :")
self.labo.configure(bg = "#17616E", fg = "#A09995", font = "agencyfb")

self.lab1.place(x = 300, y = 175)


self.lab2.place(x = 300, y = 200)
self.labp.place(x = 300, y = 225)
self.labo.place(x = 294, y = 140)

def coountdown(time, fab) :

''' This function coountdown() is used for time interval. I have used this function several time
for
vanishing different frames. '''

if time == -1 :
fab.destroy()
else :
fab.after(500, coountdown, time-1, fab)

fab = Frame(self.win, bg = "white", width = 800, height = 500)


fab.place(x = 0, y = 0)
coountdown(2, fab)

basewidth = 300
img = Image.open('logo12.PNG')
# wpercent = (basewidth/float(img.size[0]))
# hsize = int((float(img.size[1])*float(wpercent)))
im = img.resize((90,90), Image.ANTIALIAS)
imgii = ImageTk.PhotoImage(im)
imi = img.resize((150, 130), Image.ANTIALIAS)
imgia = ImageTk.PhotoImage(imi)

panel = Label(fab, image = imgii)


panel.image = imgii
panel.place(x = 355, y = 205)

varm = IntVar()
st = StringVar()
st1 = StringVar()
self.intt = IntVar()

def mark() :

''' The function mark() is used for hiding password in the first frame or login page. This
function is
embedded inside the Checkbutton widget so that if the button is checked then the password
will bo shown
or for any other case it will be replaced by a star(*). '''

if varm.get() == 1 :

self.password.configure(show = "")
check.configure(text = "Hide")

elif varm.get() == 0 :

self.password.configure(show = "*")
check.configure(text = "Show")

self.name = Entry(self.home_frame, textvariable = st, font = "Arial", bg = "#FDFEFE", width = 16,


fg = "#F02D94", bd = 0, selectbackground = "#B9AA8F")
self.age = Entry(self.home_frame, textvariable = self.intt, font = "Arial", bg = "#FDFEFE", width =
16,
fg = "#F02D94", bd = 0, selectbackground = "#B9AA8F")
self.password = Entry(self.home_frame,textvariable = st1, show = "*", font = "Arial", bg =
"#FDFEFE",
width = 16, fg = "#FDFEFE", bd = 0, selectbackground = "#FDFEFE")
check = Checkbutton(self.home_frame, text = "Show", command = mark, font = "Arial", bd = 0)
check.configure(onvalue = 1, offvalue = 0, variable = varm, bg = "#17616E", fg = "white",
activebackground = "#2A7888")

self.name.place(x = 385, y = 175)


self.age.place(x = 385, y = 200)
self.password.place(x = 385, y = 225)
check.place(x = 534, y = 225)

self.messg = "Subham Das\n"

def like(event) :

''' The function like() is used to display the image in the login frame and it also display the
about
section of application by double clicking on the image. I have also packed a button named Out
to exiting
about frame displayed on the main frame. '''
creator_info = Frame(self.home_frame, width = 600, height = 380)
creator_info.place(x = 100, y = 60)

messg_widget = Message(creator_info, text = self.messg, bg = "pink", fg = "black")


messg_widget.place(x = 100, y = 100)

def destrot() :

''' This small function destrot() is packed inside the Button named out for destroying the
about
frame or to clear the about section. '''

creator_info.destroy()

quite = Button(creator_info,text = "Out", command = destrot, bd = 0, fg = "red")


quite.place(x = 570, y = 0)

top = Button(self.home_frame, image = imgia, bd = 0)


top.bind('<Double-Button>', like)
top.image = imgia
top.place(x = 25, y = 25)

# self.flag = ""
# self.cart = ""
self.constant = False

#self.win.iconbitmap('management_ico.ico')

def options() :

''' The function options() is used for displaying the different genders in the login page. I have
used
the OptionMenu widget for making the Option Button. This options are specified with the four
different
strings. '''

self.lab3 = Label(self.home_frame, text = "Gender :", bg = "#17616E", fg = "white", font =


"agencyfb")
self.lab3.place(x = 300, y = 250)

options = [
" None ",
" Male ",
" Female ",
" Others "
]

st = StringVar()
st.set(options[0])
self.optnbtn = OptionMenu(self.home_frame, st, options[0], options[1], options[2],
options[3])
self.optnbtn.configure(bd = 0, height = 1, width = 12, font = "Arial", bg = "#FDFEFE", fg =
"#F02D94",
activebackground = "#B6C1C3")
self.optnbtn.place(x = 385, y = 250)
self.optnbtn1 = "gg"

options()
def service() :

''' This function service() is designed to store the Earnings of a person in a regular basis in the
service sector. I have specified different entry box using the Entry widget to store the data of
their
expenses in our MySql server. '''

self.service_frame = Frame(self.win, width = 800, height = 500, bg = "dimgrey")


self.service_frame.place(x = 0, y = 0)

self.var5 = IntVar()
self.var6 = IntVar()

self.var5.set(0)
self.var6.set(0)

self.flag = "servi"

# self.day_1.place_forget()
# self.week_1.place_forget()
# self.month_1.place_forget()

self.lab5 = Label(self.service_frame, text = "EARNINGS")


self.lab6 = Label(self.service_frame, text = "SALARY :")
self.lab7 = Label(self.service_frame, text = "EXTRA INCOME :")

self.lab5.configure(bd = 0, bg = "dimgrey", fg = "white", font = "arialroundedmtbold")


self.lab6.configure(bd = 0, bg = "dimgrey", fg = "white", font = "arialroundedmtbold")
self.lab7.configure(bd = 0, bg = "dimgrey", fg = "white", font = "arialroundedmtbold")

self.lab5.place(x = 375, y = 155)


self.lab6.place(x = 250, y = 250)
self.lab7.place(x = 250, y = 325)

self.salary_1 = Entry(self.service_frame, textvariable = self.var5)


self.extra_1 = Entry(self.service_frame, textvariable = self.var6)
self.salary_1.place(x = 390, y = 250)
self.extra_1.place(x = 390, y = 325)
user = str(self.name.get())
passwd = b64encode(bytes(self.password.get(), "utf-16")).decode()

self.cur.execute("select * from main where Name = '%s' and Password = '%s'" % (str(user),
str(passwd)))
rud = self.cur.fetchall()

if rud :

self.cur.execute("select Salary, Extra_Income from main where Name = '%s'and Job =


'servi'" %(user))
nod = self.cur.fetchone()

if nod :

rd = np.array(nod)

self.var5.set(rd[0])
self.var6.set(rd[1])

self.salary_1.configure(textvariable = self.var5)
self.extra_1.configure(textvariable = self.var6)

submit = Button(self.service_frame, text = "SUBMIT", command = expenses)


submit.configure(bd = 0, bg = "grey", fg = "red", font = "agencyfb", width = 10)
submit.place(x = 390, y = 375)

self.acc = Button(self.win, text = "12", command = account, bd = 0)


self.acc.place(x = 0, y = 240)

def business() :
income in our MySql server. '''

self.business_frame = Frame(self.win, width = 800, height = 500, bg = "dimgrey")


self.business_frame.place(x = 0, y = 0)

self.var5 = IntVar()
self.var6 = IntVar()

self.var5.set(0)
self.var6.set(0)

self.flag = "busin"

# self.day_2.place_forget()
# self.week_2.place_forget()
# self.month_2.place_forget()

self.lab8 = Label(self.business_frame, text = "EARNINGS")


self.lab9 = Label(self.business_frame, text = "SALARY :")
self.lab10 = Label(self.business_frame, text = "EXTRA INCOME :")

self.lab8.configure(bd = 0, bg = "dimgrey", fg = "white", font = "arialroundedmtbold")


self.lab9.configure(bd = 0, bg = "dimgrey", fg = "white", font = "arialroundedmtbold")
self.lab10.configure(bd = 0, bg = "dimgrey", fg = "white", font = "arialroundedmtbold")

self.lab8.place(x = 375, y = 155)


self.lab9.place(x = 250, y = 250)
self.lab10.place(x = 250, y = 325)

self.salary_1 = Entry(self.business_frame, textvariable = self.var5)


self.extra_1 = Entry(self.business_frame, textvariable = self.var6)
self.salary_1.place(x = 390, y = 250)
self.extra_1.place(x = 390, y = 325)
user = str(self.name.get())
passwd = b64encode(bytes(self.password.get(), "utf-16")).decode()

self.cur.execute("select * from main where Name = '%s' and Password = '%s'" % (str(user),
str(passwd)))
rud = self.cur.fetchall()

if rud:

self.cur.execute("select Salary, Extra_Income from main where Name = '%s'and Job =


'busin'" % (user))
nod = self.cur.fetchone()
if nod :

rd = np.array(nod)

self.var5.set(rd[0])
self.var6.set(rd[1])

self.salary_1.configure(textvariable = self.var5)
self.extra_1.configure(textvariable = self.var6)

submit = Button(self.business_frame, text = "SUBMIT", command = expenses)


submit.configure(bd = 0, bg = "grey", fg = "red", font = "agencyfb", width = 10)
submit.place(x = 390, y = 375)

self.acc = Button(self.win, text = "12", command = account, bd = 0)


self.acc.place(x = 0, y = 240)

def expenses() :
if self.salary_1.get() != "" or self.extra_1.get() != "" :
self.frame2 = Frame(self.win, bg = "blue", width = 800, height = 500)
self.frame2.place(x = 0, y = 0)
self.acc = Button(self.win, text = "12", command = account, bd = 0)
self.acc.place(x = 0, y = 240)
self.lab14 = Label(self.frame2, text = "EXPENSES", bd = 0)
self.lab14.configure(fg = "yellow", bg = "blue", font = "agencyfb")
self.lab14.place(x = 375, y = 50)
self.var7 = IntVar()
self.var8 = IntVar()
self.var9 = IntVar()
self.var10 = IntVar()
self.var11 = IntVar()
self.var12 = IntVar()
self.var13 = IntVar()
self.var14 = IntVar()
self.var15 = IntVar()
self.var16 = IntVar()
self.var17 = IntVar()
self.var18 = IntVar()
self.var19 = IntVar()
self.var20 = IntVar()

self.var7.set(0)
self.var8.set(0)
self.var9.set(0)
self.var10.set(0)
self.var11.set(0)
self.var12.set(0)
self.var13.set(0)
self.var14.set(0)
self.var15.set(0)
self.var16.set(0)
self.var17.set(0)
self.var18.set(0)
self.var19.set(0)
self.var20.set(0)

lab15 = Label(self.frame2, text = "HOUSE RENT", bd = 0)


lab16 = Label(self.frame2, text = "ELECTRIC BILLS", bd = 0)
lab17 = Label(self.frame2, text = "FOOD", bd = 0)
lab18 = Label(self.frame2, text = "COOKING EMENITIES", bd = 0)
lab19 = Label(self.frame2, text = "HEALTH", bd = 0)
lab20 = Label(self.frame2, text = "EDUCATION", bd = 0)
lab21 = Label(self.frame2, text = "WATER SUPPLY", bd = 0)
lab22 = Label(self.frame2, text = "SHOPPING", bd = 0)
lab23 = Label(self.frame2, text = "TRAVELLING", bd = 0)
lab24 = Label(self.frame2, text = "INTERNET &", bd = 0)
lab24_a = Label(self.frame2, text = "COMMUNICATION BILLS", bd = 0)
lab25 = Label(self.frame2, text = "SAVINGS", bd = 0)
lab26 = Label(self.frame2, text = "LOAN REPAYMENT", bd = 0)
lab27 = Label(self.frame2, text = "EXTRA", bd = 0)
lab28 = Label(self.frame2, text = "DONATIONS", bd = 0)

lab15.configure(fg = "#AC6D0F", bg = "blue", font = "Arial")


lab16.configure(fg = "#AC6D0F", bg = "blue", font = "Arial")
lab17.configure(fg = "#AC6D0F", bg = "blue", font = "Arial")
lab18.configure(fg = "#AC6D0F", bg = "blue", font = "Arial")
lab19.configure(fg = "#AC6D0F", bg = "blue", font = "Arial")
lab20.configure(fg = "#AC6D0F", bg = "blue", font = "Arial")
lab21.configure(fg = "#AC6D0F", bg = "blue", font = "Arial")
lab22.configure(fg = "#AC6D0F", bg = "blue", font = "Arial")
lab23.configure(fg = "#AC6D0F", bg = "blue", font = "Arial")
lab24.configure(fg = "#AC6D0F", bg = "blue", font = "Arial")
lab24_a.configure(fg = "#AC6D0F", bg = "blue", font = "Arial")
lab25.configure(fg = "#AC6D0F", bg = "blue", font = "Arial")
lab26.configure(fg = "#AC6D0F", bg = "blue", font = "Arial")
lab27.configure(fg = "#AC6D0F", bg = "blue", font = "Arial")
lab28.configure(fg = "#AC6D0F", bg = "blue", font = "Arial")

#intt = IntVar()
self.intt .set(0)

self.entry15 = Entry(self.frame2, textvariable = self.var7, bd = 0)


self.entry16 = Entry(self.frame2, textvariable = self.var8, bd = 0)
self.entry17 = Entry(self.frame2, textvariable = self.var9, bd = 0)
self.entry18 = Entry(self.frame2, textvariable = self.var10, bd = 0)
self.entry19 = Entry(self.frame2, textvariable = self.var11, bd = 0)
self.entry20 = Entry(self.frame2, textvariable = self.var12, bd = 0)
self.entry21 = Entry(self.frame2, textvariable = self.var13, bd = 0)
self.entry22 = Entry(self.frame2, textvariable = self.var14, bd = 0)
self.entry23 = Entry(self.frame2, textvariable = self.var15, bd = 0)
self.entry24 = Entry(self.frame2, textvariable = self.var16, bd = 0)
self.entry25 = Entry(self.frame2, textvariable = self.var17, bd = 0)
self.entry26 = Entry(self.frame2, textvariable = self.var18, bd = 0)
self.entry27 = Entry(self.frame2, textvariable = self.var19, bd = 0)
self.entry28 = Entry(self.frame2, textvariable = self.var20, bd = 0)

self.total_print = Label(self.frame2, text = 0, bd = 0)


self.total = Label(self.frame2, text = "TOTAL EXPENSES", bd = 0)
self.db = sql.connect(host = "localhost", user = "root", passwd = "18180612",
database = "salarymanagement")
self.cur = self.db.cursor()

user = self.name.get()
passwd = b64encode(bytes(self.password.get(), "utf-16")).decode()
self.cur.execute("select * from main where Name = '%s' and Password = '%s'" % (str(user),
str(passwd)))
rud = self.cur.fetchall()

if rud :

def if_login() :

rd = np.array(rud)

self.var1 = StringVar()
self.var2 = IntVar()
# self.var3 = StringVar()
self.var4 = StringVar()
self.var5 = IntVar()
self.var6 = IntVar()
self.var7 = IntVar()
self.var8 = IntVar()
self.var9 = IntVar()
self.var10 = IntVar()
self.var11 = IntVar()
self.var12 = IntVar()
self.var13 = IntVar()
self.var14 = IntVar()
self.var15 = IntVar()
self.var16 = IntVar()
self.var17 = IntVar()
self.var18 = IntVar()
self.var19 = IntVar()
self.var20 = IntVar()

self.var1.set(rd[0][0])
self.var2.set(rd[0][1])
# self.var3.set(rd[0][2])
self.var4.set(rd[0][3])
self.var5.set(rd[0][6])
self.var6.set(rd[0][7])
self.var7.set(rd[0][8])
self.var8.set(rd[0][9])
self.var9.set(rd[0][10])
self.var10.set(rd[0][11])
self.var11.set(rd[0][12])
self.var12.set(rd[0][13])
self.var13.set(rd[0][14])
self.var14.set(rd[0][15])
self.var15.set(rd[0][16])
self.var16.set(rd[0][17])
self.var17.set(rd[0][18])
self.var18.set(rd[0][19])
self.var19.set(rd[0][20])
self.var20.set(rd[0][21])

self.name.configure(textvariable = self.var1)
self.age.configure(textvariable = self.var2)
# self.optnbtn1.configure(textvariable = self.var3)
self.password.configure(textvariable = self.var4)
self.salary_1.configure(textvariable = self.var5)
self.extra_1.configure(textvariable = self.var6)
self.entry15.configure(textvariable = self.var7)
self.entry16.configure(textvariable = self.var8)
self.entry17.configure(textvariable = self.var9)
self.entry18.configure(textvariable = self.var10)
self.entry19.configure(textvariable = self.var11)
self.entry20.configure(textvariable = self.var12)
self.entry21.configure(textvariable = self.var13)
self.entry22.configure(textvariable = self.var14)
self.entry23.configure(textvariable = self.var15)
self.entry24.configure(textvariable = self.var16)
self.entry25.configure(textvariable = self.var17)
self.entry26.configure(textvariable = self.var18)
self.entry27.configure(textvariable = self.var19)
self.entry28.configure(textvariable = self.var20)

if_login()
self.db.commit()

def click() :

self.lst_total = [
int(self.entry15.get()),
int(self.entry16.get()),
int(self.entry17.get()),
int(self.entry18.get()),
int(self.entry19.get()),
int(self.entry20.get()),
int(self.entry21.get()),
int(self.entry22.get()),
int(self.entry23.get()),
int(self.entry24.get()),
int(self.entry25.get()),
int(self.entry26.get()),
int(self.entry27.get()),
int(self.entry28.get())
]

self.summ = 0
for i in range(0, len(self.lst_total)):
self.summ = self.summ + self.lst_total[i]

inc_1 = int(self.salary_1.get()) + int(self.extra_1.get())

if self.summ > inc_1 :

error = Frame(self.frame2, bd = 0, bg = "red", width = 800, height = 100)


error.place(x = 250, y = 245)
error_lab = Label(error, text = "YOUR INCOME IS LESS TO FULFILL YOUR EXPENSE")
error_lab.configure(bd = 0, fg = "black", bg = "red")
error_lab.pack()
self.total_print.configure(text = self.summ)

coountdown(6, error)

def error_ok() :

error.place_forget()
#sleep(5)
error_btn = Button(error, text = "Ok", command = error_ok, bd = 0)
error_btn.pack()

else :

database()
self.total_print.configure(text = self.summ)

stat()

click_btn = Button(self.frame2, text = "Enter", command = click, bd = 0)


click_btn.configure()

lab15.place(x = 50, y = 100)


lab16.place(x = 50, y = 150)
lab17.place(x = 50, y = 200)
lab18.place(x = 50, y = 250)
lab19.place(x = 50, y = 300)
lab20.place(x = 50, y = 350)
lab21.place(x = 50, y = 400)
lab22.place(x = 450, y = 100)
lab23.place(x = 450, y = 150)
lab24.place(x = 450, y = 200)
lab24_a.place(x = 450, y = 220)
lab25.place(x = 450, y = 250)
lab26.place(x = 450, y = 300)
lab27.place(x = 450, y = 350)
lab28.place(x = 450, y = 400)
self.total.place(x = 280, y = 445)
self.total_print.place(x = 480, y = 440)
click_btn.place(x = 380, y = 475)

self.entry15.place(x = 200, y = 100)


self.entry16.place(x = 200, y = 150)
self.entry17.place(x = 200, y = 200)
self.entry18.place(x = 200, y = 250)
self.entry19.place(x = 200, y = 300)
self.entry20.place(x = 200, y = 350)
self.entry21.place(x = 200, y = 400)
self.entry22.place(x = 600, y = 100)
self.entry23.place(x = 600, y = 150)
self.entry24.place(x = 600, y = 200)
self.entry25.place(x = 600, y = 250)
self.entry26.place(x = 600, y = 300)
self.entry27.place(x = 600, y = 350)
self.entry28.place(x = 600, y = 400)

else :

fabu = Label(self.win, text = "Please enter your Name and Password")


fabu.configure(bg = "#15350204f", fg = "black")
fabu.place(x = 300, y = 345)
coountdown(5, fabu)

def stat() :
self.frame2.place_forget()
self.statt = Frame(self.win, bg = "pink", width = 800, height = 500)
self.statt.place (x = 0, y = 0)

ab = Label(self.statt, text = "STATISTICAL INTERPETATION")


ab.place(x = 340, y = 35)

self.line_graph = Button(self.statt, text = "LINE GRAPH", command = line_graphical)


self.bar_graph = Button(self.statt, text = "BAR GRAPH", command = bar_graphical)
self.pie_graph = Button(self.statt, text = "PIE CHART", command = pie_graphical)

self.line_graph.configure(bd = 0, width = 15, height = 6, bg = "dark green", activebackground =


"#15350204f", font = "arialroundedmtbold", relief = SUNKEN)
self.bar_graph.configure(bd = 0, width = 15, height = 6, bg = "dark green", activebackground =
"#15350204f", font = "arialroundedmtbold", relief = SUNKEN)
self.pie_graph.configure(bd = 0, width = 15, height = 6, bg = "dark green", activebackground =
"#15350204f", font = "arialroundedmtbold", relief = SUNKEN)

self.line_graph.place(x = 166, y = 160)


self.bar_graph.place(x = 482, y = 160)
self.pie_graph.place(x = 320, y = 330)

self.acc = Button(self.statt, text = "12", command = account, bd = 0)


self.acc.place(x = 0, y = 240)

def line_graphical() :
self.statt.place_forget()

self.graph_frame = Frame(self.win, bg = "green", width = 800, height = 500)


self.graph_frame.place(x = 0, y = 0)

fig = Figure(figsize = (8, 5), dpi = 100)


fig.suptitle("Money Spent")

b = []
a=[
"HOUSE RENT",
"ELECTRIC BILLS",
"FOOD",
"COOKING EMENITIES",
"HEALTH",
"EDUCATION",
"WATER SUPPLY",
"SHOPPING",
"TRAVELLING",
"INTERNET & COMMUNICATION",
"SAVINGS",
"LOAN REPAYMENT",
"EXTRA",
"DONATIONS"
]

for i in self.lst_total :
b.append(i)

graph = fig.add_subplot(122)
graph.plot(b, a, marker = "o")
graph.grid()

canv = FigureCanvasTkAgg(fig, master = self.graph_frame)


canv.draw()

get_widz = canv.get_tk_widget()
get_widz.pack()

self.back = Button(self.graph_frame, text = "BACK", command = stat)


self.back.configure(bd = 0, bg = "black", fg = "white", activebackground = "#15350204f",
font = "arialroundedmtbold", relief = SUNKEN)
self.back.place(x = 0, y = 0)

def bar_graphical() :
self.statt.place_forget()

self.br_grph = Frame(self.win, bg = "green", width = 800, height = 500)


self.br_grph.place(x = 0, y = 0)

fig = Figure(figsize = (8, 5), dpi = 100)


fig.suptitle("Money Spent")

b = []
a=[
"HOUSE RENT",
"ELECTRIC BILLS",
"FOOD",
"COOKING EMENITIES",
"HEALTH",
"EDUCATION",
"WATER SUPPLY",
"SHOPPING",
"TRAVELLING",
"INTERNET & COMMUNICATION",
"SAVINGS",
"LOAN REPAYMENT",
"EXTRA",
"DONATIONS"
]

for i in self.lst_total:
b.append(i)

graph = fig.add_subplot(122)
graph.barh(a, b)
graph.grid()

canv = FigureCanvasTkAgg(fig, master = self.br_grph)


canv.draw()

get_widz = canv.get_tk_widget()
get_widz.pack()

self.back = Button(self.br_grph, text = "BACK", command = stat)


self.back.configure(bd = 0, bg = "black", fg = "white", activebackground = "#15350204f",
font = "arialroundedmtbold", relief = SUNKEN)
self.back.place(x = 0, y = 0)

def pie_graphical() :
self.statt.place_forget()
self.pie_grph = Frame(self.win, bg = "green", width = 800, height = 500)
self.pie_grph.place(x = 0, y = 0)

fig = Figure(figsize = (8, 5), dpi = 100)


fig.suptitle("Money Spent")

b = []
a=[
"HOUSE RENT",
"ELECTRIC BILLS",
"FOOD",
"COOKING EMENITIES",
"HEALTH",
"EDUCATION",
"WATER SUPPLY",
"SHOPPING",
"TRAVELLING",
"INTERNET & COMMUNICATION",
"SAVINGS",
"LOAN REPAYMENT",
"EXTRA",
"DONATIONS"
]

for i in self.lst_total :
b.append(i)

graph = fig.add_subplot(111)
graph.pie(b, labels = a)

canv = FigureCanvasTkAgg(fig, master = self.pie_grph)


canv.draw()

get_widz = canv.get_tk_widget()
get_widz.pack()

self.back = Button(self.pie_grph, text = "BACK", command = stat)


self.back.configure(bd = 0, bg = "black", fg = "white", activebackground = "#15350204f",
font = "arialroundedmtbold", relief = SUNKEN)
self.back.place(x = 0, y = 0)

def database() :
user = self.name.get()
passwd = b64encode(bytes(self.password.get(), "utf-16")).decode()

self.cur.execute("select * from main where Name = '%s' and Password = '%s'" % (str(user),
str(passwd)))
rud = self.cur.fetchall()

def inserting() :

self.cur = self.db.cursor()
self.cur.execute("insert into main values"
"("
"'{}', {}, '{}', '{}', '{}', '{}', {}, {}, {}, {}, {},"
" {}, {}, {}, {}, {}, {}, {},{}, {}, {}, {})"
.format
(
str(self.name.get()),
self.age.get(),
str(self.optnbtn1),
b64encode(bytes(self.password.get(), "utf-16")).decode(),
str(self.flag),
str(self.cart),
int(self.salary_1.get()),
int(self.extra_1.get()),
self.entry15.get(),
self.entry16.get(),
self.entry17.get(),
self.entry18.get(),
self.entry19.get(),
self.entry20.get(),
self.entry21.get(),
self.entry22.get(),
self.entry23.get(),
self.entry24.get(),
self.entry25.get(),
self.entry26.get(),
self.entry27.get(),
self.entry28.get()
))

if rud :

print("Welcome")
inserting()
self.db.commit()

else :

inserting()
self.db.commit()
print("Account Created")

self.cur.close()
self.db.close()

def add_income_again() :
self.db = sql.connect(host = "localhost", user = "root", passwd = "18180612", database =
"salarymanagement")
self.cur = self.db.cursor()

user = self.name.get()
passwd = b64encode(bytes(self.password.get(), "utf-16")).decode()

self.cur.execute("select Job from main where Name = '%s' and Password = '%s'" % (str(user),
str(passwd)))
rud = self.cur.fetchall()

try :

if rud[-1][0] == "servi" :

service()

elif rud[-1][0] == "busin" :


business()

except IndexError :

if self.flag == "servi" :

service()

elif self.flag == "busin" :

business()

def account_setting() :
self.frame.pack_forget()

# intt = IntVar()
varm = IntVar()
st = StringVar()
st1 = StringVar()
self.intt.set(self.age.get())
st.set(self.name.get())
st1.set(self.password.get())
self.constant = True

self.frame1 = Frame(self.win, bg = "lightpink", width = 250, height = 500)


self.frame1.place(x = 0, y = 0)

name_entry = Entry(self.frame1, textvariable = st)


age_entry = Entry(self.frame1, textvariable = self.intt)
password_entry = Entry(self.frame1, textvariable = st1, show = "*")
name_entry.configure(bd = 1, width = 17)
age_entry.configure(bd = 1, width = 17)

def mark_2() :

if varm.get() == 1 :

password_entry.configure(show = "")
check.configure(text = "Hide")

elif varm.get() == 0 :

password_entry.configure(show = "*")
check.configure(text = "Show")

def update_account() :
self.name = name_entry
self.age = age_entry
self.password = password_entry

btn_name = Button(self.frame1, text = "Change Name", command = update_account)


btn_age = Button(self.frame1, text = "Change Age", command = update_account)
btn_password = Button(self.frame1, text = "Change Password", command = update_account)

check = Checkbutton(self.frame1, text = "Show", command = mark_2, font = "Arial", bd = 0)


check.configure(onvalue = 1, offvalue = 0, variable = varm, bg = "lightpink", fg = "white",
activebackground = "pink")
name_entry.place(x = 10, y = 150)
age_entry.place(x = 10, y = 230)
password_entry.place(x = 10, y = 310)

btn_name.place(x = 140, y = 150)


btn_age.place(x = 140, y = 230)
btn_password.place(x = 140, y = 310)
check.place(x = 10, y = 350)

def account() :
# self.acc.place_forget()
self.acc.configure(text = "21", command = account_update)
self.acc.place_configure(x = 250, y = 240)
# self.goback = Button(self.win, text = "21", command = account_update)
# self.goback.place(x = 250, y = 240)
self.frame = Frame(self.win, bg = "red", width = 250, height = 500)
self.frame.pack(side = LEFT)

lab11 = Label(self.frame, text = "Hello", font = "agencyfb", bd = 0)


lab11.configure(bg = "red", fg = "white")
lab12 = Label(self.frame, text = self.name.get(), font = "agencyfb", bd = 0)
lab13 = Label(self.frame, text = "-"*50, bd = 0)
lab13.configure(font = "agencyfb", bg = "red", fg = "white")
lab12.configure(bg = "red", fg = "blue")

lab11.place(x = 100, y = 40)


lab12.place(x = 75, y = 65)
lab13.place(x = 0, y = 90)

def like() :
creator_info = Frame(self.win, width = 600, height = 380)
creator_info.place(x = 100, y = 60)

messg_widget = Message(creator_info, text = self.messg, bg = "pink", fg = "black")


messg_widget.place(x = 100, y = 100)

def destrot() :
creator_info.destroy()

quite = Button(creator_info, text = "Out", command = destrot, bd = 0, fg = "red")


quite.place(x = 570, y = 0)

accsettings = Button(self.frame, text = "Account Settings", command = account_setting, font =


"agencyfb")
addincome = Button(self.frame, text = "Add Income", font = "agencyfb", command =
add_income_again)
about = Button(self.frame, text = "ABOUT", font = "agencyfb", command = like)
quit = Button(self.frame, text = "Quit",font = "agencyfb", command = self.win.quit)
accsettings.configure(bg = "red", fg = "white", bd = 0)
addincome.configure(bg = "red", fg = "white", bd = 0)
about.configure(bd = 0, bg = "red", fg = "white")
quit.configure(bg = "red", fg = "white", bd = 0)

accsettings.place(x = 70, y = 160)


addincome.place(x = 70, y = 245)
about.place(x = 70, y = 330)
quit.place(x = 70, y = 415)
def account_update() :
self.frame.pack_forget()

if self.constant == True :

self.frame1.place_forget()
self.acc.configure(text = "12", command = account)
self.acc.place_configure(x = 0, y = 240)
# self.frame.pack_forget()

# self.frame.place_forget()
# self.goback.place_forget()
self.acc.configure(text = "12", command = account)
self.acc.place_configure(x = 0, y = 240)

def day1() :

self.cart = "Day"
service()

def week1() :

self.cart = "Week"
service()

def month1() :

self.cart = "Month"
service()

def day2():

self.cart = "Day"
business()

def week2() :

self.cart = "Week"
business()

def month2() :

self.cart = "Month"
business()

def interval_service() :
self.lab4.place_forget()
self.service.place_forget()
self.business.place_forget()

self.day_1 = Button(self.win, text = "per Day", command = day1)


self.week_1 = Button(self.win, text = "per Week", command = week1)
self.month_1 = Button(self.win, text = "per Month", command = month1)

self.day_1.configure(bg = "lightpink", bd = 0, width = 15, height = 6)


self.week_1.configure(bg = "lightpink", bd = 0, width = 15, height = 6)
self.month_1.configure(bg = "lightpink", bd = 0, width = 15, height = 6)
self.day_1.place(x = 350, y = 80)
self.week_1.place(x = 350, y = 220)
self.month_1.place(x = 350, y = 360)

self.acc = Button(self.win, text = "12", command = account, bd = 0)


self.acc.place(x = 0, y = 240)

def interval_business() :
self.lab4.place_forget()
self.service.place_forget()
self.business.place_forget()

self.day_2 = Button(self.win, text = "per Day", command = day2)


self.week_2 = Button(self.win, text = "per Week", command = week2)
self.month_2 = Button(self.win, text = "per Year", command = month2)

self.day_2.configure(bg = "lightpink", bd = 0, width = 15, height = 6)


self.week_2.configure(bg = "lightpink", bd = 0, width = 15, height = 6)
self.month_2.configure(bg = "lightpink", bd = 0, width = 15, height = 6)

self.day_2.place(x = 350, y = 80)


self.week_2.place(x = 350, y = 220)
self.month_2.place(x = 350, y =360)

self.acc = Button(self.win, text = "12", command = account, bd = 0)


self.acc.place(x = 0, y = 240)

def afterenter() :
if self.name.get() != "" and self.password.get() != "" :

self.home_frame.place_forget()
self.win.configure(bg = "dimgrey")

self.lab4 = Label(self.win, text = "/", fg = "red", bg ="dimgrey")


self.lab4.place(x = 400, y = 210)

self.service = Button(self.win, text = "SERVICE", command = interval_service, bd = 0)


self.business = Button(self.win, text = "BUSINESS", command = interval_business, bd = 0)

self.service.configure(fg = "black", bg = "red", height = 3, width =13)


self.service.configure(activebackground = "blue", activeforeground = "white")
self.business.configure(fg = "black", bg = "red", height = 3, width =13)
self.business.configure(activebackground = "blue", activeforeground = "white")

self.service.place(x = 290, y =200)


self.business.place(x = 430, y = 200)

else :

fabu = Label(self.win, text = "Please enter your Name or Password")


fabu.configure(bg = "#17616E", fg = "#A09995")
fabu.place(x = 300, y = 360)
coountdown(4, fabu)

enter = Button(self.home_frame, text = "Enter", command = afterenter, bg = "#9DC3CA")


enter.configure(fg = "white", bd = 0, height = 2, activebackground = "#2A7888", width = 15,
relief = SUNKEN)
enter.configure(activeforeground = "black", highlightcolor = "pink", font =
"arialroundedmtbold")
enter.place(x = 340, y = 310)

if __name__ == "__main__" :
window = Tk()
startpage(window)

window.mainloop()

You might also like