track.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. """
  2. Variables set at initialization
  3. """
  4. global curr_disp
  5. curr_disp=""
  6. global ctrl_dict
  7. ctrl_dict={}
  8. class Track:
  9. """
  10. This class has functions and variables for tracking map display,
  11. associated notebook pages, and other index values.
  12. """
  13. def SetCtrlDict(self, idx, disp, page, tree):
  14. """
  15. This method stores the associated display index, display ID,
  16. controls book page ID, and map layer tree ID in a dictionary
  17. """
  18. global ctrl_dict
  19. ctrl_dict[idx]=[disp, page, tree]
  20. return ctrl_dict
  21. def GetCtrls(self, idx, num):
  22. """
  23. Returns widget ID for map display (num=0), controls book page
  24. (num=1), or map layer tree (num=2) for a given map display
  25. index (idx)
  26. """
  27. global ctrl_dict
  28. ctrls = ctrl_dict[idx][num]
  29. return ctrls
  30. def popCtrl(self, idx):
  31. """
  32. Removes entry from display and control dictionary.
  33. Used when display is closed
  34. """
  35. global ctrl_dict
  36. if ctrl_dict != "":
  37. ctrl_dict.pop(idx)
  38. def GetDisp_idx(self, ctrl_id):
  39. """
  40. Returns the display index for the display/controls dictionary entry
  41. given the widget ID of the control (ctrl_id)
  42. """
  43. global ctrl_dict
  44. for idx,ctrl in ctrl_dict.items():
  45. if ctrl_id in ctrl:
  46. return idx
  47. def SetDisp(self, disp_idx, disp_id):
  48. """
  49. Creates a tuple of the currently active display index and its corresponding
  50. map display frame ID.
  51. """
  52. global curr_disp
  53. curr_disp = (disp_idx, disp_id)
  54. return curr_disp
  55. def GetDisp(self):
  56. """
  57. Returns the (display index, display ID) tuple of the currently
  58. active display
  59. """
  60. global curr_disp
  61. return curr_disp