def OnInitDialog(self):
self.editMenuCommand = self.GetDlgItem(win32ui.IDC_EDIT2)
self.butNew = self.GetDlgItem(win32ui.IDC_BUTTON3)
# Now hook the change notification messages for the edit controls.
self.HookCommand(self.OnCommandEditControls, win32ui.IDC_EDIT1)
self.HookCommand(self.OnCommandEditControls, win32ui.IDC_EDIT2)
self.HookNotify(self.OnNotifyListControl, commctrl.LVN_ITEMCHANGED)
self.HookNotify(self.OnNotifyListControlEndLabelEdit, commctrl.LVN_ENDLABELEDIT)
# Hook the button clicks.
self.HookCommand(self.OnButtonNew, win32ui.IDC_BUTTON3) # New Item
self.HookCommand(self.OnButtonDelete, win32ui.IDC_BUTTON4) # Delete item
self.HookCommand(self.OnButtonMove, win32ui.IDC_BUTTON1) # Move up
self.HookCommand(self.OnButtonMove, win32ui.IDC_BUTTON2) # Move down
# Setup the columns in the list control
lc = self.GetDlgItem(win32ui.IDC_LIST1)
rect = lc.GetWindowRect()
cx = rect[2] - rect[0]
colSize = cx/2 - win32api.GetSystemMetrics(win32con.SM_CXBORDER) - 1
item = commctrl.LVCFMT_LEFT, colSize, "Menu Text"
lc.InsertColumn(0, item)
item = commctrl.LVCFMT_LEFT, colSize, "Python Command"
lc.InsertColumn(1, item)
# Insert the existing tools menu
itemNo = 0
for desc, cmd in LoadToolMenuItems():
lc.InsertItem(itemNo, desc)
lc.SetItemText(itemNo, 1, cmd)
itemNo = itemNo + 1
self.listControl = lc
return dialog.PropertyPage.OnInitDialog(self)
评论列表
文章目录