wxPython 3.0.1.1 and Mac OS X Yosemite

Hello,

Today i updated OS X Mavericks to OS X Yosemite and now i can´t run a simple MessageDialog Box. Everytime when i want to Display a MessageBox it will be closed immediately.

I already removed the installation, reboot and made a fresh install of wxPython with the same result.

wxversion.getInstalled() delivers [‘3.0-osx-cocoa’]

Here are some Code which is not working

import wx

class TestFrame(wx.Frame):
def init(self):
wx.Frame.init(self, None, title=‘test’)

def Box(self):
    dlg = wx.MessageDialog(self, 'Hello from Python and wxPython!',
                           'A Message Box',
                           wx.OK | wx.ICON_INFORMATION
                           #wx.YES_NO | wx.NO_DEFAULT | wx.CANCEL | wx.ICON_INFORMATION
                           )
    dlg.ShowModal()
    dlg.Destroy()

app = wx.App(redirect=False)
a = TestFrame()
a.Box()

``

Here an other example without a Frame

import wx

def Info():
dlg = wx.MessageDialog(None, “Hello World!”, “Demo”, wx.OK | wx.ICON_INFORMATION)
dlg.ShowModal()
dlg.Destroy()
app = wx.App(redirect=False)
Info()

``

Hope it helps to find this Bug

Greetings
Steve

Steve wrote:

Hello,

Today i updated OS X Mavericks to OS X Yosemite and now i can´t run a
simple MessageDialog Box. Everytime when i want to Display a MessageBox
it will be closed immediately.

I already removed the installation, reboot and made a fresh install of
wxPython with the same result.

wxversion.getInstalled() delivers ['3.0-osx-cocoa']

This isn't a Yosemite specific issue. There were some OSX platform changes a while back that made it so we can't use the native dialogs before the application's MainLoop is running, because some additional low-level initialization has to be done then. So you can do something like this in your sample:

     app = wx.App(redirect=False)
     a = TestFrame()
     a.Show()
     wx.CallLater(100, a.Box)
     app.MainLoop()

That change only affects the native dialogs however, so if you really need a dialog on startup before the MainLoop starts then you can use a custom (non-native) dialog instead. There is also a GenericMessageDialog class that is a fairly good replacement for wx.MessageDialog if needed.

···

--
Robin Dunn
Software Craftsman

That change only affects the native dialogs however, so if you really need
a dialog on startup before the MainLoop starts then you can use a custom
(non-native) dialog instead.

Could you please clarify what you mean by "native"? Is wx.Dialog not
included? What about if I open a wx.Dialog, then a FileDialog is opened in
response to a button press? I got burnt badly by this change when
Mavericks came out and now that I know what to look for I'd like to audit
my code and fix anything that might still break.

There is also a GenericMessageDialog class that is a fairly good

replacement for wx.MessageDialog if needed.

Did this ever get fixed so the return key works?

thanks,
Nat

···

On Fri, Oct 17, 2014 at 1:33 PM, Robin Dunn <robin@alldunn.com> wrote:

The major operating systems all includes canned dialogs for things like message boxes, file selection, and printing, for example. Whenever possible wx tries to use the native operating system dialog instead of drawing one by hand.

A dialog based on wx.Dialog is not native.

Opening a dialog prior to the main loop is a questionable practice to begin with. Dialogs and windows are all managed and controlled using messages, and the only time messages get processed is then the main loop runs.

···

That change only affects the native dialogs however, so if you really need a dialog on startup before the MainLoop starts then you can use a custom (non-native) dialog instead.

Could you please clarify what you mean by “native”? Is wx.Dialog not included?

Thank you this helped me. i changed my code so the windows will stay.

But now i have a other Problem. I´am writing an background server which is calling serveral functions depending on the user input. At the moment i wrote something like this in the function if she get called:

dlg = wx.MessageDialog(self, "Really wanne start this Action", "Title", wx.YES_NO | wx.NO_DEFAULT | wx.ICON_QUESTION) result = dlg.ShowModal() if result == wx.ID_YES: #do something
dlg2.Destroy()

but this is not working. I believe he´s not get the button i clicked. could you explain me why ? is this the same problem like in your first post ?

···

Am Freitag, 17. Oktober 2014 22:33:58 UTC+2 schrieb Robin Dunn:

Steve wrote:

Hello,

Today i updated OS X Mavericks to OS X Yosemite and now i can´t run a

simple MessageDialog Box. Everytime when i want to Display a MessageBox

it will be closed immediately.

I already removed the installation, reboot and made a fresh install of

wxPython with the same result.

wxversion.getInstalled() delivers [‘3.0-osx-cocoa’]

This isn’t a Yosemite specific issue. There were some OSX platform
changes a while back that made it so we can’t use the native dialogs
before the application’s MainLoop is running, because some additional
low-level initialization has to be done then. So you can do something
like this in your sample:

 app = wx.App(redirect=False)

 a = TestFrame()

 a.Show()

 wx.CallLater(100, a.Box)

 app.MainLoop()

That change only affects the native dialogs however, so if you really
need a dialog on startup before the MainLoop starts then you can use a
custom (non-native) dialog instead. There is also a
GenericMessageDialog class that is a fairly good replacement for
wx.MessageDialog if needed.


Robin Dunn

Software Craftsman

http://wxPython.org

hmm, on Win7 with 3.0.0.0-classic I get the message dialog, but it doesn’t have a question mark icon that the wx.ICON_QUESTION should specify.

are you getting an error because dlg2 doesn’t exist? (you called it dlg earlier in the code snippet)

···

On Monday, October 20, 2014 5:19:47 AM UTC-7, Steve wrote:

Thank you this helped me. i changed my code so the windows will stay.

But now i have a other Problem. I´am writing an background server which is calling serveral functions depending on the user input. At the moment i wrote something like this in the function if she get called:

dlg = wx.MessageDialog(self, "Really wanne start this Action", "Title", wx.YES_NO | wx.NO_DEFAULT | wx.ICON_QUESTION) result = dlg.ShowModal() if result == wx.ID_YES: #do something
dlg2.Destroy()

but this is not working. I believe he´s not get the button i clicked. could you explain me why ? is this the same problem like in your first post ?

Hi,

Sorry this was a mistype. In my script i use dlg2 in the whole function. On Windows the snippet works like a charm and i can catch the Button ID´s, but on Mac he don´t recognized which buttons is pressed.

The workaround with wx.callLater() is not suitable in my situation because i want to show a dialog only if the function is called so i don´t get it in my head how i should use this :wink:

···

Am Montag, 20. Oktober 2014 21:53:30 UTC+2 schrieb Nathan McCorkle:

On Monday, October 20, 2014 5:19:47 AM UTC-7, Steve wrote:

Thank you this helped me. i changed my code so the windows will stay.

But now i have a other Problem. I´am writing an background server which is calling serveral functions depending on the user input. At the moment i wrote something like this in the function if she get called:

dlg = wx.MessageDialog(self, "Really wanne start this Action", "Title", wx.YES_NO | wx.NO_DEFAULT | wx.ICON_QUESTION) result = dlg.ShowModal() if result == wx.ID_YES: #do something
dlg2.Destroy()

but this is not working. I believe he´s not get the button i clicked. could you explain me why ? is this the same problem like in your first post ?

hmm, on Win7 with 3.0.0.0-classic I get the message dialog, but it doesn’t have a question mark icon that the wx.ICON_QUESTION should specify.

are you getting an error because dlg2 doesn’t exist? (you called it dlg earlier in the code snippet)