1+ import tkinter as tk
2+ from tkinter import messagebox
3+
4+ # Function to calculate the distribution
5+ def calculate_distribution ():
6+ try :
7+ salary = float (entry_salary .get ())
8+ expenses = salary * 0.50
9+ savings = salary * 0.20
10+ investments = salary * 0.20
11+ discretionary_spending = salary * 0.10
12+
13+ result .set (f"Expenses: ${ expenses :.2f} \n \n "
14+ f"Savings: ${ savings :.2f} \n \n "
15+ f"Investments: ${ investments :.2f} \n \n "
16+ f"Discretionary Spending: ${ discretionary_spending :.2f} " )
17+ except ValueError :
18+ messagebox .showerror ("Invalid Input" , "Please enter a valid number for the salary." )
19+
20+
21+ # Create the main window
22+ root = tk .Tk ()
23+ root .title ("Money Manager" )
24+ root .geometry ("400x600" )
25+ root .resizable (False , False )
26+ root .configure (bg = '#E7CEFF' )
27+
28+ #Logo
29+ logo = tk .PhotoImage (file = "logo.png" )
30+ tk .Label (root ,image = logo ,bg = "#E7CEFF" ).place (x = 115 ,y = 2 )
31+
32+ #heading
33+ heading = tk .Label (root ,text = "Money Manager" ,
34+ font = 'arial 20 bold' ,fg = "#9B50DE" ,
35+ bg = "#E7CEFF" )
36+ heading .place (x = 100 ,y = 195 )
37+
38+ # Create and place the widgets
39+ label_salary = tk .Label (root , text = "Enter your salary:" ,
40+ bg = '#E7CEFF' ,
41+ font = 'arial 12 bold' )
42+ label_salary .place (x = 130 , y = 260 )
43+
44+ entry_salary = tk .Entry (root ,width = 17 ,font = 'arial 11 bold' )
45+ entry_salary .place (x = 130 , y = 290 )
46+
47+ button_organize = tk .Button (root , text = "Organize" ,
48+ command = calculate_distribution ,
49+ width = 11 ,
50+ cursor = 'hand2' , bg = "#FFAA00" , bd = 0 ,
51+ activebackground = '#ED8051' ,
52+ font = 'arial 14 bold' )
53+ button_organize .place (x = 132 , y = 340 )
54+
55+ result = tk .StringVar ()
56+ label_result = tk .Label (root , textvariable = result , justify = "left" ,
57+ font = 'arial 11 bold' ,bg = "#E7CEFF" ,fg = '#9B50DE' )
58+ label_result .place (x = 120 , y = 400 )
59+
60+ insta_page = tk .Label (root ,text = "@pythonagham" ,bg = '#E7CEFF' ,
61+ fg = 'black' ,font = 'arial 10 bold italic' )
62+ insta_page .place (x = 155 ,y = 560 )
63+
64+ # Run the application
65+ root .mainloop ()
0 commit comments