diff --git a/config.py b/config.py new file mode 100644 index 000000000..3c9394f2c --- /dev/null +++ b/config.py @@ -0,0 +1,5 @@ +import os.path +import sys + +#Path autodetection, only change if it doesn't work +path = os.path.dirname(unicode(__file__, sys.getfilesystemencoding())) diff --git a/gui/bitmapLoader.py b/gui/bitmapLoader.py new file mode 100644 index 000000000..6f0b446f7 --- /dev/null +++ b/gui/bitmapLoader.py @@ -0,0 +1,28 @@ +#=============================================================================== +# Copyright (C) 2010 Diego Duclos +# +# This file is part of pyfa. +# +# pyfa is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# pyfa is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with pyfa. If not, see . +#=============================================================================== + +import os.path +import config +import wx + +def getBitmap(name, parent): + bitmap = wx.StaticBitmap(parent) + path = os.path.join(config.path, "icons", name + ".png") + bitmap.SetBitmap(wx.Image(path).ConvertToBitmap()) + return bitmap diff --git a/gui/mainFrame.py b/gui/mainFrame.py new file mode 100644 index 000000000..2b61a7db8 --- /dev/null +++ b/gui/mainFrame.py @@ -0,0 +1,32 @@ +#=============================================================================== +# Copyright (C) 2010 Diego Duclos +# +# This file is part of pyfa. +# +# pyfa is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# pyfa is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with pyfa. If not, see . +#=============================================================================== + +import wx +from gui.mainMenuBar import MainMenuBar +from gui.mainToolBar import MainToolBar + +class MainFrame(wx.Frame): + def __init__(self): + wx.Frame.__init__(self, None, wx.ID_ANY, title="pyfa - Python Fitting Assistant", size=(1200,800)) + #Show ourselves + self.Show() + + #Add menu + self.SetMenuBar(MainMenuBar()) + self.SetToolBar(MainToolBar(self)) diff --git a/gui/mainMenuBar.py b/gui/mainMenuBar.py new file mode 100644 index 000000000..6ead50bfe --- /dev/null +++ b/gui/mainMenuBar.py @@ -0,0 +1,57 @@ +#=============================================================================== +# Copyright (C) 2010 Diego Duclos +# +# This file is part of pyfa. +# +# pyfa is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# pyfa is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with pyfa. If not, see . +#=============================================================================== + +import wx + +class MainMenuBar(wx.MenuBar): + def __init__(self): + wx.MenuBar.__init__(self) + + # File menu + fileMenu = wx.Menu() + self.Append(fileMenu, "&File") + + fileMenu.Append(wx.ID_OPEN, "&Import", "Import a fit into pyfa.") + fileMenu.Append(wx.ID_SAVEAS, "&Export", "Export the fit to another format.") + fileMenu.AppendSeparator() + fileMenu.Append(wx.ID_EXIT,"E&xit"," Terminate the program.") + + + # Edit menu + editMenu = wx.Menu() + self.Append(editMenu, "&Edit") + + editMenu.Append(wx.ID_UNDO, "&Undo", "Undo the last action on this fit.") + editMenu.Append(wx.ID_REDO, "&Redo", "Redo the last undone action.") + editMenu.Append(wx.ID_UNDELETE, "Un&delete", "Recover the last deleted fit, if any.") + + # Fit menu + fitMenu = wx.Menu() + self.Append(fitMenu, "F&it") + + fitMenu.Append(wx.ID_NEW, "&New", "Create a new fit.").GetBitmap() + fitMenu.Append(wx.ID_EDIT, "&Rename", "Rename this fit.").GetBitmap() + fitMenu.Append(wx.ID_COPY, "&Copy", "Copy this fit.").GetBitmap() + fitMenu.Append(wx.ID_DELETE, "&Delete", "Delete this fit.").GetBitmap() + + # Help menu + helpMenu = wx.Menu() + self.Append(helpMenu, "&Help") + helpMenu.Append(wx.ID_ABOUT, "&About", "About this program") + helpMenu.Append(wx.ID_HELP, "User manual", "User manual") diff --git a/gui/mainToolBar.py b/gui/mainToolBar.py new file mode 100644 index 000000000..ca3795f68 --- /dev/null +++ b/gui/mainToolBar.py @@ -0,0 +1,37 @@ +#=============================================================================== +# Copyright (C) 2010 Diego Duclos +# +# This file is part of pyfa. +# +# pyfa is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# pyfa is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with pyfa. If not, see . +#=============================================================================== + +import wx +from gui import bitmapLoader + +class MainToolBar(wx.ToolBar): + def __init__(self, parent): + wx.ToolBar.__init__(self, parent, wx.ID_ANY) + + self.AddControl(bitmapLoader.getBitmap("ships", self)) + self.AddLabelTool(wx.ID_NEW, "New fit", wx.ArtProvider.GetBitmap(wx.ART_NEW, wx.ART_TOOLBAR)) + self.AddLabelTool(wx.ID_COPY, "Copy fit", wx.ArtProvider.GetBitmap(wx.ART_COPY, wx.ART_TOOLBAR)) + self.AddLabelTool(wx.ID_DELETE, "Delete fit", wx.ArtProvider.GetBitmap(wx.ART_DELETE, wx.ART_TOOLBAR)) + + self.AddSeparator() + self.AddLabelTool(wx.ID_OPEN, "Import fit", wx.ArtProvider.GetBitmap(wx.ART_FILE_OPEN, wx.ART_TOOLBAR)) + self.AddLabelTool(wx.ID_SAVEAS, "Export fit", wx.ArtProvider.GetBitmap(wx.ART_FILE_SAVE_AS, wx.ART_TOOLBAR)) + + + self.Realize() diff --git a/icons/ships.png b/icons/ships.png new file mode 100644 index 000000000..07cbbe134 Binary files /dev/null and b/icons/ships.png differ diff --git a/run.py b/run.py index de1b45e9f..29f504406 100644 --- a/run.py +++ b/run.py @@ -16,3 +16,13 @@ # You should have received a copy of the GNU Affero General Public License # along with pyfa. If not, see . #=============================================================================== + +from gui.mainFrame import MainFrame +import wx +import os +import sys + +if __name__ == "__main__": + pyfa = wx.App(False) + MainFrame() + pyfa.MainLoop()