Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Still Stumped
#1
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.

# 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
Reply


Messages In This Thread
Still Stumped - by Milfredo - Sep-02-2020, 03:46 AM
RE: Still Stumped - by bowlofred - Sep-02-2020, 05:56 AM
RE: Still Stumped - by Milfredo - Sep-02-2020, 07:48 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Stumped by my own code (ratio & epoch-time calculation). MvGulik 2 2,928 Dec-30-2020, 12:04 AM
Last Post: MvGulik
  Really stumped now Milfredo 7 4,284 Sep-17-2020, 06:18 AM
Last Post: Milfredo
  attribute error stumped on how to fix it. hank4eva 7 9,081 Aug-11-2020, 04:47 AM
Last Post: hank4eva

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020