2011-03-18 85 views
4
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") 

而且我得到错误帮助,改变Tk的窗口的图标

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?" 

我也想改变Tk()窗口

回答

2

的托盘图标你必须给它一个bitmap的说法,你不能只给它一个default。另外,您不能将.gif用作图像。它需要是.xbm,或者我认为在Windows上是一个.ico。

+1

“.ico”适用于Windows。 – Moshe 2013-10-15 14:17:33