Python Forum
Incrementing variable counter
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Incrementing variable counter
#3
I have a lot of globals that I may not need, but just learning this language. Any way here we go.

# CREATE WINDOW TO FACILITATE USER CHOOSING FACTOR SETS.
def build_factors():
	global factor_build
	global entry_factors
	global  labelfactor
	global calc_value
	global factor_namee_label
	global factorname
	global factor
	global factor_location
	global calc_valu_pos
	global Factor_ypos
	calc_valu_pos = 140
	Factor_ypos = 140
	calc_value = 0
	factor_build = Toplevel()

	Labe20 = Label(factor_build, text="Factor Factory",fg="#1F51B7",font = ("sans_serif" , 16) ).pack()
	Labe21 = Label(factor_build, text="Choose Wisely Grasshopper",fg="#F31839",font = ("sans_serif" , 12) ).pack()
	labelfactor =Label(factor_build)
	entry_factors = StringVar()
	factornames = StringVar()
	factor = StringVar()
	width_of_window = 1000
	height_of_window = 700
	screen_width= factor_build.winfo_screenwidth()
	screen_height = factor_build.winfo_screenheight()
	x_coordinate = (screen_width/2) - (width_of_window/2)
	y_coordinate = (screen_height/2) - (height_of_window/2)
	factor_build.geometry("%dx%d+%d+%d" % (width_of_window,height_of_window,x_coordinate,y_coordinate ))
	factorset_label= Label( factor_build, text ="Name Your Analyst First", fg= "#F33038", font = ("sans_serif" , 12)).place(x=803, y=20)
	entry_factors = Entry(factor_build, font = ("sans_serif", 12))
	entry_factors.place(x=800, y=50)
	save_factorbutton= Button(factor_build, text="Save Factors Name", width = 15, command=save_factors)
	save_factorbutton.place(x=830, y=80)
	
	#factor_label=Label(factor_build,text = factor, fg="#1F51B7",font = ("sans_serif" , 16) ).place(x=800,y=120)
	factor_build.iconbitmap("c:/guis/racehorse.ico")
	my_button20 = Button(factor_build, text = "DRF Speed",bg="#0DDA7D", width = 15,  command = set_drfvalue) 
	my_button20.place(x=10, y=25)
	my_button21 = Button(factor_build, text = "Bst Spd T-T", bg='#0DDAD7' ,width = 15, command = set_bestspeed) 
	my_button21.place(x=10, y=53)
	my_button22 = Button(factor_build, text = "Bst Spd Turf", bg="#0DDA7D",width = 15, command = set_bestspeed_turf) 


def save_factors():
	global factor
	factor = entry_factors.get()
	factor_namee_label=Label(factor_build,text = factor, fg="#4167E8",font = ("sans_serif" , 14) ).place(x=800,y=145)
	factor_label = Label(factor_build, text = 'Analyst Name', fg= 'black',font = ("sans_serif" , 14) ).place(x=800,y=120)

def set_drfvalue():
	
	get_Caclulator()
	Factor_ypos += 25
	a_factorname= Label( factor_build, text ="drf", fg= "black", font = ("sans_serif" , 16)).place(x=800, y= Factor_ypos) 
I have posted these in reverse order just so you can see what calls what.

I used two different variables for the two displays. Set them at 140 and each time they are used I increment them += 25.
Reply


Messages In This Thread
Incrementing variable counter - by Milfredo - Sep-01-2020, 06:57 PM
RE: Incrementing variable counter - by bowlofred - Sep-01-2020, 07:04 PM
RE: Incrementing variable counter - by Milfredo - Sep-01-2020, 09:02 PM
RE: Incrementing variable counter - by bowlofred - Sep-01-2020, 09:43 PM
RE: Incrementing variable counter - by Milfredo - Sep-02-2020, 12:54 AM

Forum Jump:

User Panel Messages

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