Can a modal dialog be moved with .Move()

Is it possible to move a modal dialog with wxWindow.Move() or wxWindow.MoveXY()? It does not seem to work in this:

def warn(frame, captionBarString, warningMessage) :
     """Show a warning dialog."""
     x,y = frame.GetPositionTuple()
     print "X = %d, Y= %d" % (x,y)
     dlg = wx.MessageDialog(frame, warningMessage , captionBarString, wx.ICON_ERROR)
     dlg.MoveXY(x+10,y+10)
     dlg.ShowModal()
     dlg.Destroy()

Thanks

Pierre

Pierre Rouleau wrote:

Is it possible to move a modal dialog with wxWindow.Move() or wxWindow.MoveXY()? It does not seem to work in this:

def warn(frame, captionBarString, warningMessage) :
    """Show a warning dialog."""
    x,y = frame.GetPositionTuple()
    print "X = %d, Y= %d" % (x,y)
    dlg = wx.MessageDialog(frame, warningMessage , captionBarString, wx.ICON_ERROR)
    dlg.MoveXY(x+10,y+10)
    dlg.ShowModal()
    dlg.Destroy()

In this case, why not just use the pos argument to the MessageDialog contructor?

David

David C. Fox wrote:

Pierre Rouleau wrote:

Is it possible to move a modal dialog with wxWindow.Move() or wxWindow.MoveXY()? It does not seem to work in this:

def warn(frame, captionBarString, warningMessage) :
    """Show a warning dialog."""
    x,y = frame.GetPositionTuple()
    print "X = %d, Y= %d" % (x,y)
    dlg = wx.MessageDialog(frame, warningMessage , captionBarString, wx.ICON_ERROR)
    dlg.MoveXY(x+10,y+10)
    dlg.ShowModal()
    dlg.Destroy()

In this case, why not just use the pos argument to the MessageDialog contructor?

Yep! So obvious! Thnaks for the answer, and sorry for the stupid question.

Pierre

Pierre Rouleau wrote:

David C. Fox wrote:

Pierre Rouleau wrote:

Is it possible to move a modal dialog with wxWindow.Move() or wxWindow.MoveXY()? It does not seem to work in this:

def warn(frame, captionBarString, warningMessage) :
    """Show a warning dialog."""
    x,y = frame.GetPositionTuple()
    print "X = %d, Y= %d" % (x,y)
    dlg = wx.MessageDialog(frame, warningMessage , captionBarString, wx.ICON_ERROR)
    dlg.MoveXY(x+10,y+10)
    dlg.ShowModal()
    dlg.Destroy()

In this case, why not just use the pos argument to the MessageDialog contructor?

Yep! So obvious! Thnaks for the answer, and sorry for the stupid question.

Not so obvious after all:

def warn(frame, captionBarString, warningMessage) :
     """Show a warning dialog."""
     x,y = frame.GetPositionTuple()
     print "X = %d, Y= %d" % (x,y)
     dlg = wx.MessageDialog(frame, warningMessage , captionBarString, wx.ICON_ERROR, pos=wx.Point(x+10,y+10))
     dlg.ShowModal()
     dlg.Destroy()

This does NOT work under Windows. It works in other platforms, but not windows (as stated in the wxWindows manual).

So the question remains: is it possible to move a modal dialog under Windows?

Pierre Rouleau wrote:

David C. Fox wrote:

Pierre Rouleau wrote:

Is it possible to move a modal dialog with wxWindow.Move() or wxWindow.MoveXY()? It does not seem to work in this:

def warn(frame, captionBarString, warningMessage) :
    """Show a warning dialog."""
    x,y = frame.GetPositionTuple()
    print "X = %d, Y= %d" % (x,y)
    dlg = wx.MessageDialog(frame, warningMessage , captionBarString, wx.ICON_ERROR)
    dlg.MoveXY(x+10,y+10)
    dlg.ShowModal()
    dlg.Destroy()

In this case, why not just use the pos argument to the MessageDialog contructor?

Yep! So obvious! Thnaks for the answer, and sorry for the stupid question.

Pierre

No problem. By the way, MoveXY does seem to work once the dialog is shown.

David

Pierre Rouleau wrote:

Pierre Rouleau wrote:

David C. Fox wrote:

Pierre Rouleau wrote:

Is it possible to move a modal dialog with wxWindow.Move() or wxWindow.MoveXY()? It does not seem to work in this:

def warn(frame, captionBarString, warningMessage) :
    """Show a warning dialog."""
    x,y = frame.GetPositionTuple()
    print "X = %d, Y= %d" % (x,y)
    dlg = wx.MessageDialog(frame, warningMessage , captionBarString, wx.ICON_ERROR)
    dlg.MoveXY(x+10,y+10)
    dlg.ShowModal()
    dlg.Destroy()

In this case, why not just use the pos argument to the MessageDialog contructor?

Yep! So obvious! Thnaks for the answer, and sorry for the stupid question.

Not so obvious after all:

def warn(frame, captionBarString, warningMessage) :
    """Show a warning dialog."""
    x,y = frame.GetPositionTuple()
    print "X = %d, Y= %d" % (x,y)
    dlg = wx.MessageDialog(frame, warningMessage , captionBarString, wx.ICON_ERROR, pos=wx.Point(x+10,y+10))
    dlg.ShowModal()
    dlg.Destroy()

This does NOT work under Windows. It works in other platforms, but not windows (as stated in the wxWindows manual).

So the question remains: is it possible to move a modal dialog under Windows?

Oops - I should have read the manual more closely, or tried it with a wxMessageDialog instead of a generic modal dialog. Looking at the MSWindows code for wxMessageDialog (msgdlg.cpp), I see that it is implemented in terms of the MSW *function* MessageBox, which seems to be the source of the limitation on specifying a position or moving the window.

However, it does work fine for an ordinary wxDialog, so you could get the same effect by writing your own subclass of wxDialog to show the message. Apart from getting the icon to look like the native one, that shouldn't be to difficult.

David C. Fox wrote:

Pierre Rouleau wrote:

Pierre Rouleau wrote:

David C. Fox wrote:

Pierre Rouleau wrote:

Is it possible to move a modal dialog with wxWindow.Move() or wxWindow.MoveXY()? It does not seem to work in this:

def warn(frame, captionBarString, warningMessage) :
    """Show a warning dialog."""
    x,y = frame.GetPositionTuple()
    print "X = %d, Y= %d" % (x,y)
    dlg = wx.MessageDialog(frame, warningMessage , captionBarString, wx.ICON_ERROR)
    dlg.MoveXY(x+10,y+10)
    dlg.ShowModal()
    dlg.Destroy()

In this case, why not just use the pos argument to the MessageDialog contructor?

Yep! So obvious! Thnaks for the answer, and sorry for the stupid question.

Not so obvious after all:

def warn(frame, captionBarString, warningMessage) :
    """Show a warning dialog."""
    x,y = frame.GetPositionTuple()
    print "X = %d, Y= %d" % (x,y)
    dlg = wx.MessageDialog(frame, warningMessage , captionBarString, wx.ICON_ERROR, pos=wx.Point(x+10,y+10))
    dlg.ShowModal()
    dlg.Destroy()

This does NOT work under Windows. It works in other platforms, but not windows (as stated in the wxWindows manual).

So the question remains: is it possible to move a modal dialog under Windows?

Oops - I should have read the manual more closely, or tried it with a wxMessageDialog instead of a generic modal dialog. Looking at the MSWindows code for wxMessageDialog (msgdlg.cpp), I see that it is implemented in terms of the MSW *function* MessageBox, which seems to be the source of the limitation on specifying a position or moving the window.

However, it does work fine for an ordinary wxDialog, so you could get the same effect by writing your own subclass of wxDialog to show the message. Apart from getting the icon to look like the native one, that shouldn't be to difficult.

Agreed. Thanks

Pierre Rouleau wrote:

So the question remains: is it possible to move a modal dialog under Windows?

Yes, but the standard "common dialogs" are not real wxDialogs, but just a wrapper around an API function, so you don't have as much control. If you need to position the wxMessageDialog then you will need to create your own generic version of it.

···

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