class_docstr: A dialog for "selecting" items on a tree by checking them
class_docstr_tok: ["A","dialog","for","``","selecting","''","items","on","a","tree","by","checking","them"]
docstr: Initialize the dialog
  
  d - dictionary representing the tree.
      Keys form the dictionary labels, values are dictionaries of subtrees
      A leaf is marked with a dictionary entry whose key is None and
      whose value is True or False, depending on whether it is
      initially selected or not.
docstr_tok: ["Initialize","the","dialog","d","-","dictionary","representing","the","tree",".","Keys","form","the","dictionary","labels",",","values","are","dictionaries","of","subtrees","A","leaf","is","marked","with","a","dictionary","entry","whose","key","is","None","and","whose","value","is","True","or","False",",","depending","on","whether","it","is","initially","selected","or","not","."]
code: def __init__(self, parent, d, *args, **kwargs):
      """Initialize the dialog
  
      d - dictionary representing the tree.
          Keys form the dictionary labels, values are dictionaries of subtrees
          A leaf is marked with a dictionary entry whose key is None and
          whose value is True or False, depending on whether it is
          initially selected or not.
      """
      wx.Dialog.__init__(self, parent, *args, **kwargs)
  
      self.bitmaps = []
      self.parent_reflects_child = True
      sizer = wx.BoxSizer(wx.VERTICAL)
      self.SetSizer(sizer)
      tree_style = wx.TR_DEFAULT_STYLE
      self.tree_ctrl = wx.TreeCtrl(self, style=tree_style)
      sizer.Add(self.tree_ctrl, 1, wx.EXPAND | wx.ALL, 5)
  
      image_list = wx.ImageList(16, 16)
      for i, state_flag in enumerate(
          (0, wx.CONTROL_CHECKED, wx.CONTROL_UNDETERMINED)
      ):
          for j, selection_flag in enumerate((0, wx.CONTROL_CURRENT)):
              idx = image_list.Add(
                  self.get_checkbox_bitmap(
                      state_flag | selection_flag, 16, 16
                  )
              )
      self.tree_ctrl.SetImageList(image_list)
      self.image_list = image_list
      image_index, selected_image_index = self.img_idx(d)
      root_id = self.tree_ctrl.AddRoot(
          "All", image_index, selected_image_index, d
      )
      self.tree_ctrl.SetItemImage(
          root_id, image_index, wx.TreeItemIcon_Normal
      )
      self.tree_ctrl.SetItemImage(
          root_id, selected_image_index, wx.TreeItemIcon_Selected
      )
      self.tree_ctrl.SetItemImage(
          root_id, image_index, wx.TreeItemIcon_Expanded
      )
      self.tree_ctrl.SetItemImage(
          root_id, image_index, wx.TreeItemIcon_SelectedExpanded
      )
      self.root_id = root_id
      self.tree_ctrl.SetItemHasChildren(root_id, len(d) > 1)
      self.Bind(
          wx.EVT_TREE_ITEM_EXPANDING, self.on_expanding, self.tree_ctrl
      )
      self.tree_ctrl.Bind(wx.EVT_LEFT_DOWN, self.on_left_down)
      self.tree_ctrl.Expand(root_id)
      table_sizer = wx.GridBagSizer()
      sizer.Add(table_sizer, 0, wx.EXPAND)
      table_sizer.Add(
          wx.StaticText(self, label="Key:"),
          (0, 0),
          flag=wx.LEFT | wx.RIGHT,
          border=3,
      )
      for i, (bitmap, description) in enumerate(
          (
              (
                  image_list.GetBitmap(0),
                  "No subitems selected / not selected",
              ),
              (
                  image_list.GetBitmap(2),
                  "All subitems selected / selected",
              ),
              (
                  image_list.GetBitmap(4),
                  "Some subitems selected. Open tree to see selections.",
              ),
          )
      ):
          bitmap_ctrl = wx.StaticBitmap(self)
          bitmap_ctrl.SetBitmap(bitmap)
          table_sizer.Add(bitmap_ctrl, (i, 1), flag=wx.RIGHT, border=5)
          table_sizer.Add(
              wx.StaticText(self, label=description), (i, 2)
          )
      table_sizer.AddGrowableCol(2)
      sizer.Add(
          self.CreateStdDialogButtonSizer(wx.CANCEL | wx.OK),
          flag=wx.CENTER,
      )
      self.Layout()
  
file_path: CellProfiler/src/frontend/cellprofiler/gui/_tree_checkbox_dialog.py
imports: import wx
label_desc: Use image node_id 1 to create a new TreeCheckboxDialog object from inherited base classes: wx with example: obj = TreeCheckboxDialog(parent, d)