wx.MessageBox Strange Behaviour

Hi All,
Coding an application on OS X, and trying to use wx.MessageBox to provide a simple yes / no prompt. Only thing is, it always returns 16 (which is wx.CANCEL). I define the message box like this:

dlg = wx.MessageBox(‘Are you sure you want to delete %s - %s from this playlist?’ % (track.get(‘track’, {}).get(‘artist’, ‘Unknown Artist’), track.get(‘track’, {}).get(‘title’, ‘Unknown Track’)), ‘Really delete’, style = wx.YES_NO)

I tried using wx.MessageDialog as well, but ShowModal always returned 0 for some reason.

I’m using wx.SingleSeleccDialog a lot elsewhere in the application, and that’s working fine. Any reason this is screwing up?

Cheers in advance.

Take care,

Chris Norman

chris.norman2@googlemail.com

What versions of python and wxPython are you using?

David

···

On May 15, 2015 3:26 PM, “Chris Norman” chris.norman2@googlemail.com wrote:

Hi All,
Coding an application on OS X, and trying to use wx.MessageBox to provide a simple yes / no prompt. Only thing is, it always returns 16 (which is wx.CANCEL). I define the message box like this:

dlg = wx.MessageBox(‘Are you sure you want to delete %s - %s from this playlist?’ % (track.get(‘track’, {}).get(‘artist’, ‘Unknown Artist’), track.get(‘track’, {}).get(‘title’, ‘Unknown Track’)), ‘Really delete’, style = wx.YES_NO)

I tried using wx.MessageDialog as well, but ShowModal always returned 0 for some reason.

I’m using wx.SingleSeleccDialog a lot elsewhere in the application, and that’s working fine. Any reason this is screwing up?

Cheers in advance.

Take care,

Chris Norman

chris.norman2@googlemail.com

You received this message because you are subscribed to the Google Groups “wxPython-users” group.

To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Sorry yes, should have included that:

Python 2.7.9 (default, May 7 2015, 14:42:41)

[GCC 4.2.1 Compatible Apple LLVM 6.1.0 (clang-602.0.49)] on darwin

Type “help”, “copyright”, “credits” or “license” for more information.

Wx 3.0.2.0 osx-cocoa (classic)

Take care,

Chris Norman

chris.norman2@googlemail.com

···

On 15 May 2015, at 21:28, David Woods david@badgerchildhoodcancer.org wrote:

What versions of python and wxPython are you using?

David

On May 15, 2015 3:26 PM, “Chris Norman” chris.norman2@googlemail.com wrote:

Hi All,
Coding an application on OS X, and trying to use wx.MessageBox to provide a simple yes / no prompt. Only thing is, it always returns 16 (which is wx.CANCEL). I define the message box like this:

dlg = wx.MessageBox(‘Are you sure you want to delete %s - %s from this playlist?’ % (track.get(‘track’, {}).get(‘artist’, ‘Unknown Artist’), track.get(‘track’, {}).get(‘title’, ‘Unknown Track’)), ‘Really delete’, style = wx.YES_NO)

I tried using wx.MessageDialog as well, but ShowModal always returned 0 for some reason.

I’m using wx.SingleSeleccDialog a lot elsewhere in the application, and that’s working fine. Any reason this is screwing up?

Cheers in advance.

Take care,

Chris Norman

chris.norman2@googlemail.com

You received this message because you are subscribed to the Google Groups “wxPython-users” group.

To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

You received this message because you are subscribed to the Google Groups “wxPython-users” group.

To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

OS X 10.10.3 (Yosemite)

Python 2.7.9, 32-bit

wxPython 3.0.2.0 osx-carbon (classic)

import wx
app = wx.App()
print wx.ID_YES, wx.ID_NO
5103 5104
dlg = wx.MessageDialog(None, ‘Message’, ‘Caption’, wx.YES_NO)
print dlg.ShowModal() # pressed Yes
5103
print dlg.ShowModal() # pressed No
5104
print wx.YES, wx.NO
2 8
print wx.MessageBox(‘Message’, ‘Caption’, style=wx.YES_NO) # pressed Yes
2
print wx.MessageBox(‘Message’, ‘Caption’, style=wx.YES_NO) # pressed No
8

So wx.MessageDialog returns wx.ID_YES or wx.ID_NO, while wx.MessageBox returns wx.Yes or wx.No.

That’s what I get anyway.

David

···

On Fri, May 15, 2015 at 3:32 PM, Chris Norman chris.norman2@googlemail.com wrote:

Sorry yes, should have included that:

Python 2.7.9 (default, May 7 2015, 14:42:41)

[GCC 4.2.1 Compatible Apple LLVM 6.1.0 (clang-602.0.49)] on darwin

Type “help”, “copyright”, “credits” or “license” for more information.

Wx 3.0.2.0 osx-cocoa (classic)

Take care,

Chris Norman

chris.norman2@googlemail.com

On 15 May 2015, at 21:28, David Woods david@badgerchildhoodcancer.org wrote:

What versions of python and wxPython are you using?

David

On May 15, 2015 3:26 PM, “Chris Norman” chris.norman2@googlemail.com wrote:

Hi All,
Coding an application on OS X, and trying to use wx.MessageBox to provide a simple yes / no prompt. Only thing is, it always returns 16 (which is wx.CANCEL). I define the message box like this:

dlg = wx.MessageBox(‘Are you sure you want to delete %s - %s from this playlist?’ % (track.get(‘track’, {}).get(‘artist’, ‘Unknown Artist’), track.get(‘track’, {}).get(‘title’, ‘Unknown Track’)), ‘Really delete’, style = wx.YES_NO)

I tried using wx.MessageDialog as well, but ShowModal always returned 0 for some reason.

I’m using wx.SingleSeleccDialog a lot elsewhere in the application, and that’s working fine. Any reason this is screwing up?

Cheers in advance.

Take care,

Chris Norman

chris.norman2@googlemail.com

You received this message because you are subscribed to the Google Groups “wxPython-users” group.

To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

You received this message because you are subscribed to the Google Groups “wxPython-users” group.

To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

You received this message because you are subscribed to the Google Groups “wxPython-users” group.

To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

That’s what I get too, when I’m running it from the console. Just not from within the app.

Is there any way the behaviours could change like that?

Cheers,

Take care,

Chris Norman

chris.norman2@googlemail.com

···

On Fri, May 15, 2015 at 3:32 PM, Chris Norman chris.norman2@googlemail.com wrote:

Sorry yes, should have included that:

Python 2.7.9 (default, May 7 2015, 14:42:41)

[GCC 4.2.1 Compatible Apple LLVM 6.1.0 (clang-602.0.49)] on darwin

Type “help”, “copyright”, “credits” or “license” for more information.

Wx 3.0.2.0 osx-cocoa (classic)

Take care,

Chris Norman

chris.norman2@googlemail.com

On 15 May 2015, at 21:28, David Woods david@badgerchildhoodcancer.org wrote:

What versions of python and wxPython are you using?

David

On May 15, 2015 3:26 PM, “Chris Norman” chris.norman2@googlemail.com wrote:

Hi All,
Coding an application on OS X, and trying to use wx.MessageBox to provide a simple yes / no prompt. Only thing is, it always returns 16 (which is wx.CANCEL). I define the message box like this:

dlg = wx.MessageBox(‘Are you sure you want to delete %s - %s from this playlist?’ % (track.get(‘track’, {}).get(‘artist’, ‘Unknown Artist’), track.get(‘track’, {}).get(‘title’, ‘Unknown Track’)), ‘Really delete’, style = wx.YES_NO)

I tried using wx.MessageDialog as well, but ShowModal always returned 0 for some reason.

I’m using wx.SingleSeleccDialog a lot elsewhere in the application, and that’s working fine. Any reason this is screwing up?

Cheers in advance.

Take care,

Chris Norman

chris.norman2@googlemail.com

You received this message because you are subscribed to the Google Groups “wxPython-users” group.

To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

You received this message because you are subscribed to the Google Groups “wxPython-users” group.

To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

You received this message because you are subscribed to the Google Groups “wxPython-users” group.

To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

The behavior could change if you did something to change it.

Can you create a simple app that demonstrates the problem? I would need to be able to recreate the problem, or at least see a lot more of your code, to explore this further.

David

···

On Fri, May 15, 2015 at 3:32 PM, Chris Norman chris.norman2@googlemail.com wrote:

Sorry yes, should have included that:

Python 2.7.9 (default, May 7 2015, 14:42:41)

[GCC 4.2.1 Compatible Apple LLVM 6.1.0 (clang-602.0.49)] on darwin

Type “help”, “copyright”, “credits” or “license” for more information.

Wx 3.0.2.0 osx-cocoa (classic)

Take care,

Chris Norman

chris.norman2@googlemail.com

On 15 May 2015, at 21:28, David Woods david@badgerchildhoodcancer.org wrote:

What versions of python and wxPython are you using?

David

On May 15, 2015 3:26 PM, “Chris Norman” chris.norman2@googlemail.com wrote:

Hi All,
Coding an application on OS X, and trying to use wx.MessageBox to provide a simple yes / no prompt. Only thing is, it always returns 16 (which is wx.CANCEL). I define the message box like this:

dlg = wx.MessageBox(‘Are you sure you want to delete %s - %s from this playlist?’ % (track.get(‘track’, {}).get(‘artist’, ‘Unknown Artist’), track.get(‘track’, {}).get(‘title’, ‘Unknown Track’)), ‘Really delete’, style = wx.YES_NO)

I tried using wx.MessageDialog as well, but ShowModal always returned 0 for some reason.

I’m using wx.SingleSeleccDialog a lot elsewhere in the application, and that’s working fine. Any reason this is screwing up?

Cheers in advance.

Take care,

Chris Norman

chris.norman2@googlemail.com

You received this message because you are subscribed to the Google Groups “wxPython-users” group.

To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

You received this message because you are subscribed to the Google Groups “wxPython-users” group.

To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

You received this message because you are subscribed to the Google Groups “wxPython-users” group.

To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Hi,

Sorry, that was the stupidest email of my entire life…

Seems I’d not swung the particular function that called the MessageBox over to sensible coding, so it was in another thread, and not using wx.CallAfter. For the record, seems this behaviour causes wx.MessageBox to return 16 (wx.CALCEL), and wx.MessageDialog to return 0.

Cheers, and sorry for wasting time! :frowning:

Take care,

Chris Norman

chris.norman2@googlemail.com

···

On Fri, May 15, 2015 at 3:32 PM, Chris Norman chris.norman2@googlemail.com wrote:

Sorry yes, should have included that:

Python 2.7.9 (default, May 7 2015, 14:42:41)

[GCC 4.2.1 Compatible Apple LLVM 6.1.0 (clang-602.0.49)] on darwin

Type “help”, “copyright”, “credits” or “license” for more information.

Wx 3.0.2.0 osx-cocoa (classic)

Take care,

Chris Norman

chris.norman2@googlemail.com

On 15 May 2015, at 21:28, David Woods david@badgerchildhoodcancer.org wrote:

What versions of python and wxPython are you using?

David

On May 15, 2015 3:26 PM, “Chris Norman” chris.norman2@googlemail.com wrote:

Hi All,
Coding an application on OS X, and trying to use wx.MessageBox to provide a simple yes / no prompt. Only thing is, it always returns 16 (which is wx.CANCEL). I define the message box like this:

dlg = wx.MessageBox(‘Are you sure you want to delete %s - %s from this playlist?’ % (track.get(‘track’, {}).get(‘artist’, ‘Unknown Artist’), track.get(‘track’, {}).get(‘title’, ‘Unknown Track’)), ‘Really delete’, style = wx.YES_NO)

I tried using wx.MessageDialog as well, but ShowModal always returned 0 for some reason.

I’m using wx.SingleSeleccDialog a lot elsewhere in the application, and that’s working fine. Any reason this is screwing up?

Cheers in advance.

Take care,

Chris Norman

chris.norman2@googlemail.com

You received this message because you are subscribed to the Google Groups “wxPython-users” group.

To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

You received this message because you are subscribed to the Google Groups “wxPython-users” group.

To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

You received this message because you are subscribed to the Google Groups “wxPython-users” group.

To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Hey Chris,

I’m sure most of the other users in this group will agree. As long as we all learn from something time was not wasted. In fact, I stumbled across this thread while experiencing a similar issue. Turns out I had forgotten to use wx.CallAfter as well. So thank you for posting the question!

Thanks,

  • Mike S.
···

On Saturday, May 16, 2015 at 6:31:28 AM UTC-4, Chris Norman wrote:

Hi,
Sorry, that was the stupidest email of my entire life…

Seems I’d not swung the particular function that called the MessageBox over to sensible coding, so it was in another thread, and not using wx.CallAfter. For the record, seems this behaviour causes wx.MessageBox to return 16 (wx.CALCEL), and wx.MessageDialog to return 0.

Cheers, and sorry for wasting time! :frowning:

Take care,

Chris Norman

chris....@googlemail.com