regpy.py 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. # (sort-of) Registry editor
  2. import win32ui
  3. import dialog
  4. import win32con
  5. import commctrl
  6. class RegistryControl:
  7. def __init__(self, key):
  8. self.key = key
  9. class RegEditPropertyPage(dialog.PropertyPage):
  10. IDC_LISTVIEW = 1000
  11. def GetTemplate(self):
  12. "Return the template used to create this dialog"
  13. w = 152 # Dialog width
  14. h = 122 # Dialog height
  15. SS_STD = win32con.WS_CHILD | win32con.WS_VISIBLE
  16. FRAMEDLG_STD = win32con.WS_CAPTION | win32con.WS_SYSMENU
  17. style = FRAMEDLG_STD | win32con.WS_VISIBLE | win32con.DS_SETFONT | win32con.WS_MINIMIZEBOX
  18. template = [[self.caption, (0, 0, w, h), style, None, (8, 'Helv')], ]
  19. lvStyle = SS_STD | commctrl.LVS_EDITLABELS | commctrl.LVS_REPORT | commctrl.LVS_AUTOARRANGE | commctrl.LVS_ALIGNLEFT | win32con.WS_BORDER | win32con.WS_TABSTOP
  20. template.append(["SysListView32", "", self.IDC_LISTVIEW, (10, 10, 185, 100), lvStyle])
  21. return template
  22. class RegistryPage(RegEditPropertyPage):
  23. def __init__(self):
  24. self.caption="Path"
  25. RegEditPropertyPage.__init__(self, self.GetTemplate())
  26. def OnInitDialog(self):
  27. self.listview = self.GetDlgItem(self.IDC_LISTVIEW)
  28. RegEditPropertyPage.OnInitDialog(self)
  29. # Setup the listview columns
  30. itemDetails = (commctrl.LVCFMT_LEFT, 100, "App", 0)
  31. self.listview.InsertColumn(0, itemDetails)
  32. itemDetails = (commctrl.LVCFMT_LEFT, 1024, "Paths", 0)
  33. self.listview.InsertColumn(1, itemDetails)
  34. index = self.listview.InsertItem(0,"App")
  35. self.listview.SetItemText(index, 1, "Path")
  36. class RegistrySheet(dialog.PropertySheet):
  37. def __init__(self, title):
  38. dialog.PropertySheet.__init__(self, title)
  39. self.HookMessage(self.OnActivate, win32con.WM_ACTIVATE)
  40. def OnActivate(self, msg):
  41. print("OnAcivate")
  42. def t():
  43. ps=RegistrySheet('Registry Settings')
  44. ps.AddPage(RegistryPage())
  45. ps.DoModal()
  46. if __name__=='__main__':
  47. t()