TabList.py 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. """
  2. This file is part of RuneOptimizer.
  3. RuneOptimizer is free software: you can redistribute it and/or modify it
  4. under the terms of the GNU General Public License as published by the Free
  5. Software Foundation, either version 3 of the License, or (at your option)
  6. any later version.
  7. RuneOptimizer is distributed in the hope that it will be useful, but WITHOUT
  8. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  9. FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  10. more details.
  11. You should have received a copy of the GNU General Public License along with
  12. RuneOptimizer. If not, see <https://www.gnu.org/licenses/>.
  13. """
  14. class Tab_List(wx.Listbook):
  15. """
  16. The main menu.
  17. Parameters
  18. ----------
  19. panel_units : PanelUnits
  20. Unit details view.
  21. panel_teams : PanelTeams
  22. Team management view.
  23. panel_optimizer : PanelOptimizer
  24. Optimizer view.
  25. panel_results : PanelUnits
  26. Optimization results view.
  27. panel_info : PanelInfo
  28. Info view.
  29. """
  30. _panel_units = None
  31. _panel_teams = None
  32. _panel_optimizer = None
  33. _panel_results = None
  34. _panel_info = None
  35. @property
  36. def panel_units(self):
  37. return self._panel_units
  38. @property
  39. def panel_teams(self):
  40. return self._panel_teams
  41. @property
  42. def panel_optimizer(self):
  43. return self._panel_optimizer
  44. @property
  45. def panel_results(self):
  46. return self._panel_results
  47. @property
  48. def panel_info(self):
  49. return self._panel_inif
  50. def __init__(
  51. self, parent, id=wx.ID_ANY
  52. ):
  53. """
  54. Initializes the tablist.
  55. Sets upt all the items.
  56. Parameters
  57. ----------
  58. parent : wx.*
  59. Listbook parent.
  60. id : int, optional
  61. ID for the listbook (default wx.ID_ANY).
  62. """
  63. # Parent constructor
  64. wx.Listbook.__init__(
  65. self, parent, id=id, pos=(0, 0), size=(1000, 650), style=wx.BK_LEFT
  66. )
  67. # Load the icons
  68. icon_path = \
  69. os.path.dirname(os.path.realpath(__file__)) + "/res/icon/"
  70. if os.name == 'nt':
  71. icon_path = os.path.dirname(__file__)
  72. if icon_path == "":
  73. icon_path += "."
  74. icon_path += "\\res\\icon\\"
  75. il = wx.ImageList(50, 50)
  76. for ico in [
  77. "units.png", "teams.png", "optimize.png", "results.png", "info.png"
  78. ]:
  79. icon = wx.Bitmap(name=icon_path + ico, type=wx.BITMAP_TYPE_PNG)
  80. il.Add(icon)
  81. self.AssignImageList(il)
  82. # Create the entries
  83. self._panel_units = PanelUnits(self)
  84. self._panel_teams = PanelTeams(self)
  85. self._panel_optimizer = PanelOptimizer(self)
  86. self._panel_results = PanelResults(self)
  87. self._panel_info = PanelInfo(self)
  88. pages = [
  89. (self._panel_units, "Units"),
  90. (self._panel_teams, "Teams"),
  91. (self._panel_optimizer, "Optimize"),
  92. (self._panel_results, "Results"),
  93. (self._panel_info, "Info")
  94. ]
  95. # Add icons to the entries
  96. image_id = 0
  97. for page, label in pages:
  98. self.AddPage(page, label, imageId=image_id)
  99. image_id += 1
  100. # Binders for tab change
  101. self.Bind(wx.EVT_LISTBOOK_PAGE_CHANGED, self._on_page_changed)
  102. self.Bind(wx.EVT_LISTBOOK_PAGE_CHANGING, self._on_page_changing)
  103. def _on_page_changed(self, event):
  104. """
  105. Things to do once the tab has finished changing.
  106. Currently, it does nothing.
  107. Parameters
  108. ----------
  109. event : wx.Event, optional
  110. The event that triggered the call (default is None).
  111. """
  112. #old = event.GetOldSelection()
  113. #new = event.GetSelection()
  114. #sel = self.GetSelection()
  115. event.Skip()
  116. def _on_page_changing(self, event):
  117. """
  118. Things to do before changing tabs.
  119. Currently, it does nothing.
  120. Parameters
  121. ----------
  122. event : wx.Event, optional
  123. The event that triggered the call (default is None).
  124. """
  125. #old = event.GetOldSelection()
  126. #new = event.GetSelection()
  127. #sel = self.GetSelection()
  128. event.Skip()