Display problem

Hi,
  I've created a new ctrl (my first custom one) and it was remarkably
easy to do(though the ctrl is quite simple)!
  The only problem I have with it is that since it shows another ctrl on
top of itself and the rest of the ctrls below it, some ctrls paint
themselfs on top of it.
  I have tried using Rise, Update and Refresh before and after showing
the ctrl and setting the wxSTAY_ON_TOP style with no results.
  I can't delay creating it until it is used since the creation order
matters (because of the tab navigation).
  How can I make this ctrl be on top of the rest? Is there a better way
to do it? I thought about inheriting wxComboBox but didn't know how to
replace the drop-down listBox with a drop-down checkListBox.

TIA,
  Javier

-- Code ---------------------------------------------------------

class ListaOcultaCtrl(wxTextCtrl):
    """ListaOcultaCtrl()

    Muestra un wxCheckListBox cuando obtiene el foco y lo oculta cuando
    lo pierde. Las opciones seleccionadas son mostradas en el wxTextCtrl
    separadas por comas.
    """
    def __init__(self, parent, id, value="", choices=None, pos=(0,0),
size=wxDefaultSize, style=0, name="listaOculta"):
        wxTextCtrl.__init__(self, parent, id, value, pos, size, style=0,
name=name)

        if choices is None:
            choices = []
        self.checkListBox = wxCheckListBox(parent, -1, choices=choices,
style=style)
        self.checkListBox.Show(False)

        EVT_SET_FOCUS(self, self.__OnSetFocus)
        EVT_KILL_FOCUS(self.checkListBox, self.__OnKillFocus)

    def __OnSetFocus(self, event):
        event.Skip()
        w, h = self.GetSize()
        x, y = self.GetPositionTuple()
        lb = self.checkListBox
        lb.SetSize((w, lb.GetItemHeight()*lb.Number()+10))
        lb.SetPosition((x, y))
        lb.Show(True)
        self.Show(False)
        lb.SetFocus()

    def __OnKillFocus(self, event):
        event.Skip()
        # Si se cierra el frame mientras tenga el foco el control, se
        # obtendría un wxPyDeadObjectError.
        if not self: return

        lb = self.checkListBox
        value = [ lb.GetString(i) for i in range(lb.Number()) if
lb.IsChecked(i) ]
        self.SetValue(', '.join(value))

        self.Show(True)
        lb.Show(False)

···

----------------------------------------------------------------------

Javier Ruere wrote:

Hi,
  I've created a new ctrl (my first custom one) and it was remarkably
easy to do(though the ctrl is quite simple)!
  The only problem I have with it is that since it shows another ctrl on
top of itself and the rest of the ctrls below it, some ctrls paint
themselfs on top of it.
  I have tried using Rise, Update and Refresh before and after showing
the ctrl and setting the wxSTAY_ON_TOP style with no results.
  I can't delay creating it until it is used since the creation order
matters (because of the tab navigation).
  How can I make this ctrl be on top of the rest? Is there a better way
to do it? I thought about inheriting wxComboBox but didn't know how to
replace the drop-down listBox with a drop-down checkListBox.

You probably want to use wxPopupWindow or wxTransientPopupWindow.

···

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