Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- import wx
- sizeh = 800
- sizev = 600
- class FiefMenu(wx.Frame):
- """ Fiefs Main Menu """
- def __init__(self, parent, title):
- wx.Frame.__init__(self, parent, title=title, size=(sizeh,sizev))
- # Create statusbar
- self.CreateStatusBar()
- # Create menubar
- filemenu = wx.Menu()
- viewmenu = wx.Menu()
- helpmenu = wx.Menu()
- # Create menubar
- menuBar = wx.MenuBar()
- menuBar.Append(filemenu, "&File")
- menuBar.Append(viewmenu, "&View")
- menuBar.Append(helpmenu, "&Help")
- self.SetMenuBar(menuBar)
- # Populate menus
- filemenu.Append(wx.ID_NEW, "&New Game", "New Game")
- filemenu.Append(wx.ID_OPEN, "&Load Game", "Load Game")
- filemenu.Append(wx.ID_SAVE, "&Save Game", "Save Game")
- filemenu.Append(wx.ID_EXIT, "E&xit FIEFS", "Exit FIEFS")
- self.consoletoggle = viewmenu.Append(0, "Show Game &Console", "Show Game Console", kind=wx.ITEM_CHECK)
- self.minimaptoggle = viewmenu.Append(1, "Show &Minimap", "Show Minimap", kind=wx.ITEM_CHECK)
- viewmenu.Check(0, True)
- viewmenu.Check(1, True)
- self.Bind(wx.EVT_MENU, self.ToggleConsole, id=0)
- # Divide the screen. We'll use a parent horizontal sizer
- # from the info panel and the buttons
- self.main_sizer = wx.BoxSizer(wx.HORIZONTAL)
- self.right_sizer = wx.BoxSizer(wx.VERTICAL)
- self.left_sizer = wx.BoxSizer(wx.VERTICAL)
- # stick the left and right sides of the window inside the main sizer
- self.main_sizer.Add(self.left_sizer, 4, wx.EXPAND)
- self.main_sizer.Add(self.right_sizer, 1, wx.EXPAND)
- # Add these controls to the left side of the screen (the map and the console)
- self.console_box = wx.TextCtrl(self, style=wx.TE_MULTILINE)
- self.main_map = wx.Button(self, -1, "This is where the map goes")
- # Draw the left side of the screen
- self.left_sizer.Add(self.main_map, 4, wx.EXPAND)
- self.left_sizer.Add(self.console_box, 1, wx.EXPAND)
- # Further divide the right side of the screen into 2 new regions
- self.right_sizer_bottom = wx.BoxSizer(wx.VERTICAL)
- self.right_sizer_top = wx.BoxSizer(wx.VERTICAL)
- self.right_sizer.Add(self.right_sizer_top, 4, wx.EXPAND)
- self.right_sizer.Add(self.right_sizer_bottom, 1, wx.EXPAND)
- # Add buttons as placeholders to the right side of the screen
- self.controlbuttons = []
- for i in range(0, 9):
- self.controlbuttons.append(wx.Button(self, -1, "Placeholder"+str(i)))
- self.right_sizer_top.Add(self.controlbuttons[i], 1, wx.EXPAND)
- # Draw our main window
- self.SetSizer(self.main_sizer)
- self.SetAutoLayout(1)
- self.main_sizer.Fit(self)
- self.Show(True)
- # the console was turned on or off
- def ToggleConsole(self, event):
- # currently does nothing but a redraw
- self.RedrawFrames()
- def RedrawFrames(self):
- """ This will repopulate the main window with the appropriate contexts """
- self.main_sizer.Fit(self)
- app = wx.App(False)
- frame = FiefMenu(None, 'Fiefs')
- app.MainLoop()
Add Comment
Please, Sign In to add comment