a problem about MessageDialog

Hi all,
Please look at this code below:
dlg=wx.MessageDialog(self, “请输入目的城市和出发城市”, “Info”, style = wx.OK|wx.ICON_INFORMATION, pos = wx.DefaultPosition)
dlg.SetFont(wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.NORMAL,False))
dlg.ShowModal()
dlg.Destroy()

I want to use SetFont() to set the font on MessageDialog, but it seems not work…Anybody has idea ?

4LGORITHM wrote:

Hi all,
Please look at this code below:
dlg=wx.MessageDialog(self, "请输入目的城市和出发城市", "Info", style =
wx.OK|wx.ICON_INFORMATION, pos = wx.DefaultPosition)
dlg.SetFont(wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.NORMAL,False))
dlg.ShowModal()
dlg.Destroy()

I want to use SetFont() to set the font on MessageDialog, but it seems
not work...Anybody has idea ?

The best way would be to just subclass wx.Dialog and make your dialog
from scratch. Then all it's components can be set up exactly as you
want. Otherwise you'll have to use a hack to get the MessageDialog's id
and use the FindWindowById() method to get a handle on the statictext
widget, which you then should be able to manipulate. I saw a post
showing a similar procedure yesterday or the day before. Check the archives.

···

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

Blog: http://blog.pythonlibrary.org
Python Extension Building Network: http://www.pythonlibrary.org

Thanks Mike, it works now1E3.gif

···

2009/1/13 Mike Driscoll mike@pythonlibrary.org

4LGORITHM wrote:

Hi all,

Please look at this code below:

dlg=wx.MessageDialog(self, “请输入目的城市和出发城市”, “Info”, style =

wx.OK|wx.ICON_INFORMATION, pos = wx.DefaultPosition)

dlg.SetFont(wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.NORMAL,False))

dlg.ShowModal()

dlg.Destroy()

I want to use SetFont() to set the font on MessageDialog, but it seems

not work…Anybody has idea ?

The best way would be to just subclass wx.Dialog and make your dialog

from scratch. Then all it’s components can be set up exactly as you

want. Otherwise you’ll have to use a hack to get the MessageDialog’s id

and use the FindWindowById() method to get a handle on the statictext

widget, which you then should be able to manipulate. I saw a post

showing a similar procedure yesterday or the day before. Check the archives.


Mike Driscoll

Blog: http://blog.pythonlibrary.org

Python Extension Building Network: http://www.pythonlibrary.org


wxpython-users mailing list

wxpython-users@lists.wxwidgets.org

http://lists.wxwidgets.org/mailman/listinfo/wxpython-users

4LGORITHM wrote:

Hi all,
    Please look at this code below:
            dlg=wx.MessageDialog(self, "请输入目的城市和出发城市",
"Info", style = wx.OK|wx.ICON_INFORMATION, pos = wx.DefaultPosition)
            dlg.SetFont(wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.NORMAL,False))
            dlg.ShowModal()
            dlg.Destroy()

I want to use SetFont() to set the font on MessageDialog, but it seems
not work...Anybody has idea ?

The wx.MessageDialog is not a true wx.Dialog but rather just a wrapper
around a system API function, so you are not able to have the any level
of control over things like layout, visual attributes, position, etc.
On the other hand, it's super simple to make your own generic dialog
that does the same thing but gives an opportunity for customizing or
subclassing. There's one here in fact:
http://trac.wxwidgets.org/browser/wxPython/3rdParty/AGW/agw/genericmessagedialog.py

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

soga~~ I got it. Thank you332.gif

···

2009/1/14 Robin Dunn robin@alldunn.com

4LGORITHM wrote:

Hi all,

Please look at this code below:
        dlg=wx.MessageDialog(self, "请输入目的城市和出发城市",

“Info”, style = wx.OK|wx.ICON_INFORMATION, pos = wx.DefaultPosition)

        dlg.SetFont(wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.NORMAL,False))
        dlg.ShowModal()
        dlg.Destroy()

I want to use SetFont() to set the font on MessageDialog, but it seems

not work…Anybody has idea ?

The wx.MessageDialog is not a true wx.Dialog but rather just a wrapper

around a system API function, so you are not able to have the any level

of control over things like layout, visual attributes, position, etc.

On the other hand, it’s super simple to make your own generic dialog

that does the same thing but gives an opportunity for customizing or

subclassing. There’s one here in fact:

http://trac.wxwidgets.org/browser/wxPython/3rdParty/AGW/agw/genericmessagedialog.py

Robin Dunn

Software Craftsman

http://wxPython.org Java give you jitters? Relax with wxPython!


wxpython-users mailing list

wxpython-users@lists.wxwidgets.org

http://lists.wxwidgets.org/mailman/listinfo/wxpython-users