Hi I think this topic is beyond my lame python abbilities.
I hope the program can run, it is writen by using error messages until it worked.
I am using python 33.
I am trying to learn info on adding leading zeros to the output.(File & Windows)
I am not sure if the variable that produces output is a list or int sometimes I think it is both :)possibly the varible (g)
either way, I am lost and have tried different things all day.
So if you have any Idea THANKS!
Output of File:
No leading zeros
4 5 33 48 57 - 41
2 27 38 54 58 - 4
8 24 30 53 57 - 46
8 17 25 42 55 - 15
15 22 34 36 47 - 7
Desired output of File:
Leading zeros
04 05 33 48 57 - 41
02 27 38 54 58 - 04
08 24 30 53 57 - 46
08 17 25 42 55 - 15
15 22 34 36 47 - 07
from tkinter import*
import sys, random, tkinter
ticket_price = 2
i=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))
label4 = Label(aApp,text = 'We permit values in 1, 2, 3, 4 or 5!',fg = 'blue').grid(row=7,column=1)
else:
label4 = Label(aApp,text = ' ',fg = 'blue').grid(row=7,column=1)
mytik=int(ticket_entry)
total = mytik*ticket_price
Label(aApp,text= "You purchased:$%.2f \n" % total).grid(row=7,column=1)
Label(aApp,text= "\nNumber Of Tckets: %.f\n" % 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)
aApp=Tk()
aApp.geometry('580x170+200+270')
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\nClick Here",fg='blue'\
,command=calculatetotals)
button1.grid(row=6,column=1)
def nextx():
Button(aApp,text="Click Here to see the new winning number.",fg='lightgreen',bg='black'\
,command = nextz).grid(row=8,column=1)
ticket_entry = tik.get()
#######################################
# outputs to Window and File("C:\output.txt","a")
#######################################
i = 0
while i < int(ticket_entry):
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])])
label5=tkinter.Label(app,text = drawing ).pack(padx=1,pady=2)
text_file = open("C:\output.txt","a")
text_file.write('\n')
text_file.write(drawing)
text_file.close()
i+=1
#########################################
# Finnished output to window and File
#########################################
app=tkinter.Tk()
app.geometry('600x400+75+75')
app.title(string=" NUMBERS ")
Button(app, text="Quit", command=app.quit).pack()
def nextz():
Button(aApp,text='Push again to <Quit> : To see if you match Push <Compare> In The New Winning Number Window, '\
,fg='yellow',bg='black',command = quit).grid(row=8,column=1)
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])])
aBpp=tkinter.Tk()
aBpp.geometry('200x100+705+705')
aBpp.title(string="Winning Number")
label6=tkinter.Label(aBpp,text = drawing).pack(padx=1,pady=2)
Button(aBpp, text="Compare", command=aBpp.quit).pack()
return
tkinter.mainloop()
app.mainloop()
aApp.mainloop()