在GUI中,我使用填充了許多wx.lib.agw.ultimatelistctrl
(ULC)的wx.Treebook
。切片wxPython WindowList
我需要遍歷樹形圖書頁(又名ULCs)。
我用lPages = treebook.GetChildren()
來得到它們。
但是,樹形圖的第一個孩子是wx.TreeCtrl
的一個實例。
我知道我可以用類似避免:
for page in lPages:
if not isinstance(page, wx.TreeCtrl):
# do something with the ULCs
但我想保持我的代碼簡單,容易閱讀。因此,不要將測試用於單次使用並保留額外縮進。
我想要做一些像lPages = treebook.GetChildren()[1:]
或del lPages[0]
只能得到ULCs。
它給我以下錯誤:
使用treebook.GetChildren()[1:]
:
TypeError: WindowList.__getitem__(): argument 1 has unexpected type 'slice'
Segmentation fault (core dumped)
使用del lPages[0]
:
TypeError: 'WindowList' object doesn't support item deletion
Segmentation fault (core dumped)
有沒有什麼辦法來分割一個WindowList中?