diff --git a/gui/mainFrame.py b/gui/mainFrame.py index bed52d091..1668f0fa2 100644 --- a/gui/mainFrame.py +++ b/gui/mainFrame.py @@ -40,9 +40,6 @@ class MainFrame(wx.Frame): self.SetMinSize((1000, 700)) self.SetSize((1000, 700)) - #Register menubar events / only quit for now - self.Bind(wx.EVT_MENU, self.ExitApp, id=wx.ID_EXIT) - self.Bind(wx.EVT_MENU, self.ShowAboutBox, id=wx.ID_ABOUT) self.splitter = wx.SplitterWindow(self, style = wx.SP_LIVE_UPDATE) @@ -77,6 +74,8 @@ class MainFrame(wx.Frame): self.SetMenuBar(MainMenuBar()) self.SetToolBar(MainToolBar(self)) + self.registerMenu() + #Show ourselves self.Show() @@ -84,10 +83,26 @@ class MainFrame(wx.Frame): self.Close() def ShowAboutBox(self, evt): - info = wx.AboutDialogInfo() - info.Name = "pyfa" - info.Version = aboutData.versionString - info.Description = wordwrap(aboutData.description + "\n\n\nDevelopers: " + ", ".join(aboutData.developers) + "\nLicense: " + aboutData.license + " see included " + aboutData.licenseLocation, - 350, wx.ClientDC(self)) - info.WebSite = ("http://pyfa.sourceforge.net/", "pyfa home page") - wx.AboutBox(info) + info = wx.AboutDialogInfo() + info.Name = "pyfa" + info.Version = aboutData.versionString + info.Description = wordwrap(aboutData.description + "\n\n\nDevelopers: " + ", ".join(aboutData.developers) + "\nLicense: " + aboutData.license + " see included " + aboutData.licenseLocation, + 350, wx.ClientDC(self)) + info.WebSite = ("http://pyfa.sourceforge.net/", "pyfa home page") + wx.AboutBox(info) + + def registerMenu(self): + # Quit + self.Bind(wx.EVT_MENU, self.ExitApp, id=wx.ID_EXIT) + + # About + self.Bind(wx.EVT_MENU, self.ShowAboutBox, id=wx.ID_ABOUT) + + #Ship browser + self.Bind(wx.EVT_MENU, self.toggleShipBrowser, id=10) + + def toggleShipBrowser(self, event): + toolbar = self.GetToolBar() + toolbar.ToggleTool(10, not toolbar.GetToolState(10)) + toolbar.toggleShipBrowser(event) + diff --git a/gui/mainMenuBar.py b/gui/mainMenuBar.py index 761f9659f..bbc064ee3 100644 --- a/gui/mainMenuBar.py +++ b/gui/mainMenuBar.py @@ -40,7 +40,7 @@ class MainMenuBar(wx.MenuBar): # Fit menu fitMenu = wx.Menu() self.Append(fitMenu, "F&it") - shipBrowserItem = wx.MenuItem(fitMenu, wx.ID_ANY, "Ship &Browser") + shipBrowserItem = wx.MenuItem(fitMenu, 10, "Toggle Ship &Browser") shipBrowserItem.SetBitmap(bitmapLoader.getBitmap("ship_small", "icons")) fitMenu.AppendItem(shipBrowserItem) fitMenu.AppendSeparator() @@ -56,7 +56,7 @@ class MainMenuBar(wx.MenuBar): charMenu = wx.Menu() self.Append(charMenu, "&Character") - charEditItem = wx.MenuItem(charMenu, wx.ID_ANY, "Character &Editor") + charEditItem = wx.MenuItem(charMenu, 20, "Character &Editor") charEditItem.SetBitmap(bitmapLoader.getBitmap("character_small", "icons")) charMenu.AppendItem(charEditItem) diff --git a/gui/mainToolBar.py b/gui/mainToolBar.py index 9921961f4..d513ac10e 100644 --- a/gui/mainToolBar.py +++ b/gui/mainToolBar.py @@ -29,19 +29,22 @@ class MainToolBar(wx.ToolBar): self.AddCheckLabelTool(10, "Ship Browser", bitmapLoader.getBitmap("ship_big", "icons"), shortHelp="Ship browser") self.AddCheckLabelTool(20, "Character Editor", bitmapLoader.getBitmap("character_big", "icons"), shortHelp="Character editor") - self.Bind(wx.EVT_TOOL, self.shipBrowserToggle, id=10) - self.Bind(wx.EVT_TOOL, self.characterEditor, id=20) + self.Bind(wx.EVT_TOOL, self.toggleShipBrowser, id=10) + self.Bind(wx.EVT_TOOL, self.toggleCharacterBrowser, id=20) self.Realize() gui.mainFrame.MainFrame.getInstance().shipBrowser.Hide() - def shipBrowserToggle(self, event): + def toggleShipBrowser(self, event): newState = self.GetToolState(10) mainFrame = gui.mainFrame.MainFrame.getInstance() + if newState: + mainFrame.shipBrowser.build() + mainFrame.shipBrowser.Show(newState) mainFrame.marketBrowser.Show(not newState) mainFrame.marketShipBrowserSizer.Layout() - def characterEditor(self, event): + def toggleCharacterBrowser(self, event): print event diff --git a/gui/shipBrowser.py b/gui/shipBrowser.py index c944d05ef..471d4a2a9 100644 --- a/gui/shipBrowser.py +++ b/gui/shipBrowser.py @@ -4,6 +4,7 @@ import bitmapLoader class ShipBrowser(wx.Panel): def __init__(self, parent): + self.built = False wx.Panel.__init__(self, parent) vbox = wx.BoxSizer(wx.VERTICAL) self.SetSizer(vbox) @@ -16,16 +17,6 @@ class ShipBrowser(wx.Panel): self.shipRoot = self.shipView.AddRoot("Ships") - iconId = self.shipImageList.Add(bitmapLoader.getBitmap("ship_small", "icons")) - - cMarket = controller.Market.getInstance() - shipRoot = cMarket.getShipRoot() - for id, name in shipRoot: - childId = self.shipView.AppendItem(self.shipRoot, name, iconId, data=wx.TreeItemData(id)) - self.shipView.AppendItem(childId, "dummy") - - self.shipView.SortChildren(self.shipRoot) - self.raceImageIds = {} self.races = ["amarr", "caldari", "gallente", "minmatar", "ore", "serpentis", "angel", "blood", "sansha", "guristas"] for race in self.races: @@ -39,6 +30,17 @@ class ShipBrowser(wx.Panel): self.shipView.races = self.races self.shipView.idRaceMap = self.idRaceMap + def build(self): + if not self.built: + self.built = True + cMarket = controller.Market.getInstance() + shipRoot = cMarket.getShipRoot() + iconId = self.shipImageList.Add(bitmapLoader.getBitmap("ship_small", "icons")) + for id, name in shipRoot: + childId = self.shipView.AppendItem(self.shipRoot, name, iconId, data=wx.TreeItemData(id)) + self.shipView.AppendItem(childId, "dummy") + + self.shipView.SortChildren(self.shipRoot) def expandLookup(self, event): root = event.Item child, cookie = self.shipView.GetFirstChild(root)