First draft of the menu and toolbar for the new interface.

This commit is contained in:
cncfanatics
2010-08-12 17:20:10 +02:00
parent e064963607
commit 263bb9ae7c
7 changed files with 169 additions and 0 deletions

5
config.py Normal file
View File

@@ -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()))

28
gui/bitmapLoader.py Normal file
View File

@@ -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 <http://www.gnu.org/licenses/>.
#===============================================================================
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

32
gui/mainFrame.py Normal file
View File

@@ -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 <http://www.gnu.org/licenses/>.
#===============================================================================
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))

57
gui/mainMenuBar.py Normal file
View File

@@ -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 <http://www.gnu.org/licenses/>.
#===============================================================================
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")

37
gui/mainToolBar.py Normal file
View File

@@ -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 <http://www.gnu.org/licenses/>.
#===============================================================================
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()

BIN
icons/ships.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

10
run.py
View File

@@ -16,3 +16,13 @@
# You should have received a copy of the GNU Affero General Public License
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
#===============================================================================
from gui.mainFrame import MainFrame
import wx
import os
import sys
if __name__ == "__main__":
pyfa = wx.App(False)
MainFrame()
pyfa.MainLoop()