S
Samantha
I am new to Python and am attempting to write a routine that will display a
five game selection for a power ball drawing. I think I have the random
drawing set to work ok, but I want to have the dialog box move in the center
of my screen. I can't seem to get the code correct to do this. Any help
would be appreciated.
Thanks,
S
This is the routine I have.
###########################
import random
from Tkinter import *
root = Tk()
frame = Label(root, width=50, height=2, background = 'white', text =
'PowerBall Numbers')
frame.pack()
def GetNumbers():
numbers = random.sample(xrange(53), 5)
numbers.sort()
numbers[0] = numbers[0] + 1
numbers[1] = numbers[1] + 1
numbers[2] = numbers[2] + 1
numbers[3] = numbers[3] + 1
numbers[4] = numbers[4] + 1
powerball = random.sample(xrange(42), 1)
powerball[0] = powerball[0] + 1
return numbers, powerball
y = 0
sp1 = sp2 = sp3 = sp4 = sp5 =' '
w = 0
for x in range(5):
y = y + 1
MyNumbers= GetNumbers()
x = MyNumbers
num1= str(x[0][0])
num2 = str(x[0][1])
num3 = str(x[0][2])
num4 = str(x[0][3])
num5 = str(x[0][4])
pbnum = str(MyNumbers[1][0])
root.title =('Powerball Numbers')
w = Label(root, width=50, height=2, background= 'white' , text='Game
'+str(y)+': Numbers: '+num1.zfill(2)+' '+num2.zfill(2)+' '+num3.zfill(2)+'
'+num4.zfill(2)+' '+num5.zfill(2)+' '+'PowerBall: '+pbnum.zfill(2))
w.pack()
root.mainloop()
#####################
five game selection for a power ball drawing. I think I have the random
drawing set to work ok, but I want to have the dialog box move in the center
of my screen. I can't seem to get the code correct to do this. Any help
would be appreciated.
Thanks,
S
This is the routine I have.
###########################
import random
from Tkinter import *
root = Tk()
frame = Label(root, width=50, height=2, background = 'white', text =
'PowerBall Numbers')
frame.pack()
def GetNumbers():
numbers = random.sample(xrange(53), 5)
numbers.sort()
numbers[0] = numbers[0] + 1
numbers[1] = numbers[1] + 1
numbers[2] = numbers[2] + 1
numbers[3] = numbers[3] + 1
numbers[4] = numbers[4] + 1
powerball = random.sample(xrange(42), 1)
powerball[0] = powerball[0] + 1
return numbers, powerball
y = 0
sp1 = sp2 = sp3 = sp4 = sp5 =' '
w = 0
for x in range(5):
y = y + 1
MyNumbers= GetNumbers()
x = MyNumbers
num1= str(x[0][0])
num2 = str(x[0][1])
num3 = str(x[0][2])
num4 = str(x[0][3])
num5 = str(x[0][4])
pbnum = str(MyNumbers[1][0])
root.title =('Powerball Numbers')
w = Label(root, width=50, height=2, background= 'white' , text='Game
'+str(y)+': Numbers: '+num1.zfill(2)+' '+num2.zfill(2)+' '+num3.zfill(2)+'
'+num4.zfill(2)+' '+num5.zfill(2)+' '+'PowerBall: '+pbnum.zfill(2))
w.pack()
root.mainloop()
#####################