[wxPython] focus not set in miniframe after dialog

From a wxgrid-derived class in a splitter window in a wxframe, in a

function called by an OnCellChange method...

I first put up a wxTextEntryDialog, and then after the user closes
that, based on further results, sometimes put up a wxMiniFrame-derived
window.

The second window doesn't get the focus, even if I set it
explicitly with SetFocus. It does get the focus if I comment out the
wxTextEntryDialog. Any thoughts?

Here's the function, and the wxMiniFrame-based class:

    def do_match(self, row):
        dlg = wxTextEntryDialog(self, 'Comment regarding the match',
                                'Enter comments')
        if dlg.ShowModal() == wxID_OK:
            note = dlg.GetValue()
        else: note = ''
        dlg.Destroy()
        debug("Note was: %s"%note)
        key1 = self.grid1.table.records[0][self.grid1.table.datalist.primary_key]
        key2 = self.grid2.table.records[row][self.grid2.table.datalist.primary_key]
        further_matches = self.matchset.make_match(key1, key2, note)

        if further_matches:
      win = MatchMiniFrame(self, -1, "This is a wxMiniFrame",
                          wxDefaultPosition, wxSize(200, 200),
                          wxDEFAULT_FRAME_STYLE | wxTINY_CAPTION_HORIZ)
           self.otherWin = win
           win.Show(true)

class MatchMiniFrame(wxMiniFrame):
    def __init__(self, parent, ID, title, pos, size, style):
        wxMiniFrame.__init__(self, parent, ID, title, pos, size, style)
        panel = wxPanel(self, -1)

        button = wxButton(panel, 1003, "Close Me")
        button.SetPosition(wxPoint(15, 15))
        EVT_BUTTON(self, 1003, self.OnCloseMe)
        EVT_CLOSE(self, self.OnCloseWindow)

    def OnCloseMe(self, event):
        self.Close(true)

    def OnCloseWindow(self, event):
        self.Destroy()

The second window doesn't get the focus, even if I set it
explicitly with SetFocus. It does get the focus if I comment out the
wxTextEntryDialog. Any thoughts?

Does it make any difference if you set the focus back to the parent window
after the dialog is destroyed but before the miniframe is shown? What if
you use a wxFrame instead of a wxMiniFrame?

···

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

The second window doesn't get the focus, even if I set it
explicitly with SetFocus. It does get the focus if I comment out the
wxTextEntryDialog. Any thoughts?

Does it make any difference if you set the focus back to the parent window
after the dialog is destroyed but before the miniframe is shown? What if
you use a wxFrame instead of a wxMiniFrame?

Already tried both; neither help.

Try an explicit
frame.RemoveChild(dlg)

after the

dlg.Destroy()

This worked around a similar problem for me--incidentally, it was due to
someone on this list (can't remember who), not to me...

Hope this works...

Chris

···

----- Original Message -----
From: "Patricia Hawkins" <phawkins@connact.com>
To: <wxpython-users@lists.wxwindows.org>
Sent: Saturday, May 19, 2001 6:54 AM
Subject: Re: [wxPython] focus not set in miniframe after dialog

>>
>> The second window doesn't get the focus, even if I set it
>> explicitly with SetFocus. It does get the focus if I comment out the
>> wxTextEntryDialog. Any thoughts?
>>

> Does it make any difference if you set the focus back to the parent

window

> after the dialog is destroyed but before the miniframe is shown? What

if

> you use a wxFrame instead of a wxMiniFrame?

Already tried both; neither help.

_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwindows.org
http://lists.wxwindows.org/mailman/listinfo/wxpython-users