Sep-02-2020, 03:46 AM
I have watched a couple of videos and still stumped. The calc_value variable get assigned a number and I print it out and it is fine. But when I try and put it in a dictionary in another function it doesn't show up. Anyway here's code.
Help please
# SET UP CALCULATOR SLIDER TO SET FACTOR WEIGHTS def get_Caclulator(): calculator= Toplevel() global Calculator_horizontal global factornames global calc_value width_of_window = 300 height_of_window = 300 screen_width= calculator.winfo_screenwidth() screen_height = calculator.winfo_screenheight() x_coordinate = (screen_width/2) - (width_of_window/2) y_coordinate = (screen_height/2) - (height_of_window/2) calculator.geometry("%dx%d+%d+%d" % (width_of_window,height_of_window,x_coordinate,y_coordinate )) calculator.iconbitmap("c:/guis/racehorse.ico") Calculator_horizontal = Scale(calculator, from_= -50, to = 250, length = 200, resolution = 2,orient=HORIZONTAL) Calculator_horizontal.place(x=50, y=60) my_label= Label(calculator, text ="Set Factor Weight", fg= "#104CD6", font = ("sans_serif" , 16)).place(x=50, y=20) calc_button = Button(calculator, text = "Save Weight",bg="#E2F07F", width = 15, command = set_calc_value) calc_button.place(x=90, y=125) def set_calc_value(): global calc_value global factornames global factor global Factor_ypos global calc_valu_pos calc_valu_pos += 25 calc_value = Calculator_horizontal.get() calc_value_label=Label(factor_build,text = calc_value, fg="black",font = ("sans_serif" , 14) ).place(x=1000,y=calc_valu_pos) def set_drfvalue(): get_Caclulator() global Factor_ypos global calc_value Factor_ypos += 25 a_factorname= Label( factor_build, text ="drf", fg= "black", font = ("sans_serif" , 16)).place(x=750, y= Factor_ypos) factor_list['drf'] = calc_value print(factor_list['drf']) print(calc_value)I print calc_value in def set_calc_value(): to check it and it has a value. But when I get to the def set_drfvalue(): it doesn't show a value.
Help please