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.
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
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 |
# 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) |
Help please