-
Notifications
You must be signed in to change notification settings - Fork 0
/
randomCircles01.py
53 lines (40 loc) · 1.62 KB
/
randomCircles01.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import sys
import time
from tkinter import *
import random
import math
# this is a comment
# the computer does NOT read comments.
# only humans read comments.
def myHello():
print("hello world")
colourList = ["red", "green", "light blue", "orange", "yellow", "pink", "indigo", "violet", "magenta"]
iMax = 100
iMax = loopReq.get()
for i in range(0,iMax):
print("loop number: " + str(i+1))
myCan.delete("text01")
fillCol = random.SystemRandom().choice(colourList)
ranNum1 = random.randint(1,400)
ranNum2 = random.randint(1,200)
loopNum = round((i+1) / iMax * 100,1)
myCan.create_rectangle(30,40,180,60, fill = "dark red", outline = "dark blue")
myCan.create_text(100,50, fill = "white", text="percent complete "+ str(loopNum), tag="text01")
myCan.create_oval(ranNum1,ranNum2,ranNum1+4,ranNum2+4, fill = fillCol)
myCan.update()
#time.sleep(0.01)
myGui = Tk()
myGui.geometry('400x400')
myGui.title("Random Dots Programme")
loopReq = IntVar(value=50)
Label(myGui, text = "number of loops").pack()
Entry(myGui, textvariable = loopReq).pack()
Label(myGui, text = "press okay to run").pack()
myButton = Button(myGui, text = "ok", command = myHello, fg = "white", bg = "purple").pack()
myCan = Canvas(myGui, width=400, height=200, bg = 'black')
myCan.create_rectangle(30,40,180,60, fill = "dark red", outline = "dark blue")
myCan.create_text(100,50, fill = "orange", text="starting hello world", tag="text01")
myCan.pack()
myGui.update()
#input("press enter to close .>.>.>")
myGui.mainloop()