i want to add some info in my entry widget in tkinter

I want to add account codes and there values in entry widget or any other widget but I don't know how to do that following is the info:

{100 : 'Cash',101 : 'Equipments', 102 : 'Supplies' , 103 : 'AccRec' , 104 : 'PreInsurance', 200 : 'AccPayable', 201 : 'NotesPay', 202 : 'InterestPayable', 203 : 'AccDepreciation' , 204 : 'Salaries and wages payable', 300 : 'Owner_Capital', 301 : 'Owner Drawing', 400 : 'Service Revenue' , 401 : 'Rent Revenue', 500 : 'Salaries and wages Expense' , 501 : 'Utilities Expense' , 502 : 'Rent Expense' , 503 : "Insurance Expense" , 504 : 'Depreciation Expense' , 505 : 'Supplies expense' }

so that when user wants to insert the account he can know the account code for the value he wants to insert

1 answer

  • answered 2020-01-18 11:09 Somraj Chowdhury

    If you just want to list the codes and the respective values inside the GUI window, you can do something like the following

    import tkinter as tk
    
    codes = {100 : 'Cash',
            101 : 'Equipments',
            102 : 'Supplies',
            103 : 'AccRec',
            104 : 'PreInsurance',
            200 : 'AccPayable',
            201 : 'NotesPay',
            202 : 'InterestPayable',
            203 : 'AccDepreciation' ,
            204 : 'Salaries and wages payable',
            300 : 'Owner_Capital',
            301 : 'Owner Drawing',
            400 : 'Service Revenue',
            401 : 'Rent Revenue',
            500 : 'Salaries and wages Expense',
            501 : 'Utilities Expense',
            502 : 'Rent Expense',
            503 : "Insurance Expense" ,
            504 : 'Depreciation Expense',
            505 : 'Supplies expense' }
    
    window = tk.Tk()
    
    _row = 0 
    for code, value in codes.items():
        tk.Label(window, text=str(code)+' - '+value).grid(row=_row, column=0, sticky=tk.W)
        _row += 1
    
    window.mainloop()
    

    cl