wx.SearchCtrl crashes with wx.RESIZE_BORDER

Hi all,

(Sorry for my bad english, im french)

A wx.searchCtrl in a toolBar in a wx.dialog with wx.RESIZE_BORDER (and wx.DEFAUT_DIALOG_STYLE) crashes when i close the dialog.

But only if i have written something in the searchCtrl ! Amazing, no ?

You can reproduce problem with this code :

#!/usr/bin/env python

-- coding: iso-8859-15 --

import wx

class Dialog(wx.Dialog):
def init(self, parent):
wx.Dialog.init(self, parent, style=
wx.DEFAULT_DIALOG_STYLE
> wx.RESIZE_BORDER

| wx.MAXIMIZE_BOX

| wx.MINIMIZE_BOX

| wx.CAPTION

| wx.CLOSE_BOX

| wx.THICK_FRAME

        )

    panel = wx.Panel(self)
    tb = wx.ToolBar(panel)
    sizer = wx.BoxSizer(wx.VERTICAL)
    sizer.Add(tb, 0, wx.EXPAND)
    panel.SetSizer(sizer)

    search = wx.SearchCtrl(tb, -1, "")
    tb.AddControl(search)
    tb.Realize()

if name == “main”:
app = wx.App(0)
dialog_1 = Dialog(None)
app.SetTopWindow(dialog_1)
dialog_1.ShowModal()
app.MainLoop()

``

Do you know how i can avoid this bug ?

Thx for your help !

Any answer ?

···

Le dimanche 26 octobre 2014 18:44:09 UTC+1, Noe a écrit :

Hi all,

(Sorry for my bad english, im french)

A wx.searchCtrl in a toolBar in a wx.dialog with wx.RESIZE_BORDER (and wx.DEFAUT_DIALOG_STYLE) crashes when i close the dialog.

But only if i have written something in the searchCtrl ! Amazing, no ?

You can reproduce problem with this code :

#!/usr/bin/env python

-- coding: iso-8859-15 --

import wx

class Dialog(wx.Dialog):
def init(self, parent):
wx.Dialog.init(self, parent, style=
wx.DEFAULT_DIALOG_STYLE
> wx.RESIZE_BORDER

| wx.MAXIMIZE_BOX

| wx.MINIMIZE_BOX

| wx.CAPTION

| wx.CLOSE_BOX

| wx.THICK_FRAME

        )


    panel = wx.Panel(self)
    tb = wx.ToolBar(panel)
    sizer = wx.BoxSizer(wx.VERTICAL)
    sizer.Add(tb, 0, wx.EXPAND)
    panel.SetSizer(sizer)


    search = wx.SearchCtrl(tb, -1, "")
    tb.AddControl(search)
    tb.Realize()

if name == “main”:
app = wx.App(0)
dialog_1 = Dialog(None)
app.SetTopWindow(dialog_1)
dialog_1.ShowModal()
app.MainLoop()

``

Do you know how i can avoid this bug ?

Thx for your help !

The code as you have it has a problem. You have made the dialog into the top-level window for the app, but then you call ShowModal, which displays the dialog and creates its own main loop. The ShowModal call will not return until you close the dialog, so by the time you get to MainLoop, there aren’t any windows left.

I tried this on OS X and it did not crash, although the app would not exit because of the call to MainLoop. If I remove the call to app.MainLoop, it works normally.

···

On Nov 1, 2014, at 12:39 AM, Noe noethys@gmail.com wrote:

Any answer ?

Tim Roberts, timr@probo.com

Providenza & Boekelheide, Inc.