且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

类中未显示 tkinter 画布图像

更新时间:2023-02-22 15:23:36

您必须保留对 PhotoImage 的引用.这只是一个例子(你也可以使用 self.background 而不是 c.background):

You have to keep a reference to the PhotoImage. This is just and example (you can also use self.background instead of c.background):

    c = Canvas(frame2)
    c.pack(expand=YES,fill=BOTH)
    c.background = PhotoImage(file='Board.gif')
    c.create_image(100,100,image=c.background,anchor='nw')