Add export to clipboard and gray out export menus when applicable
This commit is contained in:
@@ -157,6 +157,7 @@ class MainFrame(wx.Frame):
|
|||||||
dlg.Destroy()
|
dlg.Destroy()
|
||||||
|
|
||||||
def registerMenu(self):
|
def registerMenu(self):
|
||||||
|
menuBar = self.GetMenuBar()
|
||||||
# Quit
|
# Quit
|
||||||
self.Bind(wx.EVT_MENU, self.ExitApp, id=wx.ID_EXIT)
|
self.Bind(wx.EVT_MENU, self.ExitApp, id=wx.ID_EXIT)
|
||||||
# Widgets Inspector
|
# Widgets Inspector
|
||||||
@@ -164,9 +165,9 @@ class MainFrame(wx.Frame):
|
|||||||
# About
|
# About
|
||||||
self.Bind(wx.EVT_MENU, self.ShowAboutBox, id=wx.ID_ABOUT)
|
self.Bind(wx.EVT_MENU, self.ShowAboutBox, id=wx.ID_ABOUT)
|
||||||
# Char editor
|
# Char editor
|
||||||
self.Bind(wx.EVT_MENU, self.showCharacterEditor, id=self.GetMenuBar().characterEditorId)
|
self.Bind(wx.EVT_MENU, self.showCharacterEditor, id=menuBar.characterEditorId)
|
||||||
# Damage pattern editor
|
# Damage pattern editor
|
||||||
self.Bind(wx.EVT_MENU, self.showDamagePatternEditor, id=self.GetMenuBar().damagePatternEditorId)
|
self.Bind(wx.EVT_MENU, self.showDamagePatternEditor, id=menuBar.damagePatternEditorId)
|
||||||
# Import dialog
|
# Import dialog
|
||||||
self.Bind(wx.EVT_MENU, self.showImportDialog, id=wx.ID_OPEN)
|
self.Bind(wx.EVT_MENU, self.showImportDialog, id=wx.ID_OPEN)
|
||||||
# Export dialog
|
# Export dialog
|
||||||
@@ -174,6 +175,30 @@ class MainFrame(wx.Frame):
|
|||||||
# Preference dialog
|
# Preference dialog
|
||||||
self.Bind(wx.EVT_MENU, self.showPreferenceDialog, id=wx.ID_PREFERENCES)
|
self.Bind(wx.EVT_MENU, self.showPreferenceDialog, id=wx.ID_PREFERENCES)
|
||||||
|
|
||||||
|
#Clipboard exports
|
||||||
|
self.Bind(wx.EVT_MENU, self.clipboardEft, id=menuBar.idExportEft)
|
||||||
|
self.Bind(wx.EVT_MENU, self.clipboardDna, id=menuBar.idExportDna)
|
||||||
|
self.Bind(wx.EVT_MENU, self.clipboardXml, id=menuBar.idExportXml)
|
||||||
|
|
||||||
|
def clipboardEft(self, event):
|
||||||
|
sFit = service.Fit.getInstance()
|
||||||
|
self.toClipboard(sFit.exportFit(self.getActiveFit()))
|
||||||
|
|
||||||
|
def clipboardDna(self, event):
|
||||||
|
sFit = service.Fit.getInstance()
|
||||||
|
self.toClipboard(sFit.exportDna(self.getActiveFit()))
|
||||||
|
|
||||||
|
def clipboardXml(self, event):
|
||||||
|
sFit = service.Fit.getInstance()
|
||||||
|
self.toClipboard(sFit.exportXml(self.getActiveFit()))
|
||||||
|
|
||||||
|
def toClipboard(self, text):
|
||||||
|
clip = wx.TheClipboard
|
||||||
|
clip.Open()
|
||||||
|
data = wx.TextDataObject(text)
|
||||||
|
clip.SetData(data)
|
||||||
|
clip.Close()
|
||||||
|
|
||||||
def toggleShipBrowser(self, event):
|
def toggleShipBrowser(self, event):
|
||||||
self.GetToolBar().toggleShipBrowser(event)
|
self.GetToolBar().toggleShipBrowser(event)
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,8 @@
|
|||||||
|
|
||||||
import wx
|
import wx
|
||||||
import bitmapLoader
|
import bitmapLoader
|
||||||
|
import gui.fittingView
|
||||||
|
import gui.mainFrame
|
||||||
|
|
||||||
class MainMenuBar(wx.MenuBar):
|
class MainMenuBar(wx.MenuBar):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@@ -41,11 +43,20 @@ class MainMenuBar(wx.MenuBar):
|
|||||||
editMenu.Append(wx.ID_REDO)
|
editMenu.Append(wx.ID_REDO)
|
||||||
|
|
||||||
# Fit menu
|
# Fit menu
|
||||||
fitMenu = wx.Menu()
|
self.fitMenu = fitMenu = wx.Menu()
|
||||||
self.Append(fitMenu, "F&it")
|
self.Append(fitMenu, "F&it")
|
||||||
fitMenu.Append(wx.ID_OPEN, "&Import", "Import a fit into pyfa.")
|
fitMenu.Append(wx.ID_OPEN, "&Import", "Import a fit into pyfa.")
|
||||||
fitMenu.Append(wx.ID_SAVEAS, "&Export", "Export the fit to another format.")
|
fitMenu.Append(wx.ID_SAVEAS, "&Export", "Export the fit to another format.")
|
||||||
|
|
||||||
|
clipboardMenu = wx.Menu()
|
||||||
|
self.idExportDna, self.idExportEft, self.idExportXml = wx.NewId(), wx.NewId(), wx.NewId()
|
||||||
|
clipboardMenu.Append(self.idExportEft, "&EFT", "Copy the EFT export of this fit to the clipboard")
|
||||||
|
clipboardMenu.Append(self.idExportXml, "&XML", "Copy the XML export of this fit to the clipboard")
|
||||||
|
clipboardMenu.Append(self.idExportDna, "&DNA", "Copy the DNA export of this fit to the clipboard")
|
||||||
|
|
||||||
|
fitMenu.AppendMenu(wx.ID_COPY, "To &Clipboard", clipboardMenu, "Export a fit to the clipboard")
|
||||||
|
|
||||||
|
|
||||||
# Character menu
|
# Character menu
|
||||||
windowMenu = wx.Menu()
|
windowMenu = wx.Menu()
|
||||||
self.Append(windowMenu, "&Window")
|
self.Append(windowMenu, "&Window")
|
||||||
@@ -65,3 +76,14 @@ class MainMenuBar(wx.MenuBar):
|
|||||||
helpMenu.Append(wx.ID_ABOUT)
|
helpMenu.Append(wx.ID_ABOUT)
|
||||||
helpMenu.Append(wx.ID_HELP, "User manual", "User manual")
|
helpMenu.Append(wx.ID_HELP, "User manual", "User manual")
|
||||||
helpMenu.Append(911,"Open Widgets Inspect tool", "Open Widgets Inspect tool")
|
helpMenu.Append(911,"Open Widgets Inspect tool", "Open Widgets Inspect tool")
|
||||||
|
|
||||||
|
|
||||||
|
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||||
|
self.mainFrame.Bind(gui.fittingView.FIT_CHANGED, self.fitChanged)
|
||||||
|
|
||||||
|
def fitChanged(self, event):
|
||||||
|
enable = event.fitID is not None
|
||||||
|
self.Enable(wx.ID_SAVEAS, enable)
|
||||||
|
self.Enable(wx.ID_COPY, enable)
|
||||||
|
event.Skip()
|
||||||
|
|
||||||
|
|||||||
@@ -269,6 +269,10 @@ class Fit(object):
|
|||||||
fit = eos.db.getFit(fitID)
|
fit = eos.db.getFit(fitID)
|
||||||
return fit.exportEft()
|
return fit.exportEft()
|
||||||
|
|
||||||
|
def exportDna(self, fitID):
|
||||||
|
fit = eos.db.getFit(fitID)
|
||||||
|
return fit.exportDna()
|
||||||
|
|
||||||
def exportXml(self, *fitIDs):
|
def exportXml(self, *fitIDs):
|
||||||
fits = map(lambda id: eos.db.getFit(id), fitIDs)
|
fits = map(lambda id: eos.db.getFit(id), fitIDs)
|
||||||
return eos.types.Fit.exportXml(*fits)
|
return eos.types.Fit.exportXml(*fits)
|
||||||
|
|||||||
Reference in New Issue
Block a user