I'm developing a python/tkinter application, and finding the default messagebox lacked flexibility, I programmed my own using Toplevel
.
I was rather successful in recreating the messabox appearance, however, I could not find a way to obtain the icons displayed in normal tkinter messagebox (i.e. : error, warning, info icons...)
I did some research didn't find much, except that those image were stored in a win32 DLL file... Also tried looking into the tkinter messagebox module code, but its only an interface transferring from python to TCL code I can't find (and probably wouldn't be able to read anyway...)
Is there anyway to get files or rough equivalents (PhotoImage
objects) for these icons using either python or TCL executed though Tk().tk.call()
?
Or any other (thourghly explained then) way to achieve this?
Right now the best solution I can think of is to use screencapture, and save the icons to files, but I'd rather be able to access the original ones...
Thanks in advance !
iconphoto() method in Tkinter | Python iconphoto() method is used to set the titlebar icon of any tkinter/toplevel window. But to set any image as the icon of titlebar, image should be the object of PhotoImage class. Set the titlebar icon for this window based on the named photo images passed through args.
The tkMessageBox module is used to display message boxes in your applications. This module provides a number of functions that you can use to display an appropriate message. Some of these functions are showinfo, showwarning, showerror, askquestion, askokcancel, askyesno, and askretryignore.
Build A Paint Program With TKinter and Python If you need to display the error messagebox in your application, you can use showerror("Title", "Error Message") method. This method can be invoked with the messagebox itself.
The rough equivalents are available as (tk global variables):
::tk::icons::warning
::tk::icons::error
::tk::icons::information
::tk::icons::question
Like anything that is not documented, it is subject to change in the future, but these should be stable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With