Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #104108

Re: Adding Icon To Tkinter Window - Followup

Path csiph.com!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail
From Christian Gollwitzer <auriocus@gmx.de>
Newsgroups comp.lang.python
Subject Re: Adding Icon To Tkinter Window - Followup
Date Sat, 5 Mar 2016 19:36:19 +0100
Organization A noiseless patient Spider
Lines 28
Message-ID <nbf8pc$783$1@dont-email.me> (permalink)
References <tIadnY8e89YQkEbLnZ2dnUU7-LHNnZ2d@giganews.com> <qMKdnSPI4_llvUbLnZ2dnUU7-eOdnZ2d@giganews.com>
Mime-Version 1.0
Content-Type text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding 7bit
Injection-Date Sat, 5 Mar 2016 18:33:16 -0000 (UTC)
Injection-Info mx02.eternal-september.org; posting-host="09360e0ab07672f4bcf79b9f96c5414e"; logging-data="7427"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+RAj/J9NIQCYNLN0gJUVM1iDz3HwqGxZU="
User-Agent Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:38.0) Gecko/20100101 Thunderbird/38.6.0
In-Reply-To <qMKdnSPI4_llvUbLnZ2dnUU7-eOdnZ2d@giganews.com>
Cancel-Lock sha1:I4IsrkD4cQupamQYl6xzNPnBeNo=
Xref csiph.com comp.lang.python:104108

Show key headers only | View raw


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

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


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