开发者

help with changing icon of Tk window

root = Tk()


w=350
h=200

# get screen width and height
ws = root.winfo_screenwidth()
hs = root.winfo_screenheight()
    # calculate position x, y

x = (ws/2) - (w/2)
y = (hs/2) - (h/2)

root.geometry('%dx%d+%d+%d' % (w, h, x, y))

root.iconbitmap(default='images/account.gif')

Label(root, text='Window with transparent icon.').pack()

root.title("Create a window")

And I am getting error

File "Project.py", line 46, in <module>
root.iconbitmap(default='images/account.gif')
File "/usr/lib/开发者_运维问答python2.6/lib-tk/Tkinter.py", line 1523, in wm_iconbitmap
return self.tk.call('wm', 'iconbitmap', self._w, '-default', default)
_tkinter.TclError: wrong # args: should be "wm iconbitmap window ?bitmap?"

I also want to change the tray icon of Tk() window


You have to give it a bitmap argument, you can't just give it a default. Also, you can't use .gif as an image. It needs to be a .xbm, or I think a .ico on windows.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜