Guest User

Untitled

a guest
Nov 24th, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.22 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3. import wx
  4.  
  5. sizeh = 800
  6. sizev = 600
  7.  
  8. class FiefMenu(wx.Frame):
  9. """ Fiefs Main Menu """
  10. def __init__(self, parent, title):
  11. wx.Frame.__init__(self, parent, title=title, size=(sizeh,sizev))
  12.  
  13. # Create statusbar
  14. self.CreateStatusBar()
  15.  
  16. # Create menubar
  17. filemenu = wx.Menu()
  18. viewmenu = wx.Menu()
  19. helpmenu = wx.Menu()
  20.  
  21. # Create menubar
  22. menuBar = wx.MenuBar()
  23. menuBar.Append(filemenu, "&File")
  24. menuBar.Append(viewmenu, "&View")
  25. menuBar.Append(helpmenu, "&Help")
  26. self.SetMenuBar(menuBar)
  27.  
  28. # Populate menus
  29. filemenu.Append(wx.ID_NEW, "&New Game", "New Game")
  30. filemenu.Append(wx.ID_OPEN, "&Load Game", "Load Game")
  31. filemenu.Append(wx.ID_SAVE, "&Save Game", "Save Game")
  32. filemenu.Append(wx.ID_EXIT, "E&xit FIEFS", "Exit FIEFS")
  33.  
  34. self.consoletoggle = viewmenu.Append(0, "Show Game &Console", "Show Game Console", kind=wx.ITEM_CHECK)
  35. self.minimaptoggle = viewmenu.Append(1, "Show &Minimap", "Show Minimap", kind=wx.ITEM_CHECK)
  36. viewmenu.Check(0, True)
  37. viewmenu.Check(1, True)
  38. self.Bind(wx.EVT_MENU, self.ToggleConsole, id=0)
  39.  
  40. # Divide the screen. We'll use a parent horizontal sizer
  41. # from the info panel and the buttons
  42. self.main_sizer = wx.BoxSizer(wx.HORIZONTAL)
  43. self.right_sizer = wx.BoxSizer(wx.VERTICAL)
  44. self.left_sizer = wx.BoxSizer(wx.VERTICAL)
  45.  
  46. # stick the left and right sides of the window inside the main sizer
  47. self.main_sizer.Add(self.left_sizer, 4, wx.EXPAND)
  48. self.main_sizer.Add(self.right_sizer, 1, wx.EXPAND)
  49.  
  50. # Add these controls to the left side of the screen (the map and the console)
  51. self.console_box = wx.TextCtrl(self, style=wx.TE_MULTILINE)
  52. self.main_map = wx.Button(self, -1, "This is where the map goes")
  53.  
  54. # Draw the left side of the screen
  55. self.left_sizer.Add(self.main_map, 4, wx.EXPAND)
  56. self.left_sizer.Add(self.console_box, 1, wx.EXPAND)
  57.  
  58. # Further divide the right side of the screen into 2 new regions
  59. self.right_sizer_bottom = wx.BoxSizer(wx.VERTICAL)
  60. self.right_sizer_top = wx.BoxSizer(wx.VERTICAL)
  61. self.right_sizer.Add(self.right_sizer_top, 4, wx.EXPAND)
  62. self.right_sizer.Add(self.right_sizer_bottom, 1, wx.EXPAND)
  63.  
  64. # Add buttons as placeholders to the right side of the screen
  65. self.controlbuttons = []
  66. for i in range(0, 9):
  67. self.controlbuttons.append(wx.Button(self, -1, "Placeholder"+str(i)))
  68. self.right_sizer_top.Add(self.controlbuttons[i], 1, wx.EXPAND)
  69.  
  70. # Draw our main window
  71. self.SetSizer(self.main_sizer)
  72. self.SetAutoLayout(1)
  73.  
  74. self.main_sizer.Fit(self)
  75. self.Show(True)
  76.  
  77. # the console was turned on or off
  78. def ToggleConsole(self, event):
  79. # currently does nothing but a redraw
  80. self.RedrawFrames()
  81.  
  82. def RedrawFrames(self):
  83. """ This will repopulate the main window with the appropriate contexts """
  84. self.main_sizer.Fit(self)
  85.  
  86. app = wx.App(False)
  87. frame = FiefMenu(None, 'Fiefs')
  88. app.MainLoop()
Add Comment
Please, Sign In to add comment