This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2012年06月26日 07:19 by mark, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Messages (7) | |||
|---|---|---|---|
| msg164053 - (view) | Author: Mark Summerfield (mark) * | Date: 2012年06月26日 07:19 | |
The tkinter.messagebox functions, e.g., askyesno(), do not use the application's icon (if it has one). Nor do they accept a bitmapicon option, so ISTM that it is "impossible" to set one. The same is true of tkinter.dialog, but for that it is easy enough to write one's own replacement with the code like this: try: tkinter._default_root.iconbitmap(iconName) except tk.TclError as err: print(err) (where iconName is "path/to/icon.ico" on windows, "@path/to/icon.xbm" on Unix; and this isn't done on Mac). |
|||
| msg164443 - (view) | Author: Terry J. Reedy (terry.reedy) * (Python committer) | Date: 2012年07月01日 01:15 | |
It is not clear to me what change your are proposing. |
|||
| msg165069 - (view) | Author: Mark Summerfield (mark) * | Date: 2012年07月09日 07:42 | |
On Linux & Windows every top-level window (including dialogs) normally has an icon at the left of the title bar. Typically this icon is the application's icon. But tkinter doesn't provide such an icon and so a system default icon is used instead. For one's own code this can be fixed by using the iconbitmap() function, but for the tkinter convenience dialogs (e.g., askyesno()), this cannot be done. So, my suggestion is to make the convenience dialogs use the same icon as the application (if the application has one). |
|||
| msg165073 - (view) | Author: Drew French (Drew.French) | Date: 2012年07月09日 08:42 | |
This is also true for some of the other dialogs (such as the file dialogs). Does anyone know if this behavior can be changed in Tk itself? |
|||
| msg165290 - (view) | Author: Mark Summerfield (mark) * | Date: 2012年07月12日 09:06 | |
I think there is a solution to this that can be applied in one's own code:
app = tkinter.Tk()
icon = tkinter.PhotoImage(file="icon.gif")
app.tk.call("wm", "iconphoto", app, "-default", icon)
According to the docs (and it seems to be true), the icon thus set will be used for *all* the applications top-level windows.
|
|||
| msg209429 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) | Date: 2014年01月27日 10:22 | |
Mark's recipe works pretty well (requires Tk 8.5+). And you can use special method for this: app.wm_iconphoto(True, icon). What we can made more? We can set Python-related application icon for IDLE (issue20406). But for user applications their authors are responsible to configure properly icons. |
|||
| msg209499 - (view) | Author: Terry J. Reedy (terry.reedy) * (Python committer) | Date: 2014年01月28日 02:22 | |
After applying the .wm_iconphoto patch, I verifies that the icon specified is used for the options dialog and an ask file name message box opened by the dialog. In other words, dialogs and boxes *do* use the application title bar icon if one is provided. So I consider that existing method to be the feature requested, or at least as much of it as is sensible for tkinter. Title bar icons are 16x16. Desktop icons are much bigger. While large icons can be scaled down, the result will not necessarily be satisfactory. For instance, the Python console app has separate large and small icons. I claim on #20406 that Idle should also. In any case, automatic cross-platform access to and downscaling of a large desk icon to a small title icon should be done by tk, if at all. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:32 | admin | set | github: 59394 |
| 2014年01月28日 02:22:19 | terry.reedy | set | status: open -> closed resolution: works for me messages: + msg209499 stage: resolved |
| 2014年01月27日 10:22:27 | serhiy.storchaka | set | messages: + msg209429 |
| 2014年01月27日 07:09:30 | terry.reedy | set | nosy:
+ serhiy.storchaka |
| 2012年07月12日 09:06:50 | mark | set | messages: + msg165290 |
| 2012年07月09日 08:42:51 | Drew.French | set | nosy:
+ Drew.French messages: + msg165073 |
| 2012年07月09日 07:42:47 | mark | set | messages: + msg165069 |
| 2012年07月01日 01:15:31 | terry.reedy | set | versions:
+ Python 3.4, - Python 3.2 nosy: + gpolo, terry.reedy messages: + msg164443 type: enhancement |
| 2012年06月26日 07:19:48 | mark | create | |