regedit.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:CodeReader 作者: jasonrbr 项目源码 文件源码
def EditValue(self, item):
        # Edit the current value
        class EditDialog(dialog.Dialog):
            def __init__(self, item):
                self.item = item
                dialog.Dialog.__init__(self, win32ui.IDD_LARGE_EDIT)
            def OnInitDialog(self):
                self.SetWindowText("Enter new value")
                self.GetDlgItem(win32con.IDCANCEL).ShowWindow(win32con.SW_SHOW)
                self.edit = self.GetDlgItem(win32ui.IDC_EDIT1)
                # Modify the edit windows style
                style = win32api.GetWindowLong(self.edit.GetSafeHwnd(), win32con.GWL_STYLE)
                style = style & (~win32con.ES_WANTRETURN)
                win32api.SetWindowLong(self.edit.GetSafeHwnd(), win32con.GWL_STYLE, style)
                self.edit.SetWindowText(str(self.item))
                self.edit.SetSel(-1)
                return dialog.Dialog.OnInitDialog(self)
            def OnDestroy(self,msg):
                self.newvalue = self.edit.GetWindowText()

        try:
            index = self.GetNextItem(-1, commctrl.LVNI_SELECTED)
        except win32ui.error:
            return # No item selected.

        if index==0:
            keyVal = ""
        else:
            keyVal = self.GetItemText(index,0)
        # Query for a new value.
        try:
            newVal = self.GetItemsCurrentValue(item, keyVal)
        except TypeError as details:
            win32ui.MessageBox(details)
            return

        d = EditDialog(newVal)
        if d.DoModal()==win32con.IDOK:
            try:
                self.SetItemsCurrentValue(item, keyVal, d.newvalue)
            except win32api.error as exc:
                win32ui.MessageBox("Error setting value\r\n\n%s" % exc.strerror)
            self.UpdateForRegItem(item)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号