m_combo property of wxComboPopup

Hi,

In the wxWidgets help, wxComboPopup instances should have a member
m_combo pointing to its parent, which is a wxComboCtrl. In wxPython,
this member property is missing. Then how can wxComboPopup know with
which wxComboCtrl it is associated?

···

--
Hong Yuan

大管家网上建材超市
装修装潢建材一站式购物
http://www.homemaster.cn

Yuan HOng wrote:

Hi,

In the wxWidgets help, wxComboPopup instances should have a member
m_combo pointing to its parent, which is a wxComboCtrl. In wxPython,
this member property is missing. Then how can wxComboPopup know with
which wxComboCtrl it is associated?

Use the GetCombo method.

···

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

It returns a wx.ComboCtrl object rather than the class that derives
from wx.ComboCtrl, so some attributes are missing. Is it possible to
get the derived class instead of the base class?

Also, the wx.ComboCtrl instance so returned will return None when its
GetTextCtrl method is called.

Second question. How does wx.ComboCtrl notify the user that a
selection is made by the user? Binding to wx.EVT_COMBOBOX doesn't seem
to work in a modification to the wxPython demo.

···

On 5/30/07, Robin Dunn <robin@alldunn.com> wrote:

Yuan HOng wrote:
> Hi,
>
> In the wxWidgets help, wxComboPopup instances should have a member
> m_combo pointing to its parent, which is a wxComboCtrl. In wxPython,
> this member property is missing. Then how can wxComboPopup know with
> which wxComboCtrl it is associated?
>

Use the GetCombo method.

--
Hong Yuan

大管家网上建材超市
装修装潢建材一站式购物
http://www.homemaster.cn

Yuan HOng wrote:

···

On 5/30/07, Robin Dunn <robin@alldunn.com> wrote:

Yuan HOng wrote:
> Hi,
>
> In the wxWidgets help, wxComboPopup instances should have a member
> m_combo pointing to its parent, which is a wxComboCtrl. In wxPython,
> this member property is missing. Then how can wxComboPopup know with
> which wxComboCtrl it is associated?
>

Use the GetCombo method.

It returns a wx.ComboCtrl object rather than the class that derives
from wx.ComboCtrl, so some attributes are missing. Is it possible to
get the derived class instead of the base class?

Yes, but I'll have to tweak the wrapper to do it.

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

Robin Dunn <robin <at> alldunn.com> writes:

Yes, but I'll have to tweak the wrapper to do it.

I think my issue is similar.
Sorry, but I can understand how to change the Behavior of derived ComboCtrl.
Please, can You provide more detailed explanation how to solve this:

import wx
import wx.combo

···

#----------------------------------------------------------------------
# This class is a popup containing a TreeCtrl. This time we'll use a
# has-a style (instead of is-a like above.)
class TreeCtrlComboPopup(wx.combo.ComboPopup):
# copy from ComboCtrl-Demo

app = wx.PySimpleApp()
    dialog = wx.Dialog(None)
    
    combobox = wx.combo.ComboCtrl(dialog, style=wx.CB_READONLY)
    set = TreeCtrlComboPopup()
    combobox.PopupControl = set
    get = combobox.PopupControl
    
    text = wx.TextCtrl(dialog, style=wx.TE_MULTILINE)
    text.Value = 'set == get: %s \n set is %s \n get is %s' % ( str(type(set) ==
type(get)), type(set), type(get))

    sizer= wx.BoxSizer(wx.VERTICAL)
    sizer.Add(combobox)
    sizer.Add(text, 1, wx.EXPAND)
    dialog.Sizer = sizer
    dialog.Show()

Ur wrote:

Robin Dunn <robin <at> alldunn.com> writes:

Yes, but I'll have to tweak the wrapper to do it.

I think my issue is similar. Sorry, but I can understand how to change the Behavior of derived ComboCtrl.
Please, can You provide more detailed explanation how to solve this:

The C++ wxComboPopup class does not have the necessary magic to be able to allow wxPython to look up the original Python proxy object from the C++ and return it from methods like GetPopupControl. Instead you'll need to keep a reference to the object yourself.

···

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

Robin Dunn <robin <at> alldunn.com> writes:

The C++ wxComboPopup class does not have the necessary magic to be able
to allow wxPython to look up the original Python proxy object from the
C++ and return it from methods like GetPopupControl. Instead you'll
need to keep a reference to the object yourself.

Ok, but why in API its written:
"GetPopupControl(self) Returns the current popup interface that has been set
with SetPopupControl.". It's a tad obscure for me.
And why do ComboCtrl don't have such determined Place to store really Reference
for PopupCtrl?

one Example again:
if __name__ == '__main__':
    app = wx.PySimpleApp()
    dialog = wx.Dialog(None)
    
    comboCtrl = wx.combo.ComboCtrl(dialog, style=wx.CB_READONLY)
    set = TreeCtrlComboPopup()
    comboCtrl.PopupControl = set
    comboCtrl.__dict__['myPopupControl'] = set
    get = comboCtrl.PopupControl
    get2 = comboCtrl.myPopupControl
    
    text = wx.TextCtrl(dialog, style=wx.TE_MULTILINE)
    text.Value = 'set == get: %s \n' % str(type(set) == type(get))
    text.AppendText(' set is %s \n' % type(set))
    text.AppendText(' get is %s \n' % type(get))
    text.AppendText('set == get2: %s \n' % str(type(set) == type(get2)))
    text.AppendText(' get2 is %s \n' % type(get2))
    
    sizer= wx.BoxSizer(wx.VERTICAL)
    sizer.Add(comboCtrl)
    sizer.Add(text, 1, wx.EXPAND)
    
    dialog.Sizer = sizer
    dialog.Show()
    app.MainLoop()

Ur wrote:

Robin Dunn <robin <at> alldunn.com> writes:

The C++ wxComboPopup class does not have the necessary magic to be able to allow wxPython to look up the original Python proxy object from the C++ and return it from methods like GetPopupControl. Instead you'll need to keep a reference to the object yourself.

Ok, but why in API its written:
"GetPopupControl(self) Returns the current popup interface that has been set
with SetPopupControl.". It's a tad obscure for me.

It does return the same C++ PopupControl that was set previously, the trouble is that a new Python proxy object is being wrapped around the same C++ pointer, and since it can't determine the true type of the pointer it is creating a proxy of the base class type instead.

···

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