Skip to content
Permalink
Browse files

Merge pull request #1448 from wxWidgets/fix-issue1444

Verify parameter types for Check and Set3StateValue
  • Loading branch information
RobinD42 committed Nov 22, 2019
2 parents 4342b5c + e1c44da commit f3b370b6da850d0bff6b58703ab6d4efa0151ea7
Showing with 4 additions and 5 deletions.
  1. +4 −5 wx/lib/agw/customtreectrl.py
@@ -1646,7 +1646,7 @@ def __init__(self, parent, text="", ct_type=0, wnd=None, image=-1, selImage=-1,
self._ownsAttr = False # delete attribute when done
self._type = ct_type # item type: 0=normal, 1=check, 2=radio
self._is3State = False # true for 3-state checkbox items
self._checked = 0 # only meaningful for check and radio items
self._checked = False # only meaningful for check and radio items
self._enabled = True # flag to enable/disable an item
self._hypertext = False # indicates if the item is hypertext
self._visited = False # visited state for an hypertext item
@@ -2286,7 +2286,7 @@ def Set3StateValue(self, state):
:note: This method is meaningful only for checkbox-like items.
"""

assert state in [wx.CHK_UNCHECKED, wx.CHK_CHECKED, wx.CHK_UNDETERMINED]
if not self._is3State and state == wx.CHK_UNDETERMINED:
raise Exception("Set3StateValue can only be used with 3-state checkbox items.")

@@ -2332,7 +2332,7 @@ def Check(self, checked=True):
:note: This is meaningful only for checkbox-like and radiobutton-like items.
:note: Always use :meth:`~CustomTreeCtrl.CheckItem` instead to update the tree properly and send events.
"""

assert checked in [True, False]
self._checked = checked


@@ -2676,8 +2676,7 @@ def GetCurrentCheckedImage(self):
return None

checked = self.IsChecked()

if checked > 0:
if checked:
if self._type == 1: # Checkbox
if checked == wx.CHK_CHECKED:
return self._checkedimages[TreeItemIcon_Checked]

0 comments on commit f3b370b

Please sign in to comment.
You can’t perform that action at this time.