def get_selected_rows(listCtrl: wx.ListCtrl) -> list:
    """    Gets the selected items for the list control.
    Selection is returned as a list of selected indices,
    low to high.
    """
    selection = []
    index = listCtrl.GetFirstSelected()
    while index >= 0:  # GetFirstSelected & GetNextSelected return -1 if there is nothing selected
        selection.append(index)
        index = listCtrl.GetNextSelected(index)

    return selection
Esempio n. 2
0
def dark_row_formatter(listctrl: wx.ListCtrl, dark: bool = False) -> None:
    """Toggles the row in a ListCtrl"""

    items = [listctrl.GetItem(i) for i in range(listctrl.GetItemCount())]

    for index, item in enumerate(items):
        if dark:
            if index % 2:
                item.SetBackgroundColor(DARK_BACKGROUND_COLOUR)
            else:
                item.SetBackgroundColor(DARK_LIGHTGREY_COLOUR)

        listctrl.SetItem(item)
Esempio n. 3
0
    def _set_data_view_with_df(grid: wx.ListCtrl, df: Optional[pd.DataFrame]):
        """Set data view with data frame."""
        grid.ClearAll()
        if df is None:
            return

        cols = df.columns.tolist()
        n_col = len(cols)
        for i, col in enumerate(cols):
            grid.InsertColumn(i, col)
        for i, row in df.iterrows():
            grid.InsertItem(i, row[cols[0]])
            for n in range(1, n_col):
                grid.SetItem(i, n, row[cols[n]])
Esempio n. 4
0
def listctrl(element, instance: wx.ListCtrl):
    props = {**element['props']}
    if 'style' in props:
        del props['style']
    set_basic_props(instance, props)
    # TODO: what events...?
    instance.DeleteAllColumns()
    instance.DeleteAllItems()
    for e, col in enumerate(props.get('column_defs', [])):
        instance.InsertColumn(e, col['title'])

    for row_idx, item in enumerate(props.get('data', [])):
        instance.InsertItem(row_idx, '')
        for col_idx, coldef in enumerate(props.get('column_defs', [])):
            instance.SetItem(row_idx, col_idx, coldef['column'](item))
    return instance
Esempio n. 5
0
def dark_row_formatter(listctrl: wx.ListCtrl, dark: bool = False) -> None:
    """Toggles the row in a ListCtrl"""

    items = [listctrl.GetItem(i) for i in range(listctrl.GetItemCount())]

    for index, item in enumerate(items):
        if dark:
            if index % 2:
                item.SetBackgroundColor("Dark Grey")
            else:
                item.SetBackgroundColor("Light Grey")
        else:
            if index % 2:
                item.SetBackgroundColor("Light Blue")
            else:
                item.SetBackgroundColor("Yellow")

        listctrl.SetItem(item)
Esempio n. 6
0
    def SetItemData(self, item, data):
        retval = ListCtrl.SetItemData(self, item, data)

        datamap = list()
        for col in xrange(0, self.GetColumnCount()):
            listitem = self.GetItem(item, col)
            datamap.append(listitem.GetText())

        self.itemDataMap[item] = datamap
        return retval
Esempio n. 7
0
 def __init__(self, *args, **kwargs):
     # *args, **kwargs ensures it can be used with GUI builders unmodified
     ListCtrl.__init__(self, *args, **kwargs)
     # Initialize needed dictionary for ColumSorterMixin
     self.itemDataMap = dict()
     ColumnSorterMixin.__init__(self, 0)  # start with 0 columns
Esempio n. 8
0
    def __init__(self):
        self.cols = {}

        ListCtrl.__init__(self)
        self.Bind(EVT_WINDOW_CREATE, self.on_create)
Esempio n. 9
0
 def DeleteItem(self, item):
     data = self.GetItemData(item)
     self.itemDataMap.pop(data, None)  # try to delete and avoid errors
     return ListCtrl.DeleteItem(item)
Esempio n. 10
0
 def DeleteAllItems(self):
     self.itemDataMap.clear()
     return ListCtrl.DeleteAllItems(self)
Esempio n. 11
0
 def DeleteAllColumns(self):
     retval = ListCtrl.DeleteAllColumns(self)
     ColumnSorterMixin.SetColumnCount(self, self.GetColumnCount())
     return retval
Esempio n. 12
0
 def DeleteColumn(self, col):
     retval = ListCtrl.DeleteColumn(self, col)
     ColumnSorterMixin.SetColumnCount(self, self.GetColumnCount())
     return retval
Esempio n. 13
0
 def InsertColumn(self, col, info):
     retval = ListCtrl.InsertColumn(self, *args, **kwargs)
     ColumnSorterMixin.SetColumnCount(self, self.GetColumnCount())
     return retval
Esempio n. 14
0
 def __init__(self, *args, **kwargs):
     # *args, **kwargs ensures it can be used with GUI builders unmodified
     ListCtrl.__init__(self, *args, **kwargs)
     # Initialize needed dictionary for ColumSorterMixin
     self.itemDataMap = dict()
     ColumnSorterMixin.__init__(self, 0)  # start with 0 columns
Esempio n. 15
0
File: tools.py Progetto: Kjir/dnm
 def __init__(self, parent, id, style, sort=5):
     ListCtrl.__init__(self, parent, id, style=style)
     ListCtrlAutoWidthMixin.__init__(self)
     ColumnSorterMixin.__init__(self, sort)