| 53 | return |
| 54 | |
| 55 | def PopulateList(self): |
| 56 | self.paramList.InsertColumn(0, _t("Attribute")) |
| 57 | self.paramList.InsertColumn(1, _t("Current Value")) |
| 58 | self.paramList.SetColumnWidth(0, 110) |
| 59 | self.paramList.SetColumnWidth(1, 1500) |
| 60 | self.paramList.setResizeColumn(0) |
| 61 | |
| 62 | if self.stuff: |
| 63 | names = dir(self.stuff) |
| 64 | else: |
| 65 | names = dir(self.item) |
| 66 | |
| 67 | names = [a for a in names if not (a.startswith('__') and a.endswith('__'))] |
| 68 | |
| 69 | idNameMap = {} |
| 70 | idCount = 0 |
| 71 | for name in names: |
| 72 | try: |
| 73 | if self.stuff: |
| 74 | attrName = name.title() |
| 75 | value = getattr(self.stuff, name) |
| 76 | else: |
| 77 | attrName = name.title() |
| 78 | value = getattr(self.item, name) |
| 79 | |
| 80 | index = self.paramList.InsertItem(self.paramList.GetItemCount(), attrName) |
| 81 | # index = self.paramList.InsertImageStringItem(sys.maxint, attrName) |
| 82 | idNameMap[idCount] = attrName |
| 83 | self.paramList.SetItemData(index, idCount) |
| 84 | idCount += 1 |
| 85 | |
| 86 | valueUnit = str(value) |
| 87 | |
| 88 | self.paramList.SetItem(index, 1, valueUnit) |
| 89 | except (KeyboardInterrupt, SystemExit): |
| 90 | raise |
| 91 | except: |
| 92 | # TODO: Add logging to this. |
| 93 | # We couldn't get a property for some reason. Skip it for now. |
| 94 | continue |
| 95 | |
| 96 | self.paramList.SortItems(lambda id1, id2: (idNameMap[id1] > idNameMap[id2]) - (idNameMap[id1] < idNameMap[id2])) |
| 97 | self.paramList.RefreshRows() |
| 98 | self.totalAttrsLabel.SetLabel(_t("%d attribute.", "%d attributes.", idCount) % idCount) |
| 99 | self.Layout() |