Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to get tkinter messagebox icon image files?

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 !

like image 351
dlesbre Avatar asked Jun 13 '16 07:06

dlesbre


People also ask

How do I change my python GUI icon?

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.

What is Tkinter Messagebox in Python?

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.

How do you show error box in Python?

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.


1 Answers

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.

like image 121
Brad Lanam Avatar answered Oct 15 '22 10:10

Brad Lanam