Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/python-2.7/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何设置图标并更新tkinter窗口的标题?_Python_Python 2.7_Tkinter - Fatal编程技术网

Python 如何设置图标并更新tkinter窗口的标题?

Python 如何设置图标并更新tkinter窗口的标题?,python,python-2.7,tkinter,Python,Python 2.7,Tkinter,我正试图制作一个小程序,以便更好地理解tkinter在python中的工作原理 因此,我想知道如何设置图标并更新tkinter窗口的标题 我已经写了下面的代码,有人能建议我如何在这个脚本中实现上面的功能吗 from Tkinter import * import Tkinter as Tk import ttk class Test(Tk.Tk): def __init__(self, *args, **kwargs): Tk.Tk.__init__(self, *ar

我正试图制作一个小程序,以便更好地理解tkinter在python中的工作原理

因此,我想知道如何设置图标并更新tkinter窗口的标题

我已经写了下面的代码,有人能建议我如何在这个脚本中实现上面的功能吗

from Tkinter import *
import Tkinter as Tk
import ttk

class Test(Tk.Tk):
    def __init__(self, *args, **kwargs):
        Tk.Tk.__init__(self, *args, **kwargs)

app = Test()
app.state("zoomed")
app.mainloop()
# I'm having problems with this could I get any help?
app.wm_iconbitmap('xxxxxxx.ico')
app.title('Vikings Lore')

您可以使用以下代码段设置tkinter窗口的标题:

from tkinter import *

root = Tk()

root.wm_title("Hello, world")
from tkinter import *

root = Tk()

root.iconbitmap("icon.ico")
这将根窗口的标题设置为
Hello,world
。 对于图标,可以使用以下代码段进行设置:

from tkinter import *

root = Tk()

root.wm_title("Hello, world")
from tkinter import *

root = Tk()

root.iconbitmap("icon.ico")
这将根窗口的图标设置为文件
icon.ico

如果您在tkinter方面需要进一步的基本帮助,那么Kinter是您最好的朋友。

对于Linux(为我工作),您还需要在字符串开头添加“@”:

app_icon = '/home/user/icons/number-three_66512.XBM'
root.iconbitmap('@' + app_icon)

如果出现错误
\u tkinter.TclError:读取位图文件时出错
请使用XBM格式而不是ICO。

请将代码以文本形式发布,而不是图像形式发布。您向谷歌询问过此问题吗?任何基础教程都应该涵盖这一点。不要再说了,不,你真的毫无疑问,头衔不够!代码或汽车的两张图片是完全相同的。使用按钮使问题可读!好的,现在你已经通过电子邮件向他发送了一段代码。你想做一个描述性的句子来帮助他理解你的要求吗。因为这是一个繁忙的学院,你知道如果没有至少155个字符的描述,你的邮件将被忽略。