Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #104122
| From | Wildman <best_lay@yahoo.com> |
|---|---|
| Subject | Re: Adding Icon To Tkinter Window |
| Newsgroups | comp.lang.python |
| References | <tIadnY8e89YQkEbLnZ2dnUU7-LHNnZ2d@giganews.com> <mailman.233.1457213922.20602.python-list@python.org> |
| Organization | Wildman Productions |
| Message-ID | <bKOdnR5Actb4VUbLnZ2dnUU7-IudnZ2d@giganews.com> (permalink) |
| Date | 2016-03-06 00:04 -0600 |
On Sat, 05 Mar 2016 16:38:08 -0500, Terry Reedy wrote: > On 3/5/2016 11:47 AM, Wildman via Python-list 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. > > No single simple statement work for all situations. You should have > specified OS, Python version, and tcl/tk version. (IDLE's Help -> About > IDLE displays full tk version). > > Here is the current code from idlelib.PyShell, written by Serhiy > Storchaka, our current tkinter maintainer. > > # set application icon > icondir = os.path.join(os.path.dirname(__file__), 'Icons') > if system() == 'Windows': > iconfile = os.path.join(icondir, 'idle.ico') > root.wm_iconbitmap(default=iconfile) > elif TkVersion >= 8.5: > ext = '.png' if TkVersion >= 8.6 else '.gif' > iconfiles = [os.path.join(icondir, 'idle_%d%s' % (size, ext)) > for size in (16, 32, 48)] > icons = [PhotoImage(file=iconfile) for iconfile in iconfiles] > root.wm_iconphoto(True, *icons) > > Non-windows pre-8.5 systems remain stuck with the tk icon. > > I just tried changing the 'if' line to 'if False:' on my 3.5.1 (8.6.4) > windows install and the 2nd, wm_iconphoto block worked here also. It > may be that it did not work on windows with 8.5 and before. I appreciate your reply. Your code looks interesting but it is over my head right now. I will save it for further study and experimentation. Right now my problem was fixed by using the code posted by Mr. Gollwitzer. -- <Wildman> GNU/Linux user #557453 The cow died so I don't need your bull!
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Adding Icon To Tkinter Window Wildman <best_lay@yahoo.com> - 2016-03-05 10:47 -0600
Re: Adding Icon To Tkinter Window Grant Edwards <invalid@invalid.invalid> - 2016-03-05 18:08 +0000
Re: Adding Icon To Tkinter Window Wildman <best_lay@yahoo.com> - 2016-03-05 12:47 -0600
Re: Adding Icon To Tkinter Window Rick Johnson <rantingrickjohnson@gmail.com> - 2016-03-09 08:39 -0800
Re: Adding Icon To Tkinter Window - Followup Wildman <best_lay@yahoo.com> - 2016-03-05 12:10 -0600
Re: Adding Icon To Tkinter Window - Followup Christian Gollwitzer <auriocus@gmx.de> - 2016-03-05 19:36 +0100
Re: Adding Icon To Tkinter Window - Followup Wildman <best_lay@yahoo.com> - 2016-03-05 23:53 -0600
Re: Adding Icon To Tkinter Window - Followup Christian Gollwitzer <auriocus@gmx.de> - 2016-03-06 10:16 +0100
Re: Adding Icon To Tkinter Window - Followup Wildman <best_lay@yahoo.com> - 2016-03-06 10:30 -0600
Re: Adding Icon To Tkinter Window - Followup Serhiy Storchaka <storchaka@gmail.com> - 2016-03-09 19:09 +0200
RE: Adding Icon To Tkinter Window - Followup Joaquin Alzola <Joaquin.Alzola@lebara.com> - 2016-03-09 17:14 +0000
Re: Adding Icon To Tkinter Window Mark Lawrence <breamoreboy@yahoo.co.uk> - 2016-03-05 18:38 +0000
Re: Adding Icon To Tkinter Window Wildman <best_lay@yahoo.com> - 2016-03-05 12:50 -0600
Re: Adding Icon To Tkinter Window Serhiy Storchaka <storchaka@gmail.com> - 2016-03-05 21:55 +0200
Re: Adding Icon To Tkinter Window Wildman <best_lay@yahoo.com> - 2016-03-05 23:56 -0600
Re: Adding Icon To Tkinter Window Terry Reedy <tjreedy@udel.edu> - 2016-03-05 16:38 -0500
Re: Adding Icon To Tkinter Window Wildman <best_lay@yahoo.com> - 2016-03-06 00:04 -0600
Re: Adding Icon To Tkinter Window Rick Johnson <rantingrickjohnson@gmail.com> - 2016-03-09 08:41 -0800
Re: Adding Icon To Tkinter Window Wildman <best_lay@yahoo.com> - 2016-03-06 00:09 -0600
csiph-web