
"""
8皇后问题教学动态演示_图章版
本程序需要Python精灵模块支持,如果没有安装,请用cmd打开管理员窗口,输入:
pip install sprites进行安装。
"""
from sprites import *
width,height = 400,400
screen = Screen()
screen.title('8皇后教学演示by李兴球')
ft = ('黑体',18,'bold')
ft2 = ('新宋体',12,'normal')
tom = Sprite(visible=False) # 负责画格子与显示标题信息的
tom.color('magenta')
tom.addy(250)
tom.write("8皇后问题教学演示程序",align='center',font=ft)
tom.addy(-30)
tom.color('blue')
tom.write("本程序用于手工摆放皇后给学生看",align='center',font=ft2)
tom.home()
cors = tom.draw_grid2(8,8,50,50) # 画8x8,长宽为50的格子图
tom.shape('res/black.png')
# 下面是画黑白相间的格子
c = 0
for rows in cors:
index = c % 2
for xy in rows:
tom.goto(xy)
if index % 2 == 0 :tom.stamp()
index += 1
c = c + 1
jack0 = Sprite('res/queen.png',pos=(120,120))
jack1 = Sprite('res/queen.png',pos=(-120,-120))
jack2 = Sprite('res/queen.png',pos=(-120,20))
jack3 = Sprite('res/queen.png',pos=(-240,-10))
jack4 = Sprite('res/queen.png',pos=(-240,180))
jack5 = Sprite('res/queen.png',pos=(-120,-240))
jack6 = Sprite('res/queen.png',pos=(-240,120))
jack7 = Sprite('res/queen.png',pos=(40,-120))
screen.mainloop()