RE: Adding Icon To Tkinter Window - Followup
> root.wm_iconphoto(True, img) What are the images format allowed? This email is confidential and may be subject to privilege. If you are not the intended recipient, please do not copy or disclose its content but contact the sender immediately upon receipt. -- https://mail.python.org/mailman/listinfo/python-list
Re: Adding Icon To Tkinter Window - Followup
On 06.03.16 18:30, Wildman via Python-list wrote: That does not work... $ ./makexface.py Traceback (most recent call last): File "./makexface.py", line 236, in root.wm_iconphoto(True, img) File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1897, in __getattr__ return getattr(self.tk, attr) AttributeError: wm_iconphoto This works in Python 3.x. In 2.7 you should use root.tk.call('wm', 'iconphoto', str(root), '-default', img, ...) Note that it is worth to specify images for several different sizes (up to 128x128 for OS X). -- https://mail.python.org/mailman/listinfo/python-list
Re: Adding Icon To Tkinter Window - Followup
On Sun, 06 Mar 2016 10:16:55 +0100, Christian Gollwitzer wrote: > Am 06.03.16 um 06:53 schrieb Wildman: >> On Sat, 05 Mar 2016 19:36:19 +0100, Christian Gollwitzer wrote: >>> import Tkinter >>> from Tkinter import Tk >>> root = Tk() >>> img = Tkinter.Image("photo", file="appicon.gif") >>> root.call('wm','iconphoto',root._w,img) >> >> The above worked perfectly. Thank you very much. > > Then you should try if it works also with the last line replaced as > > root.wm_iconphoto(True, img) That does not work... $ ./makexface.py Traceback (most recent call last): File "./makexface.py", line 236, in root.wm_iconphoto(True, img) File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1897, in __getattr__ return getattr(self.tk, attr) AttributeError: wm_iconphoto > (as Serhiy and Terry wrote). My system python which I used to test this > was just too old to wrap iconphoto, yours should be up to date. > > Christian > > >> According to "root.eval('info patchlevel')" I have version 8.6.2. >> PNG worked. That is good because PNG is a common file type for >> Linux icons. > > PS: 8.6.2 is from mid 2014, that's OK - though we've had a brand new > release (8.6.5) in February 2016 I am using the latest release that is offered in the Debian repository but I will look into upgrading from other sources. Thanks for the info. -- GNU/Linux user #557453 The cow died so I don't need your bull! -- https://mail.python.org/mailman/listinfo/python-list
Re: Adding Icon To Tkinter Window - Followup
Am 06.03.16 um 06:53 schrieb Wildman: On Sat, 05 Mar 2016 19:36:19 +0100, Christian Gollwitzer wrote: import Tkinter from Tkinter import Tk root = Tk() img = Tkinter.Image("photo", file="appicon.gif") root.call('wm','iconphoto',root._w,img) The above worked perfectly. Thank you very much. Then you should try if it works also with the last line replaced as root.wm_iconphoto(True, img) (as Serhiy and Terry wrote). My system python which I used to test this was just too old to wrap iconphoto, yours should be up to date. Christian According to "root.eval('info patchlevel')" I have version 8.6.2. PNG worked. That is good because PNG is a common file type for Linux icons. PS: 8.6.2 is from mid 2014, that's OK - though we've had a brand new release (8.6.5) in February 2016 -- https://mail.python.org/mailman/listinfo/python-list
Re: Adding Icon To Tkinter Window - Followup
On Sat, 05 Mar 2016 19:36:19 +0100, Christian Gollwitzer wrote: > Am 05.03.16 um 19:10 schrieb Wildman: >> On Sat, 05 Mar 2016 10:47:09 -0600, Wildman wrote: >> >>> Anybody have the correct method of adding an icon to a >>> window? I have found several code examples on the web >>> but they all result in an error. Thanks. >> >> I found this and it works in Linux but only with black >> and white xbm images (I would prefer color): >> >> root.wm_iconbitmap('@myicon.xbm') > > iconphoto is the newer API for color icons. I am a bit surprised that it > is not wrapped in Tkinter, which is odd. You can still call it via eval: > > import Tkinter > from Tkinter import Tk > root = Tk() > img = Tkinter.Image("photo", file="appicon.gif") > root.call('wm','iconphoto',root._w,img) The above worked perfectly. Thank you very much. > If you Tk is recent enough (8.6, you can find out by doing > root.eval('info patchlevel')), you can use .png files in addition to > .gif. If you need to read other image files, look into PIL and ImageTk. > > Christian According to "root.eval('info patchlevel')" I have version 8.6.2. PNG worked. That is good because PNG is a common file type for Linux icons. -- GNU/Linux user #557453 The cow died so I don't need your bull! -- https://mail.python.org/mailman/listinfo/python-list
Re: Adding Icon To Tkinter Window - Followup
Am 05.03.16 um 19:10 schrieb Wildman: On Sat, 05 Mar 2016 10:47:09 -0600, Wildman wrote: Anybody have the correct method of adding an icon to a window? I have found several code examples on the web but they all result in an error. Thanks. I found this and it works in Linux but only with black and white xbm images (I would prefer color): root.wm_iconbitmap('@myicon.xbm') iconphoto is the newer API for color icons. I am a bit surprised that it is not wrapped in Tkinter, which is odd. You can still call it via eval: import Tkinter from Tkinter import Tk root = Tk() img = Tkinter.Image("photo", file="appicon.gif") root.call('wm','iconphoto',root._w,img) If you Tk is recent enough (8.6, you can find out by doing root.eval('info patchlevel')), you can use .png files in addition to .gif. If you need to read other image files, look into PIL and ImageTk. Christian -- https://mail.python.org/mailman/listinfo/python-list
Re: Adding Icon To Tkinter Window - Followup
On Sat, 05 Mar 2016 10:47:09 -0600, Wildman wrote: > Anybody have the correct method of adding an icon to a > window? I have found several code examples on the web > but they all result in an error. Thanks. I found this and it works in Linux but only with black and white xbm images (I would prefer color): root.wm_iconbitmap('@myicon.xbm') I found some info in a forum that talked about putting a color icon in a Label on a separate window and passing that to the main window as the icon. But there were no code examples or explanations. So far I have not been able to figure it out. I would appreciate any help. -- GNU/Linux user #557453 "Be at war with your vices, at peace with your neighbors, and let every new year find you a better man." -Benjamin Franklin -- https://mail.python.org/mailman/listinfo/python-list