Exemple #1
0
    def __init__(self,
                 parent,
                 name,
                 height_num_chars,
                 sizing_column_initial_width_num_chars,
                 columns,
                 data_to_tuples_func,
                 delete_key_callback=None,
                 activation_callback=None):

        wx.ListCtrl.__init__(self, parent, style=wx.LC_REPORT)
        ListCtrlAutoWidthMixin.__init__(self)

        self._data_to_tuples_func = data_to_tuples_func

        self._sort_column = 0
        self._sort_asc = True

        # eventually have it look up 'name' in some options somewhere and see previous height, width, and column selection
        # this thing should deal with missing entries but also have some filtered defaults for subs listctrl, which will have a bunch of possible columns

        self._indices_to_data_info = {}
        self._data_to_indices = {}

        (total_width, height) = ClientGUICommon.ConvertTextToPixels(
            self, (sizing_column_initial_width_num_chars, height_num_chars))

        resize_column = 1

        for (i, (name, width_num_chars)) in enumerate(columns):

            if width_num_chars == -1:

                width = -1

                resize_column = i + 1

            else:

                width = ClientGUICommon.ConvertTextToPixelWidth(
                    self, width_num_chars)

                total_width += width

            self.InsertColumn(i, name, width=width)

        self.setResizeColumn(resize_column)

        self.SetInitialSize((total_width, height))

        self._delete_key_callback = delete_key_callback
        self._activation_callback = activation_callback

        self.Bind(wx.EVT_KEY_DOWN, self.EventKeyDown)
        self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.EventItemActivated)

        self.Bind(wx.EVT_LIST_COL_BEGIN_DRAG, self.EventBeginColDrag)
        self.Bind(wx.EVT_LIST_COL_CLICK, self.EventColumnClick)
Exemple #2
0
    def GrowShrinkColumnsHeight(self, ideal_rows):

        # +2 for the header row and * 1.25 for magic rough text-to-rowheight conversion

        existing_min_width = self.GetMinClientSize()[0]

        (width_gumpf,
         ideal_client_height) = ClientGUICommon.ConvertTextToPixels(
             self, (20, int((ideal_rows + 2) * 1.25)))

        self.SetMinClientSize((existing_min_width, ideal_client_height))