This is a program that will calculate stockin expenses and other but the problem is whatever value i entered in the cement, bricks and etc(line 120-line155) part it keeps on showing zero

import Tkinter

Total_StockIn = 0
Total_Expenses  = 0

def win1():
    global root
    global s
    # this is the main/root window
    root = Tkinter.Tk()
    root.title("Stock Plus system")
    root.geometry('400x150')
    b2Var=Tkinter.StringVar()
    s = 1


def win2():
    # this is the child window
    global sub
    global m
    sub = Tkinter.Tk()
    sub.title('Stock Plus System')
    sub.geometry('700x500')
    Total_StockIn = 0
    Total_Expenses  = 0

    cementinVar = Tkinter.IntVar()
    hammerinVar = Tkinter.IntVar()
    spannerinVar = Tkinter.IntVar()
    brickinVar = Tkinter.IntVar()
    mirrorinVar = Tkinter.IntVar()

    cementoutVar = Tkinter.IntVar()
    hammeroutVar = Tkinter.IntVar()
    spanneroutVar = Tkinter.IntVar()
    brickoutVar = Tkinter.IntVar()
    mirroroutVar = Tkinter.IntVar()

    labelcementin = Tkinter.Label(sub,text='Cement quantity')
    labelcementin.grid(row=1,column=1)
    labelhammerin = Tkinter.Label(sub,text='Hammer quantity')
    labelhammerin.grid(row=2,column=1)
    labelspannerin = Tkinter.Label(sub,text='Spanner quantity')
    labelspannerin.grid(row=3,column=1)
    labelbrickin = Tkinter.Label(sub,text='Brick quantity')
    labelbrickin.grid(row=4,column=1)
    labelmirrorin = Tkinter.Label(sub,text='Mirror quantity')
    labelmirrorin.grid(row=5,column=1)

    boxcementin = Tkinter.Entry(sub,width=12,textvariable=cementinVar)
    boxcementin.grid(row=1, column=2)
    boxhammerin = Tkinter.Entry(sub,width=12,textvariable=hammerinVar)
    boxhammerin.grid(row=2, column=2)
    boxspannerin = Tkinter.Entry(sub,width=12,textvariable=spannerinVar)
    boxspannerin.grid(row=3, column=2)
    boxbrickin = Tkinter.Entry(sub,width=12,textvariable=brickinVar)
    boxbrickin.grid(row=4, column=2)
    boxmirrorin = Tkinter.Entry(sub,width=12,textvariable=mirrorinVar)
    boxmirrorin.grid(row=5, column=2)

    labelcementout = Tkinter.Label(sub,text='Cement quantity')
    labelcementout.grid(row=1,column=5)
    labelhammerout = Tkinter.Label(sub,text='Hammer quantity')
    labelhammerout.grid(row=2,column=5)
    labelspannerout = Tkinter.Label(sub,text='Spanner quantity')
    labelspannerout.grid(row=3,column=5)
    labelbrickout = Tkinter.Label(sub,text='Brick quantity')
    labelbrickout.grid(row=4,column=5)
    labelmirrorout = Tkinter.Label(sub,text='Mirror quantity')
    labelmirrorout.grid(row=5,column=5)



    boxcementout = Tkinter.Entry(sub,width=12,textvariable=cementoutVar)
    boxcementout.grid(row=1, column=6)
    boxhammerout = Tkinter.Entry(sub,width=12,textvariable=hammeroutVar)
    boxhammerout.grid(row=2, column=6)
    boxspannerout = Tkinter.Entry(sub,width=12,textvariable=spanneroutVar)
    boxspannerout.grid(row=3, column=6)
    boxbrickout = Tkinter.Entry(sub,width=12,textvariable=brickoutVar)
    boxbrickout.grid(row=4, column=6)
    boxmirrorout = Tkinter.Entry(sub,width=12,textvariable=mirroroutVar)
    boxmirrorout.grid(row=5, column=6)


    Button_2 = Tkinter.Button(sub, text="cb",command=textboxvalue2)
    Button_2.grid(row=6,column=2)






def textboxvalue():
#For password entry
    global s

    if (s!=3 ):
       Password=b2Var.get()
       Username=b1Var.get()
       if Password ==('stock123'):
           label4=Tkinter.Label(root,text='Welcome to stock plus system, press login again to start using')
           label4.grid(row=3,column=1)
           Button_1 = Tkinter.Button(root, text="Login", command=win2)
           Button_1.grid(row=2,column=1)

       else:
           s =s+1
           label3=Tkinter.Label(root,text='Try again')
           label3.grid(row=3,column=1)

    else:
        label5=Tkinter.Label(root,text='bye')
        label5.grid(row=4,column=1)
        label6=Tkinter.Label(root,text='Thank You for using Stock Plus System ')
        label6.grid(row=5,column=1)



def textboxvalue2():

    global Total_StockIn
    global Total_Expenses
    cementinVar = Tkinter.IntVar()
    hammerinVar = Tkinter.IntVar()
    spannerinVar = Tkinter.IntVar()
    brickinVar = Tkinter.IntVar()
    mirrorinVar = Tkinter.IntVar()

    cementoutVar = Tkinter.IntVar()
    hammeroutVar = Tkinter.IntVar()
    spanneroutVar = Tkinter.IntVar()
    brickoutVar = Tkinter.IntVar()
    mirroroutVar = Tkinter.IntVar()

    CementIn = cementinVar.get()
    HammerIn = hammerinVar.get()
    SpannerIn = spannerinVar.get()
    BrickIn = brickinVar.get()
    MirrorIn = mirrorinVar.get()

    CementOut = cementoutVar.get()
    HammerOur = hammeroutVar.get()
    SpannerOut = spanneroutVar.get()
    BrickOut = brickoutVar.get()
    MirrorOut = mirroroutVar.get()

    Total_Stockin = CementIn + HammerIn + SpannerIn + BrickIn + MirrorIn
    StockInLabel = Tkinter.Label(sub,text='Total stock is '+str(Total_StockIn))
    StockInLabel.grid(row=7, column =2)


    Total_Expenses  = (CementIn*16) + (HammerIn*10) + (SpannerIn*8) +(BrickIn*2) + (MirrorIn*22)
    StockInLabel = Tkinter.Label(sub,text=('Total expense is' +str(Total_Expenses)))
    StockInLabel.grid(row=8, column =2)





win1()
#Widgets in main window
Button_1 = Tkinter.Button(root, text="Login", command=textboxvalue)
Button_1.grid(row=2, column=1)
b1Var = Tkinter.StringVar()
b2Var = Tkinter.StringVar()

box1Label = Tkinter.Label(root,text='Username:')
box1Label.grid(row=0)
box2Label = Tkinter.Label(root,text='Password:')
box2Label.grid(row=1)
box1Text = Tkinter.Entry(root,textvariable=b1Var,width=12)
box1Text.grid(row=0, column=1)
box2Text = Tkinter.Entry(root,textvariable=b2Var,width=12,show='*')
box2Text.grid(row=1, column=1)



root.mainloop()

Remove lines 124 to 134, you already have declared these variables in lines 27 to 37. Move lines 27 to 37 into your main program below the win1() line to make those variables global.

Variables declared inside a function are local to that function.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.