如何使用 URL 设置 tkinter 应用程序图标?

编程入门 行业动态 更新时间:2024-10-28 07:20:44
本文介绍了如何使用 URL 设置 tkinter 应用程序图标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

如果我有:

from Tkinter import *
app = Tk()

...

app.mainloop()

我会使用 app.iconbitmap(...) 吗?

如果是这样,我将如何使用 this 作为文件,我应该导入 urllib 吗?

And if so, how would I go about using this as the file, and should I import urllib?

推荐答案

您也可以使用它来替换 Tkinter 默认图标.

You can use this too replace the Tkinter default icon.

import base64, PIL, urllib, Tkinter
from Tkinter import *
from PIL import ImageTk
from urllib import *

root = Tk()

raw_data = urllib.urlopen("http://dl.dropboxusercontent/s/qtlincxkbbiz1qv/stat.gif").read()

b64_data = base64.encodestring(raw_data)
image = PhotoImage(data=b64_data)

root.tk.call('wm', 'iconphoto', root._w, image)

root.mainloop()

然后将 .py 文件扩展名更改为 .pyw 以更改任务栏图标.

And then change the .py file extension to .pyw to change the taskbar icon.

.pyw 扩展告诉它使用 pythonw.exe 而不是 python.exe 运行,而是使用 pythonw 运行.exe 也让它在没有控制台的情况下运行.

The .pyw extension tells it to run with pythonw.exe instead of python.exe, but running with pythonw.exe also makes it run without the console.

因此,您要么在没有图标的情况下运行,要么在没有控制台的情况下运行.

So, you'll either have to run without the icon, or without the console.

这篇关于如何使用 URL 设置 tkinter 应用程序图标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-04-30 08:59:41,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1392039.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何使用   应用程序   图标   tkinter   URL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!