-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstartupCode.py
More file actions
executable file
·51 lines (45 loc) · 1.16 KB
/
startupCode.py
File metadata and controls
executable file
·51 lines (45 loc) · 1.16 KB
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
#!/usr/bin/python3
import turtle
import random
from turtle import TK
def sizetostr(size,pos):
return str(int(size[0]))+"x"+str(int(size[1]))+"+"+str(int(pos[0]))+"+"+str(int(pos[1]))
randerlib="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890#*"
def rander(a=3,b=4,confirm=False):
res=""
for i in range(a):
if i!=0:
res+="-"
cur=""
num=0
for j in range(b):
i=random.randint(0,len(randerlib)-1)
cur+=randerlib[i]
num=num^i
if confirm:
cur+=randerlib[num]
res+=cur
return res
def newwindow(title=None,size=(200,200),pos=(100,100)):
wn=TK.Tk()
wn.geometry(sizetostr(size,pos))
if title==None:
title=rander()
wn.title(title)
cv=TK.Canvas(wn,width=size[0],height=size[1])
cv.pack()
sc=turtle.TurtleScreen(cv)
return (wn,cv,sc)
def delwindow(wnd):
wnd[0].destroy()
def main():
global wnd
wnd = newwindow(title = "Practice", size = (400, 300))
def destroy_wrapper():
delwindow(wnd)
wnd[2].onkey(destroy_wrapper, "Escape")
wnd[2].listen()
return 0
if __name__ == "__main__":
main()
wnd[2].mainloop()