wxWidgets / Phoenix

wxPython's Project Phoenix. A new implementation of wxPython, better, stronger, faster than he was before.
http://wxpython.org/
2.29k stars 516 forks source link

wx.ChoiceBook.GetControlSizer() does not appear to be implemented #2335

Open Randalphwa opened 1 year ago

Randalphwa commented 1 year ago

Operating system: Windows (probably all operating systems) wxPython version & source: 4.2.0 installed from pypi.org Python version & source: 3.10 stock

Description of the problem:

The documentation for wx.ChoiceBook states that: "wx.Choicebook allows the use of BookCtrlBase.GetControlSizer(), allowing a program to add other controls next to the choice control.". However, using this causes an error.

Example:

    page_sizer_1 = wx.BoxSizer(wx.VERTICAL)
    self.m_choicebook = wx.Choicebook(page_2, wx.ID_ANY)
    page_sizer_1.Add(self.m_choicebook, wx.SizerFlags().Border(wx.ALL))
    btn = wx.Button(self.m_choicebook, wx.ID_ANY, "First")
    self.m_choicebook.GetControlSizer().Add(btn, wx.SizerFlags().Expand().Border(wx.ALL))

Running the above code results in the error message:

AttributeError: 'Choicebook' object has no attribute 'GetControlSizer'. Did you mean: 'GetContainingSizer'?

And no, GetContainingSizer() does not work as a replacement as the error message suggests.

Note that the following C++ code works fine:

    auto* page_sizer_1 = new wxBoxSizer(wxVERTICAL);
    m_choicebook = new wxChoicebook(page_2, wxID_ANY);
    page_sizer_1->Add(m_choicebook, wxSizerFlags().Border(wxALL));
    auto* btn = new wxButton(m_choicebook, wxID_ANY, "First");
    m_choicebook->GetControlSizer()->Add(btn, wxSizerFlags().Expand().Border(wxALL));
swt2c commented 1 year ago

Confirmed, it is a documentation error, see https://github.com/wxWidgets/wxWidgets/pull/23211

Randalphwa commented 1 year ago

I don't suppose there's any chance it could be implemented in wxPython since the function is part of the wxWidgets wxBookCtrlBase class and is documented in the main wxWidgets docs? See https://docs.wxwidgets.org/trunk/classwx_choicebook.html

swt2c commented 1 year ago

No, it certainly can be implemented. I was just pointing out why it wasn't previously. (wxPython is generated semi-automatically from wxWidgets interface headers.)