Percentage Finder

from tkinter import *

def getPercentage() :

    students= int(total_participantField.get())

    rank = int(rankField.get())

    result = round((students - rank) / students * 100,3);

    percentageField.insert(10, str(result))

def Clear():

    rankField.delete(0, END)

    total_participantField.delete(0, END)

    percentageField.delete(0, END)

if __name__ == "__main__" :

    gui = Tk()

    gui.configure(background = "light pink")

    gui.title("Rank Based- percentage Calculator")

    gui.geometry("650x200")

    rank = Label(gui, text = "Rank", bg = "light green")

    andl = Label(gui, text = "And", bg = "light green")

    total_participant = Label(gui,

                            text = "Total Participants",

                            bg = "light green")

    find = Button(gui, text = "Find percentage",

                fg = "Black", bg = "Red",

                command = getPercentage)

    percentage = Label(gui, text = "percentage", bg = "light green")

    clear = Button(gui, text = "Clear",

                fg = "Black", bg = "Red",

                command = Clear)

    rank.grid(row = 1, column = 1,padx = 10)

    andl.grid(row = 1, column = 4)

    total_participant.grid(row = 1, column = 6, padx = 10)

    find.grid(row = 3, column = 4,pady = 10)

    percentage.grid(row = 4, column = 3,padx = 10)

    clear.grid(row = 5, column = 4,pady = 10)

    rankField = Entry(gui)

    total_participantField = Entry(gui)

    percentageField = Entry(gui)

    rankField.grid(row = 1, column = 2)

    total_participantField.grid(row = 1, column = 7)

    percentageField.grid(row = 4, column = 4)

    

    gui.mainloop()


No comments: