In this Python tutorial, I will show you how to create a payslip generator using both the Python console and a user-friendly GUI built with Tkinter. You will learn how to design the interface, collect employee details, calculate salary components, and display or save the final payslip.
By the end of this blog, you’ll have a complete understanding of the logic, layout, and working source code needed to build your Python-based payslip generator using Tkinter.
Business Requirement
Using this information, the application generates an output wherein employee information and deductions are displayed on the Python console.
Though the requirement of the application was console-based, we have created it using both console and GUI-based. For the graphical user interface (GUI), we have used the Python library.
Below is the image of the requirement that we received:

Read Create a Progress Bar in Python Tkinter
Payslip Application using Python Console
Payslip application accepts employee details like name, working hours, rate per hour, sss contribution, Phil health, and housing loan.
Source Code:
By adding the data type name before the input() method, we can convert the user input into the data type of preference. Like in the code below, we converted user inputs to the float data type. Number of days of duty, server times rate per hour, will produce the gross salary of an employee.
# User inputs
emp_name = input('Employee Name: ')
rph = float(input('Rate per hour: '))
duty = float(input('Duty (No. of hours): '))
s3_contrib = float(input('SSS Contribution: '))
phealth = float(input('PhilHealth: '))
hloan = float(input('Housing loan: '))
print('')
print('-'*3+'EMPLOYEE INFORMATION'+'-'*3)
print('')
# Net salary calculation
gross_sal = rph * duty
tax = gross_sal * 0.1
total_deduction = s3_contrib + phealth + hloan + tax
net_sal = gross_sal - total_deduction
# display information using formatted string
print(f'''
Name: {emp_name}
Rendered Hours: {duty}
Rate per hour: {rph}
Gross Salary: {gross_sal}
''')
print('')
print('-'*5+'DEDUCTIONS'+'-'*5)
print('')
print(f'''
SSS: {s3_contrib}
PhilHealth: {phealth}
Other Loan: {hloan}
Tax: {tax}
Total Deductions: {total_deduction}
Net Salary: {net_sal}
''')Output:
In the below output, the user has provided the first 6 inputs rest of everything is generated by the application.

Check out Master the Python Tkinter Canvas
Simple payslip application using Python tkinter
In this section, we have created a GUI-based application that accepts user inputs through entry widgets and displays results in an interactive window. The program is written in Python using the Tkinter module.
The code is divided into two parts. In the first part, we have created an interactive form using Python Tkinter. Fill in the interactive form and click on the calculate button to generate a payslip. The other part displays the output in a new window.
Read Set and Manage Window Size in Python Tkinter
Source Code:
In the below code, the Tkinter module is imported, and the calsal module.
Save this code with the name main.py, where ws is the instance created for the tkinter object in Python.
gross_sal = r * d
tax = gross_sal * 0.1
total_deduction = contri + ph + hl + tax
net_sal = gross_sal - total_deductioncalsal.payslip(ename, d, r, gross_sal, contri, ph, hl, tax, total_deduction, net_sal, ws, f)# modules
from tkinter import *
import calsal
# tkinter object
ws = Tk()
ws.title('PythonGuides - PaySlip Generator')
ws.geometry('400x300')
f = 'sans-serif, 12'
# functions
def clearbtn():
emp_name.delete(0, 'end')
rph.delete(0, 'end')
duty.delete(0, 'end')
s3_contrib.delete(0, 'end')
phealth.delete(0, 'end')
hloan.delete(0, 'end')
def main():
ename = emp_name.get()
r = rph.get()
d = duty.get()
contri = s3_contrib.get()
ph = phealth.get()
hl = hloan.get()
r = float(r)
d = float(d)
contri = float(contri)
ph = float(ph)
hl = float(hl)
gross_sal = r * d
tax = gross_sal * 0.1
total_deduction = contri + ph + hl + tax
net_sal = gross_sal - total_deduction
# calling function
calsal.payslip(ename, d, r, gross_sal, contri, ph, hl, tax, total_deduction, net_sal, ws, f)
Label(
ws,
text="EMPLOYEE PAYSLIP",
font=('sans-serif, 14'),
relief=SOLID,
padx=10,
pady=5
).pack()
# frame widget
mainframe = Frame(ws, padx=5, pady=5)
mainframe.pack(expand=True)
# label widget
Label(
mainframe,
text='Employee Name',
font=f
).grid(row=2, column=0, sticky='e')
Label(
mainframe,
text='Rate per hour',
font=f
).grid(row=3, column=0, sticky='e')
Label(
mainframe,
text='Duty (No. of hours)',
font=f
).grid(row=4, column=0, sticky='e')
Label(
mainframe,
text='SSS Contribution',
font=f
).grid(row=5, column=0, sticky='e')
Label(
mainframe,
text='PhilHealth',
font=f
).grid(row=6, column=0, sticky='e')
Label(
mainframe,
text='House loan',
font=f
).grid(row=7, column=0, sticky='e')
# Entry widgets
emp_name = Entry(mainframe, font=f)
rph = Entry(mainframe, font=f)
duty = Entry(mainframe, font=f)
s3_contrib = Entry(mainframe, font=f)
phealth = Entry(mainframe, font=f)
hloan = Entry(mainframe, font=f)
# geometry method - Grid
emp_name.grid(row=2, column=1, padx=5)
rph.grid(row=3, column=1, padx=5, sticky='w')
duty.grid(row=4, column=1, padx=5, sticky='w')
s3_contrib.grid(row=5, column=1, padx=5, sticky='w')
phealth.grid(row=6, column=1, padx=5, sticky='w')
hloan.grid(row=7, column=1, padx=5, sticky='w')
# default values in the entry widget
emp_name.insert('0', 'Noel B. Atazar')
rph.insert('0', 150)
duty.insert('0', 9)
s3_contrib.insert('0', 200)
phealth.insert('0', 150)
hloan.insert('0', 100)
# frame for buttons
frame = Frame(mainframe)
frame.grid(row=8, columnspan=3, pady=(30, 0))
# button widget
Button(
frame,
text='Calculate',
width=10,
command=main,
font=f,
bg='#91BF2C'
).pack(side=LEFT, expand=True, padx=(0, 5))
Button(
frame,
text='Clear',
width=5,
font=f,
bg='#E6D92A',
command=clearbtn
).pack(side=LEFT, expand=True, padx=(0, 5))
Button(
frame,
text='Exit',
width=5,
font=f,
bg='#FF614F',
command=lambda:ws.destroy()
).pack(side=LEFT, expand=True, padx=(0, 5))
# infinite loop
ws.mainloop()Output:

Source Code:
Save this file with the name calsal.py. The main.py file will use this module to display the output.
# module
from tkinter import *
# function
def payslip(ename, d, r, gross_sal, contri, ph, hl, tax, total_deduction, net_sal, ws, f):
cf = ('sans-serif 12 bold')
win = Toplevel(ws)
win.geometry('500x450+500+200')
Label(
win,
text='EMPLOYEES INFORMATION',
font='sans-serif 14',
relief=SOLID, padx=5,
pady=10
).place(x=110 , y=10)
Label(
win,
text='Name: ',
font=cf
).place(x=10, y=70)
Label(
win,
text=f'{ename}',
font=f
).place(x=65, y=70)
Label(
win,
text='Rendered Hours: ',
font=cf
).place(x=250, y=70)
Label(
win,
text=f'{d}',
font=f
).place(x=390, y=70)
Label(
win,
text='Rate per hour: ',
font=cf
).place(x=10, y=110)
Label(
win,
text=f'{r}',
font=f
).place(x=125, y=110)
Label(
win,
text='Gross Salary: ',
font=cf
).place(x=250, y=110)
Label(
win,
text=f'{gross_sal}',
font=f
).place(x=390, y=110)
Label(
win,
text='DEDUCTIONS',
font='sans-serif 14', relief=SOLID,
pady=5, padx=10
).place(x=170, y=180)
Label(
win,
text='SSS: ',
font=cf
).place(x=10, y=240)
Label(
win,
text=f'{contri}',
font=f
).place(x=65, y=240)
Label(
win,
text='PhilHealth: ',
font=cf
).place(x=250, y=240)
Label(
win,
text=f'{ph}',
font=f
).place(x=390, y=240)
Label(
win,
text='Other Loan:',
font=cf
).place(x=10, y=280)
Label(
win,
text=f'{hl}',
font=f
).place(x=105, y=280)
Label(
win,
text='Tax: ',
font=cf
).place(x=250, y=280)
Label(
win,
text=f'{tax}',
font=f
).place(x=390, y=280)
Label(
win,
text='Total Deductions: ',
font=cf
).place(x=10, y=320)
Label(
win,
text=f'{total_deduction}',
font=f
).place(x=150, y=320)
Label(
win,
text='Net Salary:',
font=cf
).place(x=250, y=320)
Label(
win,
text=f'{net_sal}',
font=f
).place(x=390, y=320)
Button(
win,
text='Close',
padx=10,
pady=5,
font=f,
bg='#FF614F',
command=lambda:win.destroy()
).place(x=220, y=390)Output:

In this tutorial, I explained how to create a payslip application using a console and how to generate a Payslip using Python Tkinter.
Related Python Tkinter tutorials:
- Use the Tkinter Treeview Widget in Python
- Take User Input and Store It in a Variable Using Python Tkinter
- Cancel Scheduled Functions with after_cancel() in Python Tkinter

I am Bijay Kumar, a Microsoft MVP in SharePoint. Apart from SharePoint, I started working on Python, Machine learning, and artificial intelligence for the last 5 years. During this time I got expertise in various Python libraries also like Tkinter, Pandas, NumPy, Turtle, Django, Matplotlib, Tensorflow, Scipy, Scikit-Learn, etc… for various clients in the United States, Canada, the United Kingdom, Australia, New Zealand, etc. Check out my profile.