简体   繁体   中英

How do you position a wx.MessageDialog (wxPython)?

Is there any reason why the position, pos, flag doesn't seem to work in the following example?

dlg = wx.MessageDialog(
    parent=self,
    message='You must enter a URL',
    caption='Error',
    style=wx.OK | wx.ICON_ERROR | wx.STAY_ON_TOP,
    pos=(200,200)
)

dlg.ShowModal()
dlg.Destroy()

The documentation is here: http://www.wxpython.org/docs/api/wx.MessageDialog-class.html

'self' is a reference to the frame. I'm running in Windows Vista, python26, wxpython28. The message dialog always appears to be in the middle of the screen.

If for some reason it's not possible to position the dialog, is there anyway to at least restrict the dialog to be in the frame, rather than just the center of the screen?

It seems to be a bug and i think you should file the same. for time being you can user your own dervied dialog class to center it as you wish. Also instead of wx.MessageDialog you can use wx.MessageBox, it will save you few lines.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM