Problem with modal dialog in wx.App.OnInit with wx.3.0.0 osx-cocoa

I’m in the process of migrating a Python 2.7 application from using wx.2.9.4 osx-carbon that supported ppc-i386 to wx.3.0.0 osx-cocoa (i386-x86_64) and finding that a modal wx.message dialog opened during wx.App.OnInit() just flashes up briefly before the OnInit code continues. The attached standalone showmessage.py demonstrates the problem here and the 3 screenshots show it working OK with wx.2.9.4 osx-carbon (Snow Leopard) and wx.3.0.0 win32 (Windows8.1) but not wx.3.0.0 osx-cocoa (Mavericks). Can anyone else reproduce this? The wx.message samples in the wx 3.0.0 demo seem to be OK, which makes me think the problem is related to being inside OnInit()

showmessage.py (464 Bytes)

message-wx3.0.0-cocoa-mavericks.png

message-wx2.9.4-carbon-snowleopard.png

message-wx3.0.0-windows8.png

···


Regards
David Hughes

David Hughes wrote:

I'm in the process of migrating a Python 2.7 application from using
wx.2.9.4 osx-carbon that supported ppc-i386 to wx.3.0.0 osx-cocoa
(i386-x86_64) and finding that a modal wx.message dialog opened during
wx.App.OnInit() just flashes up briefly before the OnInit code
continues. The attached standalone *showmessage.py *demonstrates the
problem here and the 3 screenshots show it working OK with wx.2.9.4
osx-carbon (Snow Leopard) and wx.3.0.0 win32 (Windows8.1) but not
wx.3.0.0 osx-cocoa (Mavericks). Can anyone else reproduce this? The
wx.message samples in the wx 3.0.0 demo seem to be OK, which makes me
think the problem is related to being inside OnInit()

I see it too, but unfortunately I have no idea what's going on. It also happens if the dialog is shown outside of OnInit before MainLoop is called. And since MainLoop terminates immediately if there are no existing TLWs then using wx.CallAfter isn't going to help either.

I'll see if I can find any info about this, but in the meantime you can use wx.lib.agw.genericmessagedialog as a workaround.

···

--
Robin Dunn
Software Craftsman

Thanks, genericmessagedialog suits me fine,. I will probably use it permanently throughout the application. I must spend some time discovering what other goodies are in wx.lib.agw :slight_smile:

···

On 16/02/2014 01:28, Robin Dunn wrote:

David Hughes wrote:

... a modal wx.message dialog opened during
wx.App.OnInit() just flashes up briefly before the OnInit code
continues. ...

I see it too, but unfortunately I have no idea what's going on. It also happens if the dialog is shown outside of OnInit before MainLoop is called. And since MainLoop terminates immediately if there are no existing TLWs then using wx.CallAfter isn't going to help either.

I'll see if I can find any info about this, but in the meantime you can use wx.lib.agw.genericmessagedialog as a workaround.

--
Regards

David Hughes
Forestfield Software

Hi, all

I have a similar problem. In windows the fallowing script works fine, but using wx3.0.0-cocoa-mavericks the first dialog canceled automatically (print(rspns) is 5101 = wx.ID_CANCEL) and only the second dialog show appropriately :

from future import print_function

import os

import wx

CWD = os.getcwd()

class MyApp(wx.App):

def OnInit(self):

dlg_open = wx.FileDialog(None, ‘Select file’, CWD, ‘’,

wildcard=‘All(.)|.’,

style=wx.OPEN)

rspns = dlg_open.ShowModal()

if rspns == wx.ID_OK:

print(dlg_open.GetPath())

else:

print(rspns)

dlg_open.Destroy()

dlg_open = wx.FileDialog(None, ‘Select other file’, CWD, ‘’,

wildcard=‘All(.)|.’,

style=wx.OPEN)

rspns = dlg_open.ShowModal()

if rspns == wx.ID_OK:

print(dlg_open.GetPath())

else:

print(rspns)

dlg_open.Destroy()

return True

if name == “main”:

app = MyApp()

app.MainLoop()

This does not happen when the dialog has a parent, in this case all is ok:

from future import print_function

import os

import wx

CWD = os.getcwd()

class MyFrame(wx.Frame):

def init(self, parent, id_=wx.ID_ANY, title=“”,

pos=wx.DefaultPosition, size=wx.DefaultSize,

style=wx.DEFAULT_FRAME_STYLE):

super(MyFrame, self).init(parent, id_, title,

pos, size, style)

self.panel = wx.Panel(self)

btn = wx.Button(self, -1, ‘Open’, (50,50))

self.Bind(wx.EVT_BUTTON, self.on_button, btn)

def on_button(self, event):

dlg_open = wx.FileDialog(self, ‘Select file’, CWD, ‘’,

wildcard=‘All(.)|.’,

style=wx.OPEN)

rspns = dlg_open.ShowModal()

if rspns == wx.ID_OK:

print(dlg_open.GetPath())

else:

print(rspns)

dlg_open.Destroy()

dlg_open = wx.FileDialog(self, ‘Select file’, CWD, ‘’,

wildcard=‘All(.)|.’,

style=wx.OPEN)

rspns = dlg_open.ShowModal()

if rspns == wx.ID_OK:

print(dlg_open.GetPath())

else:

print(rspns)

dlg_open.Destroy()

class MyApp(wx.App):

def OnInit(self):

self.frame = MyFrame(None, title=“The Main Frame”)

self.SetTopWindow(self.frame)

self.frame.Show()

return True

if name == “main”:

app = MyApp()

app.MainLoop()

···

El martes, 11 de febrero de 2014 16:53:55 UTC+1, David Hughes escribió:

I’m in the process of migrating a Python 2.7 application from using wx.2.9.4 osx-carbon that supported ppc-i386 to wx.3.0.0 osx-cocoa (i386-x86_64) and finding that a modal wx.message dialog opened during wx.App.OnInit() just flashes up briefly before the OnInit code continues. The attached standalone showmessage.py demonstrates the problem here and the 3 screenshots show it working OK with wx.2.9.4 osx-carbon (Snow Leopard) and wx.3.0.0 win32 (Windows8.1) but not wx.3.0.0 osx-cocoa (Mavericks). Can anyone else reproduce this? The wx.message samples in the wx 3.0.0 demo seem to be OK, which makes me think the problem is related to being inside OnInit()

Regards
David Hughes

I fixed this problem by putting the dialog in another fuction (start) and scheduling it using wx.CallLater(10,self.start)

I know it’s been a few months since I raised this problem but I’m
only now trying to move forward from wx.2.9.4 to 3.0.2 (I have
determined it is a wx version problem and not cocoa vs carbon or OS
X version related). I switched to using
wx.lib.agw.genericmessagedialog as you suggested, Robin but although
the dialog now appears during OnInit, there is (still) a more
fundamental problem, as seen using Wing IDE - OnInit exits with a
return value of True but the next statement in the calling program -
app.MainLoop() - is ! The program GUI is still
sort of responsive, to everything it seems, apart from some Close()
requests and it is always necessary to force-quit in order to stop.
This suggests there is something seriously amiss. If it’s
reproducible, what’s the best way to try to progress this?

···

On 16/02/2014 01:28, Robin Dunn wrote:

  David

Hughes wrote:

    I'm in the process of migrating a Python

2.7 application from using

    wx.2.9.4 osx-carbon that supported ppc-i386 to wx.3.0.0

osx-cocoa

    (i386-x86_64) and finding that a modal wx.message dialog opened

during

    wx.App.OnInit() just flashes up briefly before the OnInit code


    continues. ....
  I see it too, but unfortunately I have no idea what's going on. 

It also happens if the dialog is shown outside of OnInit before
MainLoop is called. And since MainLoop terminates immediately if
there are no existing TLWs then using wx.CallAfter isn’t going to
help either.

  I'll see if I can find any info about this, but in the meantime

you can use wx.lib.agw.genericmessagedialog as a workaround.

never executed


-- Regards
David Hughes
Forestfield Software