TabList.py 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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 TabList(wx.Listbook):
  15. """
  16. The main menu.
  17. Parameters
  18. ----------
  19. frameUnits : PanelUnits
  20. Unit details view.
  21. frameTeams : PanelTeams
  22. Team management view.
  23. frameOptimizer : PanelOptimizer
  24. Optimizer view.
  25. frameResults : PanelUnits
  26. Optimization results view.
  27. frameInfo : PanelInfo
  28. Info view.
  29. Methods
  30. -------
  31. OnPageChanged(event)
  32. Things to do once the tab has finished changing.
  33. OnPageChanging(event)
  34. Things to do before changing tabs.
  35. """
  36. frameUnits = None
  37. frameTeams = None
  38. frameOptimizer = None
  39. frameResults = None
  40. frameInfo = None
  41. def __init__(
  42. self, parent, id=wx.ID_ANY
  43. ):
  44. """
  45. Initializes the tablist.
  46. Sets upt all the items.
  47. Parameters
  48. ----------
  49. parent : wx.*
  50. Listbook parent.
  51. id : int, optional
  52. ID for the listbook (default wx.ID_ANY).
  53. """
  54. # Parent constructor
  55. wx.Listbook.__init__(
  56. self, parent, id=id, pos=(0, 0), size=(800, 600), style=wx.BK_LEFT
  57. )
  58. # Load the icons
  59. iconPath = \
  60. os.path.dirname(os.path.realpath(__file__)) + "/res/icon/"
  61. if os.name == 'nt':
  62. iconPath = os.path.dirname(__file__)
  63. if iconPath == "":
  64. iconPath += "."
  65. iconPath += "\\res\\icon\\"
  66. il = wx.ImageList(50, 50)
  67. for ico in [
  68. "units.png", "teams.png", "optimize.png", "results.png", "info.png"
  69. ]:
  70. icon = wx.Bitmap(name=iconPath + ico, type=wx.BITMAP_TYPE_PNG)
  71. il.Add(icon)
  72. self.AssignImageList(il)
  73. # Create the entries
  74. self.frameUnits = PanelUnits(self)
  75. self.frameTeams = PanelTeams(self)
  76. self.frameOptimizer = PanelOptimizer(self)
  77. self.frameResults = PanelResults(self)
  78. self.frameInfo = PanelInfo(self)
  79. pages = [
  80. (self.frameUnits, "Units"),
  81. (self.frameTeams, "Teams"),
  82. (self.frameOptimizer, "Optimize"),
  83. (self.frameResults, "Results"),
  84. (self.frameInfo, "Info")
  85. ]
  86. # Add icons to the entries
  87. imID = 0
  88. for page, label in pages:
  89. self.AddPage(page, label, imageId=imID)
  90. imID += 1
  91. # Binders for tab change
  92. self.Bind(wx.EVT_LISTBOOK_PAGE_CHANGED, self.OnPageChanged)
  93. self.Bind(wx.EVT_LISTBOOK_PAGE_CHANGING, self.OnPageChanging)
  94. def OnPageChanged(self, event):
  95. """
  96. Things to do once the tab has finished changing.
  97. Currently, it does nothing.
  98. Parameters
  99. ----------
  100. event : wx.Event, optional
  101. The event that triggered the call (default is None).
  102. """
  103. #old = event.GetOldSelection()
  104. #new = event.GetSelection()
  105. #sel = self.GetSelection()
  106. event.Skip()
  107. def OnPageChanging(self, event):
  108. """
  109. Things to do before changing tabs.
  110. Currently, it does nothing.
  111. Parameters
  112. ----------
  113. event : wx.Event, optional
  114. The event that triggered the call (default is None).
  115. """
  116. #old = event.GetOldSelection()
  117. #new = event.GetSelection()
  118. #sel = self.GetSelection()
  119. event.Skip()