ListCtrl - wxPython / Python

My question is whether we can assign / bind some value to a specific element and hide that value (or if we can do the same thing differently).

Example: Let's say that the columns in ListCtrl are "Name" and "Description":

self.lc = wx.ListCtrl(self, -1, style=wx.LC_REPORT)
self.lc.InsertColumn(0, 'Name')
self.lc.InsertColumn(1, 'Description')

And when I add the item, I want them to display the Name parameter and description:

num_items = self.lc.GetItemCount()
        self.lc.InsertStringItem(num_items, "Randomname")
        self.lc.SetStringItem(num_items, 1, "Some description here")

Now what I want to do is basically assign something to this element that is not showing, so I can access the application later.

So, I would like to add something that is not shown in the application, but is on the value of the element, for example:

hiddendescription = "Somerandomthing"

Still not upset? Well, let's say I add a button to add an item with some other TextCtrls to set parameters, and TextCtrls parameters:

"Name"

""

"Hiddendescription"

, , , "HiddenDescription", , .

1 , , , .

+3
4

wxListCtrl , , - :

SetItemData

GetItemData

FindItemData

wxListItem GetData SetData.

+4

ListCtrl /dict , , ListCtrl .

:

class MyObject(object):
    def __init__(self, name, description, hidden_description):
        self.name = name
        self.description = description
        self.hidden_description = hidden_description

:

def __init__(self):
    self.my_items = {}
    self.lc = wx.ListCtrl(self, -1, style=wx.LC_REPORT)
    self.lc.InsertColumn(0, 'Name')
    self.lc.InsertColumn(1, 'Description')

def addItemToMyListCtrl(self, name, description, hidden):
    new_item = MyObject(name, description, hidden)
    self.my_items[name] = new_item
    self.lc.Append((new_item.name, new_item.description))

, , , .

+7

, , . ++ (-wx), .

+1

wx.ListCtrl python wx.TreeCtrl SetPyData() ( GetPyData()).

, , , python , , , .

wx.ListCtrl , , , .

SetItemData() int int dict ( , ), . tgray , , , , .

+1

Source: https://habr.com/ru/post/1741518/


All Articles