No icon under Windows 7 in a message dialog

383 views
Skip to first unread message

Boštjan Mejak

unread,
Oct 10, 2011, 7:09:58 PM10/10/11
to wxpytho...@googlegroups.com
There is no icon present in a message dialog if the style of a dialog
is constructed by using the flag wx.ICON_QUESTION and/or other
wx.ICON_* flags. How come?

werner

unread,
Oct 11, 2011, 3:13:40 AM10/11/11
to wxpytho...@googlegroups.com
Works for me in wxPython demo - Win7, Py2.7 and wxPython 2.9.2.4

Werner

Boštjan Mejak

unread,
Oct 11, 2011, 7:07:04 AM10/11/11
to wxpytho...@googlegroups.com
I noted something interesting... If I enclose the code of the message
dialog in a "with" statement, I don't get that icon shown; but if I
don't use the "with" statement, the icon is shown. So now I ask you,
is that a bug in wxPython?

with wx.MessageDialog(self,
caption='Exit Confirmation',
message='Do you want to exit the
application?',
style=wx.YES_NO | wx.ICON_QUESTION) \
as dialog:
if dialog.ShowModal() == wx.ID_YES:
self.Destroy()

I love the "with" statement because it automatically takes care of the
destruction of the message dialog and eliminates any memory leaks that
way. Anyway, my code worked (i.e. displayed an icon in the message
dialog) in the 2.8 version of wxPython, but it does not do the same
thing under 2.9. What should I do different to make this work?

Robin Dunn

unread,
Oct 11, 2011, 12:39:04 PM10/11/11
to wxpytho...@googlegroups.com
On 10/11/11 4:07 AM, Bo�tjan Mejak wrote:
> I noted something interesting... If I enclose the code of the message
> dialog in a "with" statement, I don't get that icon shown; but if I
> don't use the "with" statement, the icon is shown.

Are you sure about that? Try it with the attached sample.

> So now I ask you,
> is that a bug in wxPython?

No. On Windows 7 wx is able to use a new native dialog for the message
dialog implementation, called the task dialog. This is done to help
conform to new platform standards and to give it a more up to date look
and feel. (This same native dialog is also used for wx.ProgressDialog
if I remember correctly.) Apparently the native task dialog does not
have an equivalent for wx.ICON_QUESTION, but it does for ERROR, WARNING,
and INFORMATION. See
http://msdn.microsoft.com/en-us/library/bb760540(VS.85).aspx


--
Robin Dunn
Software Craftsman
http://wxPython.org

msgdlg.py

Boštjan Mejak

unread,
Oct 11, 2011, 1:21:25 PM10/11/11
to wxpytho...@googlegroups.com
The native task dialog does not have an equivalent for wx.ICON_QUESTION, but it does for ERROR, WARNING, and INFORMATION.
You are absolutely right. So how can I fix this? 

Cody

unread,
Oct 11, 2011, 1:34:56 PM10/11/11
to wxpytho...@googlegroups.com
Hi,

There is nothing to fix. The new ui doesn't have a question icon dialog.

If you want one with a question icon you can try using the
GenericMessageDialog in wx.lib.agw.


Cody

Robin Dunn

unread,
Oct 11, 2011, 1:37:59 PM10/11/11
to wxpytho...@googlegroups.com

Choose one:

a. live with it as-is
b. choose a different icon style
c. make your own custom dialog class
d. use a generic message dialog from wx.lib.agw or wx.lib.dialogs

Boštjan Mejak

unread,
Oct 11, 2011, 1:55:26 PM10/11/11
to wxpytho...@googlegroups.com
Well, Robin, I obviously can't choose a different icon style. Since my message dialog is of a "question" nature, I can't choose some other icon. It would be nice if you could hack wxPython in a way to make the icon appear. Is that theoretically possible?

Robin Dunn

unread,
Oct 11, 2011, 2:53:17 PM10/11/11
to wxpytho...@googlegroups.com

In theory anything is possible. In reality, no.

Mike Driscoll

unread,
Oct 11, 2011, 3:04:33 PM10/11/11
to wxpytho...@googlegroups.com
Why not just roll your own wx.Dialog that looks like a wx.MessageDialog? Or what about using the GenericMessageDialog (from wx.lib.agw.genericmessagedialog) ?

-------------------
Mike Driscoll

Blog:   http://blog.pythonlibrary.org

Tim Roberts

unread,
Oct 11, 2011, 6:28:05 PM10/11/11
to wxpytho...@googlegroups.com
Bo�tjan Mejak wrote:
Well, Robin, I obviously can't choose a different icon style. Since my message dialog is of a "question" nature, I can't choose some other icon. It would be nice if you could hack wxPython in a way to make the icon appear. Is that theoretically possible?

I'm not sure you see the point here.� The Microsoft user interface gurus have determined that the "question mark" icon is more confusing to users than helpful.� Perhaps that's because their user interface studies told them users were frightened by it, or overreacted to it, or perhaps it's because of some complicated international connotation attached to the ? symbol -- I don't know the exact reason.� But the point is that you aren't supposed to use the "question mark" icon any more.� No other applications on Windows 7 are going to show it either, and you want your app to look familiar.
-- 
Tim Roberts, ti...@probo.com
Providenza & Boekelheide, Inc.

Boštjan Mejak

unread,
Oct 12, 2011, 8:56:37 AM10/12/11
to wxpytho...@googlegroups.com
Very well put. Thank you very much, sir.
Reply all
Reply to author
Forward
0 new messages