Hi I need help using the variable mytik as a counter in the GUI "app"
If you run this code mytik stays at 1,2,3,4 or 5 as entered but when I need it for a counter in the next GUI window it no longer has the value of say "1,2,3,4,or 5 but has the value of mytik = .16801968
I use the print mytik3 as an example. I have no idea what .16801968 is and I don't know how to get the mytik = 1,2,3,4,or 5 for use as a counter. Thanks for any sugestions.
Sorry for the sloppy code also.
from tkinter import*
import sys, random, tkinter
ticket_price = 2
ticket_entry=0
total=0
def calculatetotals():
valid = set('12345')
ticket_entry = tik.get()
if ticket_entry not in valid:
print('We permit values in {}.'.format(valid))
else:
mytik=int(ticket_entry)
print('mytik1=',mytik)
print('ticket_entry1=',ticket_entry)
total=mytik*ticket_price
print('total dolars1=',total)
print('##############')
Label(aApp,text= "You purchased:$%.2f \n" % total).grid(row=7,column=2)
#####################
#Will be changed to non-float
Label(aApp,text= "Number Of Tckets: %.f" % mytik).grid(row=6,column=1)
Button(aApp,text="Click Here To Draw Your Tickets!",fg='blue',bg='white',command = nextx).grid(row=8,column=1)
####################
print('mytik2=',mytik)
print('ticket_entry2=',ticket_entry)
print('total dolars2=',total)
print('##############')
aApp=Tk()
aApp.geometry('400x200+100+200')
aApp.title("LOTTO")
tik=StringVar()
label1 = Label(aApp,text = "WELCOME TO LOTTO.",fg = 'blue')
label1.grid(row=0,column=2)
label2=Label(aApp,text="Tickets Are ${:.2f} Each.".format(ticket_price),fg='red')
label2.grid(row=1,column=1)
label3=Label(aApp,text="How Many Would You Like?",fg='black')
label3.grid(row=2,column=1)
mytik = Entry(aApp,textvariable=tik)
mytik.grid(row=2,column=2)
button1=Button(aApp,text="Your Purchse\n",fg='blue',command=calculatetotals)
button1.grid(row=6,column=1)
print('mytik3=',mytik)
print('ticket_entry3=',ticket_entry)
print('total dolars3=',total)
print('##############')
# sample items without replacement
def nextx():
print('mytik3=',mytik)
#i = 0
#app=None
#app=tkinter.Tk()
#app.geometry('700x400+320+320')
#app.title(string=" LOTTO ")
#while i !=mytik:
#L = list(range(1,60))
# random.shuffle(L)
#g = L[:5]
#g.sort()
#f = L[5:6]
#drawing = ' '.join( [' - '.join(str(G) for G in g),' - ',str(f[0])])
#print(drawing)
# label5=tkinter.Label(app,text = drawing ).pack(padx=1,pady=2)
# i = i + 1
# break
aApp.mainloop()
tkinter.Button(text="Exit",fg="brown",bg="cyan" ,command=sys.exit).pack()
tkinter.mainloop()
#app.mainloop()