473,414 Members | 1,781 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

Tkinter, iconbitmap and Windows XP

Hi all,

I have been attempting to change the title bar icon of my Tkinter
applications in Windows XP. Chasing round in google, I discovered:
- This is a common difficulty.
- There aren't any good answers.

Eventually, I stumbled across a link to this:
http://www.tcl.tk/man/tcl8.4/TkCmd/wm.htm#M18

Here is the significant information:
"On the Windows operating system, an additional flag is supported: wm
iconbitmap window ?-default? ?image?. If the -default flag is given,
the icon is applied to all toplevel windows (existing and future) to
which no other specific icon has yet been applied. In addition to
bitmap image types, a full path specification to any file which
contains a valid Windows icon is also accepted (usually .ico or .icr
files), or any file for which the shell has assigned an icon. Tcl will
first test if the file contains an icon, then if it has an assigned
icon, and finally, if that fails, test for a bitmap."

The Tkinter source (Python 2.3.4) includes this:

def wm_iconbitmap(self, bitmap=None):
"""Set bitmap for the iconified widget to BITMAP. Return
the bitmap if None is given."""
return self.tk.call('wm', 'iconbitmap', self._w, bitmap)

I modified this, to look like:

def wm_iconbitmap(self, bitmap=None, default=None):
"""Set bitmap for the iconified widget to BITMAP. Return
the bitmap if None is given."""
if default:
return self.tk.call('wm', 'iconbitmap', self._w,
'-default', default)
else:
return self.tk.call('wm', 'iconbitmap', self._w, bitmap)

The following code now does exactly what you would like it to:

#####
from Tkinter import *

tk = Tk()
tk.iconbitmap(default='foo.ico')
Label(tk, text='This window now has a custom icon.').pack()

t = Toplevel(tk)
Label(t, text='This one has the same custom icon.').pack()

tk.mainloop()
#####

I hope this is helpful to people...

(now to see if I can figure out how to submit a patch in Sourceforge)

--
John.
Jul 18 '05 #1
0 2064

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: John Benson | last post by:
Hi, I'm using Tkinter and would like to know how to replace the red "Tk" logo in the left corner of the title bar of the root window with some other icon. Another question for curiosity's sake:...
2
by: klappnase | last post by:
Hello everyone, I have seen several threads here on this problem, but still cannot figure out the solution. I want to create a window icon for a Tkinter application and tried several things that...
1
by: corrado | last post by:
Hello I have an application running several thread to display some financial data; basically I have a thread displaying HTML tables by means of Tkhtml, another implementing a scrolling ticker...
4
by: Tim Jarman | last post by:
Apologies in advance for the long post - I wanted to be sure I included all the relevant details. The answer is probably very, very simple. I am doing something stupid here, but I don't know what...
5
by: mzdude | last post by:
I've just started playing with Python. Installed 2.5 on Windows XP system. I'm working through some of the examples in Programming Python 3ed by Mark Lutz. Given the following example when the Quit...
7
by: krishnakant Mane | last post by:
hello all, I seam to have noticed this a bit late but it appears to me that tkinter is being used very widely for gui development on all platform? is that right? since fredric lundh has written a...
13
by: Daniel Fetchinson | last post by:
Was looking at PEP 3108, http://www.python.org/dev/peps/pep-3108/ , Is it just me or others also think that it would be a major loss to remove tkinter from the python core? PEP 3108 starts off...
7
by: Protected | last post by:
Hello. I'm a complete newbie trying to learn Python. I decided to try some Tkinter examples, including the one from the library reference, but they don't seem to do anything! Shouldn't there be,...
3
by: J-Burns | last post by:
Hello. Im a bit new to using Tkinter and im not a real pro in programming itself... :P. Need some help here. Problem 1: How do I make something appear on 2 separate windows using Tkinter? By...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.