Reputation: 171
I am writing a program using tkinter, and have successfully managed to use a colour icon for my program using code that looks like this:
from tkinter import *
tk = Tk()
root.tk.call('wm', 'iconbitmap', self._w, '-default', 'iconfile.ico')
However, when I create a simple dialog, it has the default tkinter icon. I have tried setting the parent to my main window, but the icon is still the default one.
How could the icon be set to not be the default one?
Upvotes: 1
Views: 1166
Reputation: 171
Got an answer from a user on another site:
It's not a configurable option in the class. You'll need to make a subclass which sets the icon:
class StringDialog(simpledialog._QueryString):
def body(self, master):
super().body(master)
self.iconbitmap('icon.ico')
def ask_string(title, prompt, **kargs):
d = StringDialog(title, prompt, **kargs)
return d.result
You'll also need to subclass _QueryFloat and _QueryInteger if you want those versions. (These classes are supposed to be private, so you might have to fix this in future updates.)
Upvotes: 4