回答編集履歴

2

変数名の修正

2021/05/05 07:01

投稿

teamikl
teamikl

スコア8664

test CHANGED
@@ -62,7 +62,7 @@
62
62
 
63
63
  global checkedList
64
64
 
65
- checkedList = listbox.GetCheckedStrings()
65
+ checkedList = self.m_checkList1.GetCheckedStrings()
66
66
 
67
67
 
68
68
 
@@ -72,10 +72,10 @@
72
72
 
73
73
  # 選択された項目のリスト→ 選択されたitemリスト に変換。
74
74
 
75
- items = map(listbox.FindString, labels)
75
+ items = map(self.m_checkList1.FindString, labels)
76
76
 
77
77
  items = [x for x in items if x != wx.NOT_FOUND] # 項目が見つからなかった場合を省く
78
78
 
79
- listbox.SetCheckedItems(items)
79
+ self.m_checkList1.SetCheckedItems(items)
80
80
 
81
81
  ```

1

追記: 表示名を記録する場合の復元方法

2021/05/05 07:01

投稿

teamikl
teamikl

スコア8664

test CHANGED
@@ -41,3 +41,41 @@
41
41
 
42
42
 
43
43
  Items の値は、要素の内容が変わると変更される点には注意してください。
44
+
45
+
46
+
47
+
48
+
49
+ ----
50
+
51
+ 追記: 表示名を記録する場合の復元方法
52
+
53
+
54
+
55
+ ```python
56
+
57
+
58
+
59
+ checkedList = [] # 選択されたラベルのリスト (ファイルに記録する内容)
60
+
61
+ def button_save(event):
62
+
63
+ global checkedList
64
+
65
+ checkedList = listbox.GetCheckedStrings()
66
+
67
+
68
+
69
+ def button_load(event):
70
+
71
+ # FindString で項目が何番目かを探索
72
+
73
+ # 選択された項目のリスト→ 選択されたitemリスト に変換。
74
+
75
+ items = map(listbox.FindString, labels)
76
+
77
+ items = [x for x in items if x != wx.NOT_FOUND] # 項目が見つからなかった場合を省く
78
+
79
+ listbox.SetCheckedItems(items)
80
+
81
+ ```