TreeView中的图像未显示Tkin

2024-09-30 08:25:13 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在用Tkinter Python3.4制作一个TreeView,我添加了一个chrome徽标,但图像从未出现过。在

treeview=ttk.Treeview(frame3)
chromelogo=PhotoImage(file="./Images/minor-logo.png")

chromelogo=chromelogo.subsample(10,10)

treeview.pack(fill=BOTH,expand=True)
treeview.insert('','0','Chrome',text='Chrome', image=chromelogo)

treeview.insert('Chrome','0',"shit",text="shit",image=chromelogo)

treeview.insert('','1','Chrome3',text='Chrome3')

{a1}图标链接


Tags: text图像imagetkinterchromeinsertttk徽标
1条回答
网友
1楼 · 发布于 2024-09-30 08:25:13

Photoimage不允许您打开图像而不是gif类型,如果您想在tkinter中打开图像而不是gif,请尝试PIL模块。您可以使用任何方法来安装PIL模块,我喜欢命令行

python -m pip install pillow

由于您希望您的图像在树状视图中的脚部,请使用此选项来调整大小并将其插入

^{pr2}$

相关问题 更多 >

    热门问题