I have the following code
The problem is that the buttons (with their images do not appear in the window). If i change the canvas dimensions i can almost see some of the buttons to the left of the image but their images still dont appear. Unless i have confused rows with columns the grid assignments would have the buttons be placed under the picture with their respective images. Please help
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
from tkinter import * from tkinter import messagebox def read_account_balance(): try : with open ( "money.txt" , "r" ) as file : money = float ( file .read()) except FileNotFoundError: with open ( "money.txt" , "w" )as file : money = 0.00 file .write(money) except ValueError: with open ( "money.txt" , "w" )as file : money = 0.00 file .write(money) return money window = Tk() def deposit_money(): pass def withdraw_money(): pass def money_transfer(): pass def display_account_balance(): budget = read_account_balance() messagebox.showinfo(title = "Balance Information" ,message = f "Account Balance is {budget}0" ) read_account_balance() window.config(padx = 50 ,pady = 50 ) window.title( "Bank App" ) canvas = Canvas(width = 400 ,height = 275 ) bank_pic = PhotoImage( file = "./bank.png" ) picture = canvas.create_image( 200 , 149 ,image = bank_pic) canvas.grid(row = 1 ,column = 0 ) withdraw_img = PhotoImage( "./withdraw.jpg" ) deposit_img = PhotoImage( "./deposit.jpg" ) money_transfer_pic = PhotoImage( "./money_transfer_pic.png" ) deposit_button = Button(text = "Deposit Money" ,image = deposit_img,command = deposit_money) deposit_button.grid(row = 1 ,column = 1 ) deposit_button.img_reference = deposit_img withdraw_button = Button(text = "Withdraw Money" ,image = withdraw_img,command = withdraw_money) withdraw_button.grid(row = 2 ,column = 1 ) withdraw_button.img_reference = withdraw_img money_transfer_button = Button(text = "Money Transfer" ,image = money_transfer_pic,command = money_transfer) money_transfer_button.grid(row = 1 ,column = 2 ) money_transfer_button.img_reference = money_transfer_pic account_balanace_image = PhotoImage( file = "./account-balance.png" ) account_balanace_button = Button(text = "Account Balance" ,image = account_balanace_image,command = display_account_balance) account_balanace_button.img_reference = account_balanace_image window.mainloop() |