欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

【四二学堂】python四子连珠游戏-2(画棋盘)

程序员文章站 2022-05-22 12:41:36
...

课程视频:
https://edu.csdn.net/course/detail/28882
【四二学堂】python四子连珠游戏-2(画棋盘)
代码:

from tkinter import*

#画布
#棋盘
class Game:
    def __init__(self):
        self.tk = Tk()
        self.tk.title("四二学堂Python四子连珠游戏")
        self.tk.resizable(0, 0)  # 窗口在水平、垂直方向的大小都不能改变
        # tk.wm_attributes("-topmost",1)  #画布窗口放在其他所有窗口之前
        self.canvas = Canvas(self.tk, width=700, height=700)
        # anvas = Canvas(tk,width=700,height=700,bd=0,highlightthickness=0)
        # bd=0 highlightthickness=0 确保在画布之外没有边框,看上去更美观些
        self.canvas.pack()

class dlines:
    def drawline(self, canvas):
        self.canvas = canvas

        a = [100, 200, 300, 400, 500, 600]
        for ii in a:
            self.canvas.create_line(100, ii, 600, ii)
            self.canvas.create_line(ii, 100, ii, 600)

if __name__=="__main__":
    game=Game()
    dlines = dlines()
    dlines.drawline(game.canvas)
    game.tk.mainloop()