小编The*_*Man的帖子

单击按钮,在tkinter窗口中显示图像

我需要有关这个程序的帮助,这个程序应该通过点击按钮在新的tkinter窗口中打开图像,但它不会只打开没有图像的新窗口.问题出在哪儿?

使用:python 3.3和tkinter

这是程序:

import sys
from tkinter import *


def button1():
    novi = Toplevel()
    canvas = Canvas(novi, width = 300, height = 200)
    canvas.pack(expand = YES, fill = BOTH)
    gif1 = PhotoImage(file = 'image.gif')
    canvas.create_image(50, 10, visual = gif1, anchor = NW)


mGui = Tk()
button1 = Button(mGui,text ='Sklop',command = button1, height=5, width=20).pack()

mGui.mainloop()
Run Code Online (Sandbox Code Playgroud)

python canvas window image tkinter

2
推荐指数
1
解决办法
5832
查看次数

标签 统计

canvas ×1

image ×1

python ×1

tkinter ×1

window ×1