PROGRAM
PROGRAM
''' 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. '''
[Link] = win
[Link]("800x500+300+150")
[Link]("Salary Manager")
# [Link](bg = "#15350204f")
st = StringVar()
[Link] = IntVar()
def main_table() :
''' The function main_table() is used for creating the table and the database in MySql. Here I have
use
Exceptional Handling for checking that the database is already created or not. Using different
exceptions, I have created a database named salarymanagement and table name main in MySql
server. Using
the module [Link], I have inserted columns in the table. '''
try :
except [Link] :
try :
main_table()
except [Link] :
pass
finally :
try :
main_table()
except [Link] :
pass
''' This function coountdown() is used for time interval. I have used this function several time for
vanishing different frames. '''
if time == -1 :
[Link]()
else :
[Link](500, coountdown, time-1, fab)
basewidth = 300
img = [Link]('[Link]')
# wpercent = (basewidth/float([Link][0]))
# hsize = int((float([Link][1])*float(wpercent)))
im = [Link]((90,90), [Link])
imgii = [Link](im)
imi = [Link]((150, 130), [Link])
imgia = [Link](imi)
varm = IntVar()
st = StringVar()
st1 = StringVar()
[Link] = 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 [Link]() == 1 :
[Link](show = "")
[Link](text = "Hide")
elif [Link]() == 0 :
[Link](show = "*")
[Link](text = "Show")
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. '''
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()
# [Link] = ""
# [Link] = ""
[Link] = False
#[Link]('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. '''
options = [
" None ",
" Male ",
" Female ",
" Others "
]
st = StringVar()
[Link](options[0])
[Link] = OptionMenu(self.home_frame, st, options[0], options[1], options[2], options[3])
[Link](bd = 0, height = 1, width = 12, font = "Arial", bg = "#FDFEFE", fg =
"#F02D94",
activebackground = "#B6C1C3")
[Link](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.var5 = IntVar()
self.var6 = IntVar()
[Link](0)
[Link](0)
[Link] = "servi"
# self.day_1.place_forget()
# self.week_1.place_forget()
# self.month_1.place_forget()
''' Here I have just extract the username and password from MySql server to check weather this
account is
already registered or not. If registered, then it will extract the values of Earnings and Extra from
MySql
server and placed it in the entry field as it was saved earlier by the owner of that account. It
means
it will be recovered every time when it is logged in. '''
user = str([Link]())
passwd = b64encode(bytes([Link](), "utf-16")).decode()
[Link]("select * from main where Name = '%s' and Password = '%s'" % (str(user),
str(passwd)))
rud = [Link]()
if rud :
[Link]("select Salary, Extra_Income from main where Name = '%s'and Job = 'servi'" %
(user))
nod = [Link]()
if nod :
rd = [Link](nod)
[Link](rd[0])
[Link](rd[1])
self.salary_1.configure(textvariable = self.var5)
self.extra_1.configure(textvariable = self.var6)
def business() :
''' This function business() is designed to store the Earnings of a person in a regular basis in the
business sector. I have specified different entry box using the Entry widget to store the data of
their
income in our MySql server. '''
self.var5 = IntVar()
self.var6 = IntVar()
[Link](0)
[Link](0)
[Link] = "busin"
# self.day_2.place_forget()
# self.week_2.place_forget()
# self.month_2.place_forget()
''' Here I have just extract the username and password from MySql server to check weather this
account is
already registered or not. If registered, then it will extract the values of Earnings and Extra from
MySql
server and placed it in the entry field as it was saved earlier by the owner of that account. It
means
it will be recovered every time when it is logged in. '''
user = str([Link]())
passwd = b64encode(bytes([Link](), "utf-16")).decode()
[Link]("select * from main where Name = '%s' and Password = '%s'" % (str(user),
str(passwd)))
rud = [Link]()
if rud:
[Link]("select Salary, Extra_Income from main where Name = '%s'and Job = 'busin'" %
(user))
nod = [Link]()
if nod :
rd = [Link](nod)
[Link](rd[0])
[Link](rd[1])
self.salary_1.configure(textvariable = self.var5)
self.extra_1.configure(textvariable = self.var6)
''' This function expenses() creates a frame that consists of different expenses of life. Here are
different entry box with different labels for users convenient. I have specified different entry box
using
the Entry widget to store the data of their expenses in our MySql server. '''
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()
[Link](0)
[Link](0)
[Link](0)
[Link](0)
[Link](0)
[Link](0)
[Link](0)
[Link](0)
[Link](0)
[Link](0)
[Link](0)
[Link](0)
[Link](0)
[Link](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)
#intt = IntVar()
[Link] .set(0)
''' Here again I have checked for account verification so that the data can be replaced with the
existing data stored in the MySql database for any similar username and password. So that it
will be
easy for user to update their existing data in the frame. '''
user = [Link]()
passwd = b64encode(bytes([Link](), "utf-16")).decode()
[Link]("select * from main where Name = '%s' and Password = '%s'" % (str(user),
str(passwd)))
rud = [Link]()
if rud :
def if_login() :
''' In this function if_login() we have extracted all the values of daily expenses
from database as stored by the user. I have also used a if structure before calling of this
function, that will help if the given username and password matched with the data stored
earlier in the database, otherwise it will create a new row for the new user. '''
rd = [Link](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()
[Link](rd[0][0])
[Link](rd[0][1])
# [Link](rd[0][2])
[Link](rd[0][3])
[Link](rd[0][6])
[Link](rd[0][7])
[Link](rd[0][8])
[Link](rd[0][9])
[Link](rd[0][10])
[Link](rd[0][11])
[Link](rd[0][12])
[Link](rd[0][13])
[Link](rd[0][14])
[Link](rd[0][15])
[Link](rd[0][16])
[Link](rd[0][17])
[Link](rd[0][18])
[Link](rd[0][19])
[Link](rd[0][20])
[Link](rd[0][21])
[Link](textvariable = self.var1)
[Link](textvariable = self.var2)
# [Link](textvariable = self.var3)
[Link](textvariable = self.var4)
self.salary_1.configure(textvariable = self.var5)
self.extra_1.configure(textvariable = self.var6)
[Link](textvariable = self.var7)
[Link](textvariable = self.var8)
[Link](textvariable = self.var9)
[Link](textvariable = self.var10)
[Link](textvariable = self.var11)
[Link](textvariable = self.var12)
[Link](textvariable = self.var13)
[Link](textvariable = self.var14)
[Link](textvariable = self.var15)
[Link](textvariable = self.var16)
[Link](textvariable = self.var17)
[Link](textvariable = self.var18)
[Link](textvariable = self.var19)
[Link](textvariable = self.var20)
if_login()
[Link]()
def click() :
''' This function click() mainly used for collecting all the data from the entry boxes of
expenses an to check weather the total expenses is less that the total income including extra
income. If it is more that the income then it will show a error message, so that user can
understand the problem so that it can be changed into correct form. '''
self.lst_total = [
int([Link]()),
int([Link]()),
int([Link]()),
int([Link]()),
int([Link]()),
int([Link]()),
int([Link]()),
int([Link]()),
int([Link]()),
int([Link]()),
int([Link]()),
int([Link]()),
int([Link]()),
int([Link]())
]
[Link] = 0
for i in range(0, len(self.lst_total)):
[Link] = [Link] + self.lst_total[i]
coountdown(6, error)
def error_ok() :
''' The function error_ok() is used delete a error frame created due to a debug in the
program to make this simple and understandable. '''
error.place_forget()
#sleep(5)
else :
database()
self.total_print.configure(text = [Link])
stat()
else :
def stat() :
''' This function stat() will create a frame with three buttons for three types of graph. This was
made
so that user can get graphical or tabular view of his/her daily expenses. '''
self.frame2.place_forget()
[Link] = Frame([Link], bg = "pink", width = 800, height = 500)
[Link] (x = 0, y = 0)
def line_graphical() :
''' The function line_graphical() is directed from the statt frame. Here using matplotlib and pyplot,
I have plotted the data in format of line graph. For this I have used canvas and figure function
from
tkinter and matplotlib respectively. At first I have created a figure and then the data was plotted
inside the line graph. After that the image was placed inside the canvas and then on main frame
of the
window. '''
[Link].place_forget()
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 :
[Link](i)
graph = fig.add_subplot(122)
[Link](b, a, marker = "o")
[Link]()
get_widz = canv.get_tk_widget()
get_widz.pack()
''' The function bar_graphical() is directed from the statt frame. Here using matplotlib and pyplot,
I have plotted the data in format of bar graph. For this I have used canvas and figure function
from
tkinter and matplotlib respectively. At first I have created a figure and then the data was plotted
inside the line graph. After that the image was placed inside the canvas and then on main frame
of the
window. In the same way like the line graph. '''
[Link].place_forget()
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:
[Link](i)
graph = fig.add_subplot(122)
[Link](a, b)
[Link]()
get_widz = canv.get_tk_widget()
get_widz.pack()
[Link] = Button(self.br_grph, text = "BACK", command = stat)
[Link](bd = 0, bg = "black", fg = "white", activebackground = "#15350204f",
font = "arialroundedmtbold", relief = SUNKEN)
[Link](x = 0, y = 0)
def pie_graphical() :
''' The function pie_graphical() is directed from the statt frame. Here using matplotlib and pyplot,
I have plotted the data in format of pie graph. For this I have used canvas and figure function from
tkinter and matplotlib respectively. At first I have created a figure and then the data was plotted
inside the line graph. After that the image was placed inside the canvas and then on main frame
of the
window. In the same way like the line graph & and bar graph. '''
[Link].place_forget()
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 :
[Link](i)
graph = fig.add_subplot(111)
[Link](b, labels = a)
get_widz = canv.get_tk_widget()
get_widz.pack()
def database() :
''' This function database() once again checks for account verification so that the expenses can be
stored in the MySql database. If the condition satisfied the it will restore the old data of thar user
otherwise it will insert the new data of that new user. This thing will make the whole program
more
user-friendly, so there will be no need to remember the old data by user. '''
user = [Link]()
passwd = b64encode(bytes([Link](), "utf-16")).decode()
[Link]("select * from main where Name = '%s' and Password = '%s'" % (str(user),
str(passwd)))
rud = [Link]()
def inserting() :
''' The function inserting() is fully based on the module [Link], because this function
working on the department of inserting all the data of user starting from Name or username to
daily
expenses and total amount that have spent by user. Here I have extracted the all the data from
the
entry boxes using the syntax <entry>.get() function and put it into different columns of the
table
main main in MySql database. '''
[Link] = [Link]()
[Link]("insert into main values"
"("
"'{}', {}, '{}', '{}', '{}', '{}', {}, {}, {}, {}, {},"
" {}, {}, {}, {}, {}, {}, {},{}, {}, {}, {})"
.format
(
str([Link]()),
[Link](),
str(self.optnbtn1),
b64encode(bytes([Link](), "utf-16")).decode(),
str([Link]),
str([Link]),
int(self.salary_1.get()),
int(self.extra_1.get()),
[Link](),
[Link](),
[Link](),
[Link](),
[Link](),
[Link](),
[Link](),
[Link](),
[Link](),
[Link](),
[Link](),
[Link](),
[Link](),
[Link]()
))
if rud :
print("Welcome")
inserting()
[Link]()
else :
inserting()
[Link]()
print("Account Created")
[Link]()
[Link]()
def add_income_again() :
''' The function add_income_again() is called inside the settings tab Add Income. The function will
redirect the user the service or business income page. Whenever user will press that button,
the frame will be replaced by that frame. '''
user = [Link]()
passwd = b64encode(bytes([Link](), "utf-16")).decode()
[Link]("select Job from main where Name = '%s' and Password = '%s'" % (str(user),
str(passwd)))
rud = [Link]()
try :
if rud[-1][0] == "servi" :
service()
business()
except IndexError :
if [Link] == "servi" :
service()
business()
def account_setting() :
''' This function account_setting() is a part of settings where user can change their name as well
their
age too. Here one frame will be slided from left side of the window for settings options. The
frame was
a rectangle of dimension 250 x 500. '''
[Link].pack_forget()
# intt = IntVar()
varm = IntVar()
st = StringVar()
st1 = StringVar()
[Link]([Link]())
[Link]([Link]())
[Link]([Link]())
[Link] = True
def mark_2() :
''' The function mark_2() is same as the mark() at top level, 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 [Link]() == 1 :
password_entry.configure(show = "")
[Link](text = "Hide")
elif [Link]() == 0 :
password_entry.configure(show = "*")
[Link](text = "Show")
def update_account() :
''' The function update_account() will change their name to the new name given by that user.
Here I
am just shifting the values name & age that we are getting from login page to the new name
and age
in the settings section. '''
[Link] = name_entry
[Link] = age_entry
[Link] = password_entry
def account() :
''' The function account() is used to create a frame with several options like about, updating
name & age, quit etc. for users benefits. This will also show your name at the top of the frame.
The
main work of this function is for account settings. '''
# [Link].place_forget()
[Link](text = "21", command = account_update)
[Link].place_configure(x = 250, y = 240)
# [Link] = Button([Link], text = "21", command = account_update)
# [Link](x = 250, y = 240)
[Link] = Frame([Link], bg = "red", width = 250, height = 500)
[Link](side = LEFT)
def like() :
''' The function like() is used for showing the about section of the program. The work of the
function is to place the about frame. '''
def destrot() :
''' The function destrot() was used to destroy the about frame. Simply it is used as a cross
button which exit a window. '''
creator_info.destroy()
def account_update() :
''' The function account_update() was just used for the sliding part of the account setting frame.
This
was responsible for the placing and vanishing part of the frame '''
[Link].pack_forget()
if [Link] == True :
self.frame1.place_forget()
[Link](text = "12", command = account)
[Link].place_configure(x = 0, y = 240)
# [Link].pack_forget()
# [Link].place_forget()
# [Link].place_forget()
[Link](text = "12", command = account)
[Link].place_configure(x = 0, y = 240)
''' Here all the function day1(), week1() etc. is responsible for storing the date of the period of
interval
choose by the user. For different conditions it will store different strings in the MySql database. '''
def day1() :
[Link] = "Day"
service()
def week1() :
[Link] = "Week"
service()
def month1() :
[Link] = "Month"
service()
def day2():
[Link] = "Day"
business()
def week2() :
[Link] = "Week"
business()
def month2() :
[Link] = "Month"
business()
def interval_service() :
''' This function interval_service() will create a frame with time of intervals for service sections.
Every buttons will redirect you to different function specified for this. This is build so that user
can store their income as per their options. '''
self.lab4.place_forget()
[Link].place_forget()
[Link].place_forget()
''' This function interval_business() will create a frame with time of intervals for business sections.
Every buttons will redirect you to different function specified for this. This is build so that user
can store their income as per their options. '''
self.lab4.place_forget()
[Link].place_forget()
[Link].place_forget()
def afterenter() :
''' The function afterenter() is called after the enter button clicked in login page. This function will
redirect you from login page to the job frame which will allow to select your job type. I have also
specified a condition that if the entry box of name or username and password is blank then it will
stop
you from entering the job frame.'''
self.home_frame.place_forget()
[Link](bg = "dimgrey")
else :
if __name__ == "__main__" :
''' This thing is just checking that we are outside the class or function, if yes then it will call the
respected class startpage() with the parameter window as tkinter window as scripted below. '''
window = Tk()
startpage(window)
[Link]()
@@@@@@@@@@@@