[Tkinter-discuss] Application window icon on Linux
Michael Lange
klappnase at web.de
Thu Jun 7 19:01:32 CEST 2012
Hi Mark,
Thus spoketh Mark Summerfield <list at qtrac.plus.com>
unto us on Thu, 7 Jun 2012 17:18:25 +0100:
> This works perfectly on Windows 7. But on Linux (Debian & Ubuntu), I
> just get a default icon. The print() statement produces:
> @/home/mark/hello.xbm
I had to look twice myself, even if you showed the solution yourself in
the sentence above: of course os.path.isfile('@/home/mark/hello.xbm')
will always be False ;) If you change your set_icon() function to use a
simple try...except instead of additional tests as in
def set_icon(self, iconName):
windowSystem = self.master.tk.call("tk", "windowingsystem")
if windowSystem == "win32": # Windows
iconName += ".ico"
elif windowSystem == "x11": # Unix
iconName = "@" + iconName + ".xbm"
try:
self.master.iconbitmap(iconName)
except TclError:
pass
it should save you some headaches and (hopefully) work fine as long as
the bitmap file is present.
Regards
Michael
.-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-.
Without followers, evil cannot spread.
-- Spock, "And The Children Shall Lead", stardate 5029.5
More information about the Tkinter-discuss
mailing list