from Tkinter import *
from random import randrange
class Pole(Canvas):
def __init__(self,rows,cols,size):
self.rows=rows
self.cols=cols
self.size=size
width_g=cols*size
height_g=rows*size
Canvas.__init__(self,relief=RIDGE, borderwidth=2, width=width_g, height=height_g)
A=range(rows+1)
for i in range(rows):
A[i]=range(cols)
for i in range(rows):
for j in range(cols):
A[i][j]=0
x=j*size
y=i*size
x1=x+size
y1=y+size
self.create_rectangle(x,y,x1,y1, fill=colors[0],tag='pole')
self.data=A
def ris(self):
for i in range(self.rows):
for j in range(self.cols):
x=j*self.size
y=i*self.size
x1=x+self.size
self.create_rectangle(x,y,x1,y1, fill=colors[self.data[i][j]],tag='pole')
class Work:
def __init__(self,rows=30,cols=15,size=15,delay=1000):
self.ii=2
self.jj=cols/2
self.nf=1
self.nf=randrange(len())
for nk in [0,1,2,3]:
x=(self.jj+fig_data[self.nf][nk][1])*size
y=(self.ii+fig_data[self.nf][nk][0])*size
x1=x+size
y1=y+size
pole.create_rectangle(x,y,x1,y1, fill=fig_data[self.nf][nk])
fig_data[self.nf]
def ris(self):
for nk in [0,1,2,3]:
s=(self.jj+self.B[nk][1])*self.size
y=(self.ii+self.B[nk][0])*self.size
x1=x+self.size
y1=y+self.size
pole.create_rectangle(x,y,x1,y1 fill=colors[self.B[4]],tag='cubs')
def move(self,i,j,):
a=o
for nk in 0,1,2,3:
iii=self.ii+self.B[nk][0]
jjj=self.jj+self.B[nk][1]
if iii in range(pole.rows) and jjj in range(pole.cols)and pole.data[]
#def f_top_top(event):
#print'ryaaaaa!!!'
def keyPressed(event):
if(event.keysym == "Up"):
pass
if(event.keysym == "Down"):
pass
if(event.keysym == "Left"):
try:
figa.jj-=1
figa.jj.top_top()
except Tupik:
figa.jj+=1
if(event.keysym == "Right"):
pass
elif (event.char == "g"):
time_top()
okno=Tk()
okno.title('Tetris')
ramka_1 =Frame(okno, relief=SOLID, borderwidth=3, width=300, height=600, bg='#9ACD32')
ramka_2 =Frame(okno, width=300,bg='white')
ramka_1.pack(side=LEFT)
ramka_2.pack(side=LEFT, fill=BOTH)
ramka_t=Frame(ramka_2, relief=GROOVE, borderwidth=3, width=250, height=100,bg='#FF69B4')
ramka_t.pack(side=TOP)
ramka_B=Frame(ramka_2, width=250, height=100,bg='#B22222')
ramka_B.pack(side=BOTTOM)
pole=Pole(ramka_1,rows=18, cols=12, bit=20,color='#808080')
pole.pack(side=LEFT, expand=1)
figa=Figa(15,15)
okno.bind("<Key>", KeyPressed)
#exort.create_oval(0,100,70,70, fill='deepskyblue')
but={}
but[1]=Button(ramka_B,text='START',command=my_start)
but[2]=Button(ramka_B,text='EXIT',command=okno.destroy)
but[3]=Button(ramka_B,text='CLEAR',command=my_clear)
but[4]=Button(ramka_B,text='COLOR',command=my_color)
but[1].grid(row=0, column=0)
but[2].grid(row=0, column=1)
but[3].grid(row=1, column=0)
but[4].grid(row=1, column=1)
okno.mainloop()
ZnJvbSBUa2ludGVyIGltcG9ydCAqCmZyb20gcmFuZG9tIGltcG9ydCByYW5kcmFuZ2UKCmNsYXNzIFBvbGUoQ2FudmFzKToKICAgIGRlZiBfX2luaXRfXyhzZWxmLHJvd3MsY29scyxzaXplKToKICAgICAgICBzZWxmLnJvd3M9cm93cwogICAgICAgIHNlbGYuY29scz1jb2xzCiAgICAgICAgc2VsZi5zaXplPXNpemUKICAgICAgICB3aWR0aF9nPWNvbHMqc2l6ZQogICAgICAgIGhlaWdodF9nPXJvd3Mqc2l6ZQogICAgICAgIENhbnZhcy5fX2luaXRfXyhzZWxmLHJlbGllZj1SSURHRSwgYm9yZGVyd2lkdGg9Miwgd2lkdGg9d2lkdGhfZywgaGVpZ2h0PWhlaWdodF9nKQogICAgICAgIEE9cmFuZ2Uocm93cysxKQogICAgICAgIGZvciBpIGluIHJhbmdlKHJvd3MpOgogICAgICAgICAgICBBW2ldPXJhbmdlKGNvbHMpCiAgICAgICAgZm9yIGkgaW4gcmFuZ2Uocm93cyk6CiAgICAgICAgICAgIGZvciBqIGluIHJhbmdlKGNvbHMpOgogICAgICAgICAgICAgICAgQVtpXVtqXT0wCiAgICAgICAgICAgICAgICB4PWoqc2l6ZQogICAgICAgICAgICAgICAgeT1pKnNpemUKICAgICAgICAgICAgICAgIHgxPXgrc2l6ZQogICAgICAgICAgICAgICAgeTE9eStzaXplCiAgICAgICAgICAgICAgICBzZWxmLmNyZWF0ZV9yZWN0YW5nbGUoeCx5LHgxLHkxLCBmaWxsPWNvbG9yc1swXSx0YWc9J3BvbGUnKQogICAgICAgIHNlbGYuZGF0YT1BCiAgICBkZWYgcmlzKHNlbGYpOgogICAgICAgIGZvciBpIGluIHJhbmdlKHNlbGYucm93cyk6CiAgICAgICAgICAgIGZvciBqIGluIHJhbmdlKHNlbGYuY29scyk6CiAgICAgICAgICAgICAgICB4PWoqc2VsZi5zaXplCiAgICAgICAgICAgICAgICB5PWkqc2VsZi5zaXplCiAgICAgICAgICAgICAgICB4MT14K3NlbGYuc2l6ZQogICAgICAgICAgICAgICAgc2VsZi5jcmVhdGVfcmVjdGFuZ2xlKHgseSx4MSx5MSwgZmlsbD1jb2xvcnNbc2VsZi5kYXRhW2ldW2pdXSx0YWc9J3BvbGUnKQpjbGFzcyBXb3JrOgogICAgZGVmIF9faW5pdF9fKHNlbGYscm93cz0zMCxjb2xzPTE1LHNpemU9MTUsZGVsYXk9MTAwMCk6CiAgICAgICAgc2VsZi5paT0yCiAgICAgICAgc2VsZi5qaj1jb2xzLzIKICAgICAgICBzZWxmLm5mPTEKICAgICAgICBzZWxmLm5mPXJhbmRyYW5nZShsZW4oKSkKICAgIGZvciBuayBpbiBbMCwxLDIsM106CiAgICAgICAgeD0oc2VsZi5qaitmaWdfZGF0YVtzZWxmLm5mXVtua11bMV0pKnNpemUKICAgICAgICB5PShzZWxmLmlpK2ZpZ19kYXRhW3NlbGYubmZdW25rXVswXSkqc2l6ZQogICAgICAgIHgxPXgrc2l6ZQogICAgICAgIHkxPXkrc2l6ZQogICAgICAgIHBvbGUuY3JlYXRlX3JlY3RhbmdsZSh4LHkseDEseTEsIGZpbGw9ZmlnX2RhdGFbc2VsZi5uZl1bbmtdKQogICAgICAgICAgCiAgICBmaWdfZGF0YVtzZWxmLm5mXQoKZGVmIHJpcyhzZWxmKToKICAgIGZvciBuayBpbiBbMCwxLDIsM106CiAgICAgICAgcz0oc2VsZi5qaitzZWxmLkJbbmtdWzFdKSpzZWxmLnNpemUKICAgICAgICB5PShzZWxmLmlpK3NlbGYuQltua11bMF0pKnNlbGYuc2l6ZQogICAgICAgIHgxPXgrc2VsZi5zaXplCiAgICAgICAgeTE9eStzZWxmLnNpemUKICAgICAgICBwb2xlLmNyZWF0ZV9yZWN0YW5nbGUoeCx5LHgxLHkxIGZpbGw9Y29sb3JzW3NlbGYuQls0XV0sdGFnPSdjdWJzJykKCmRlZiBtb3ZlKHNlbGYsaSxqLCk6CiAgICBhPW8KICAgIGZvciBuayBpbiAwLDEsMiwzOgogICAgICAgIGlpaT1zZWxmLmlpK3NlbGYuQltua11bMF0KICAgICAgICBqamo9c2VsZi5qaitzZWxmLkJbbmtdWzFdCiAgICAgICAgaWYgaWlpIGluIHJhbmdlKHBvbGUucm93cykgYW5kIGpqaiBpbiByYW5nZShwb2xlLmNvbHMpYW5kIHBvbGUuZGF0YVtdCiNkZWYgZl90b3BfdG9wKGV2ZW50KToKICAgICNwcmludCdyeWFhYWFhISEhJwoKZGVmIGtleVByZXNzZWQoZXZlbnQpOgogICAgaWYoZXZlbnQua2V5c3ltID09ICJVcCIpOgogICAgICAgIHBhc3MKICAgIGlmKGV2ZW50LmtleXN5bSA9PSAiRG93biIpOgogICAgICAgIHBhc3MKICAgIGlmKGV2ZW50LmtleXN5bSA9PSAiTGVmdCIpOgogICAgICAgIHRyeToKICAgICAgICAgICAgZmlnYS5qai09MQogICAgICAgICAgICBmaWdhLmpqLnRvcF90b3AoKQogICAgICAgIGV4Y2VwdCBUdXBpazoKICAgICAgICAgICAgZmlnYS5qais9MQogICAgaWYoZXZlbnQua2V5c3ltID09ICJSaWdodCIpOg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