Opened 5 years ago

Closed 4 years ago

#17649 closed defect (invalid)

wx.DatePickerCtrl's GetChildren() call returns inconsistent wrapped type

Reported by: will133 Owned by:
Priority: normal Milestone:
Component: wxPython Version: 3.0.2
Keywords: Cc:
Blocked By: Blocking:
Patch: no

Description

This is related to a ticket I filed at:

https://github.com/enthought/traitsui/issues/303

but since I think it may be a wxPython bug I'm filing it here as well.

Platform:

I'm running wxPython 3.0.2.0 gtk2 (classic) on Linux.

To reproduce:

Trying to execute this following code:

import wx._combo
import wx


class Frame(wx.Frame):
    def __init__(self, title):
        wx.Frame.__init__(self, None, title=title, pos=(150, 150), size=(350, 200))
        panel = wx.Panel(self)
        box = wx.BoxSizer(wx.VERTICAL)
        dateCtrl = wx.DatePickerCtrl(panel,
                                     size=(120, -1),
                                     style=wx.DP_DROPDOWN
                                     | wx.DP_SHOWCENTURY
                                     | wx.DP_ALLOWNONE)
        print(dateCtrl.GetChildren())
        box.Add(dateCtrl, 0, wx.ALL, 50)
        panel.SetSizer(box)
        panel.Layout()

if __name__ == "__main__":
    app = wx.App()   # Error messages go to popup window
    top = Frame("test")
    top.Show()
    app.MainLoop()

will yield this:

wxWindowList: [<Swig Object of type 'wxComboCtrl *' at 0x22d6400>]

The behavior, however, is different when *I comment out the wx._combo line*. If I rerun that code I'd get:

wxWindowList: [<wx._core.Control; proxy of <Swig Object of type 'wxControl *' at 0x26dc000> >]

Note that originally I was not importing wx._combo but wx.combo, which import the _combo from that module.

It seems the behavior is really strange and made the traitsui package that I've been using failed in unpredictable ways. The second behavior is the expected one, I assume.

Change History (1)

comment:1 Changed 4 years ago by robind

  • Resolution set to invalid
  • Status changed from new to closed

This is expected and not a bug. The runtime type info implemented for the C++ classes is not loaded in a way that wxPython can use until the wxPython extension module implementing those classes is imported, so what you are seeing is just a side-effect of that implementation detail.

Either way, that is handled differently now in wxPython 4.

Note: See TracTickets for help on using tickets.