Merge branch 'development'
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
|
||||
# =============================================================================
|
||||
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
|
||||
|
||||
@@ -79,11 +80,11 @@ class PFListPane(wx.ScrolledWindow):
|
||||
new_vs_x, new_vs_y = -1, -1
|
||||
|
||||
# is it before the left edge?
|
||||
if cr.x < 0 and sppu_x > 0:
|
||||
if cr.x < 0 < sppu_x:
|
||||
new_vs_x = vs_x + (cr.x / sppu_x)
|
||||
|
||||
# is it above the top?
|
||||
if cr.y < 0 and sppu_y > 0:
|
||||
if cr.y < 0 < sppu_y:
|
||||
new_vs_y = vs_y + (cr.y / sppu_y)
|
||||
|
||||
# For the right and bottom edges, scroll enough to show the
|
||||
@@ -143,10 +144,8 @@ class PFListPane(wx.ScrolledWindow):
|
||||
elif doFocus:
|
||||
self.SetFocus()
|
||||
|
||||
clientW, clientH = self.GetSize()
|
||||
for i in xrange(len(self._wList)):
|
||||
iwidth, iheight = self._wList[i].GetSize()
|
||||
itemX, itemY = self._wList[i].GetPosition()
|
||||
self._wList[i].SetSize((cwidth, iheight))
|
||||
if doRefresh is True:
|
||||
self._wList[i].Refresh()
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
import gui.utils.colorUtils as colorUtils
|
||||
import gui.utils.drawUtils as drawUtils
|
||||
@@ -68,7 +69,8 @@ class PFSearchBox(wx.Window):
|
||||
wx.PostEvent(self, TextEnter())
|
||||
event.Skip()
|
||||
|
||||
def OnEditSetFocus(self, event):
|
||||
@staticmethod
|
||||
def OnEditSetFocus(event):
|
||||
# value = self.EditBox.GetValue()
|
||||
# if value == self.descriptiveText:
|
||||
# self.EditBox.ChangeValue("")
|
||||
@@ -102,14 +104,15 @@ class PFSearchBox(wx.Window):
|
||||
x, y = target
|
||||
px, py = position
|
||||
aX, aY = area
|
||||
if (px > x and px < x + aX) and (py > y and py < y + aY):
|
||||
if (x < px < x + aX) and (y < py < y + aY):
|
||||
return True
|
||||
return False
|
||||
|
||||
def GetButtonsPos(self):
|
||||
btnpos = []
|
||||
btnpos.append((self.searchButtonX, self.searchButtonY))
|
||||
btnpos.append((self.cancelButtonX, self.cancelButtonY))
|
||||
btnpos = [
|
||||
(self.searchButtonX, self.searchButtonY),
|
||||
(self.cancelButtonX, self.cancelButtonY)
|
||||
]
|
||||
return btnpos
|
||||
|
||||
def GetButtonsSize(self):
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
|
||||
# =============================================================================
|
||||
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
import gui.mainFrame
|
||||
from gui.boosterView import BoosterView
|
||||
from gui.droneView import DroneView
|
||||
from gui.fighterView import FighterView
|
||||
@@ -31,7 +31,7 @@ from gui.notesView import NotesView
|
||||
from gui.pyfatogglepanel import TogglePanel
|
||||
from gui.bitmapLoader import BitmapLoader
|
||||
|
||||
import gui.chromeTabs
|
||||
from gui.chromeTabs import PFNotebook
|
||||
|
||||
|
||||
class AdditionsPane(TogglePanel):
|
||||
@@ -45,9 +45,7 @@ class AdditionsPane(TogglePanel):
|
||||
baseSizer = wx.BoxSizer(wx.HORIZONTAL)
|
||||
pane.SetSizer(baseSizer)
|
||||
|
||||
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
|
||||
self.notebook = gui.chromeTabs.PFNotebook(pane, False)
|
||||
self.notebook = PFNotebook(pane, False)
|
||||
self.notebook.SetMinSize((-1, 1000))
|
||||
|
||||
baseSizer.Add(self.notebook, 1, wx.EXPAND)
|
||||
@@ -92,9 +90,6 @@ class AdditionsPane(TogglePanel):
|
||||
def select(self, name):
|
||||
self.notebook.SetSelection(self.PANES.index(name))
|
||||
|
||||
def toggleBoosters(self, event):
|
||||
self.notebook.ToggleShown(self.booster)
|
||||
|
||||
def getName(self, idx):
|
||||
return self.PANES[idx]
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ import os.path
|
||||
import zipfile
|
||||
from config import parsePath
|
||||
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
|
||||
import config
|
||||
@@ -32,7 +33,7 @@ except ImportError:
|
||||
from utils.compat import OrderedDict
|
||||
|
||||
|
||||
class BitmapLoader():
|
||||
class BitmapLoader(object):
|
||||
try:
|
||||
archive = zipfile.ZipFile(config.getPyfaPath('imgs.zip'), 'r')
|
||||
except IOError:
|
||||
|
||||
@@ -17,18 +17,19 @@
|
||||
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
|
||||
# =============================================================================
|
||||
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
import gui.display as d
|
||||
import gui.globalEvents as GE
|
||||
import gui.marketBrowser as mb
|
||||
import gui.marketBrowser as marketBrowser
|
||||
from gui.builtinViewColumns.state import State
|
||||
from gui.contextMenu import ContextMenu
|
||||
from service.fit import Fit
|
||||
|
||||
|
||||
class BoosterViewDrop(wx.PyDropTarget):
|
||||
def __init__(self, dropFn):
|
||||
wx.PyDropTarget.__init__(self)
|
||||
def __init__(self, dropFn, *args, **kwargs):
|
||||
super(BoosterViewDrop, self).__init__(*args, **kwargs)
|
||||
self.dropFn = dropFn
|
||||
# this is really transferring an EVE itemID
|
||||
self.dropData = wx.PyTextDataObject()
|
||||
@@ -52,7 +53,7 @@ class BoosterView(d.Display):
|
||||
self.lastFitId = None
|
||||
|
||||
self.mainFrame.Bind(GE.FIT_CHANGED, self.fitChanged)
|
||||
self.mainFrame.Bind(mb.ITEM_SELECTED, self.addItem)
|
||||
self.mainFrame.Bind(marketBrowser.ITEM_SELECTED, self.addItem)
|
||||
|
||||
self.Bind(wx.EVT_LEFT_DCLICK, self.removeItem)
|
||||
self.Bind(wx.EVT_LEFT_DOWN, self.click)
|
||||
@@ -66,16 +67,16 @@ class BoosterView(d.Display):
|
||||
self.Bind(wx.EVT_RIGHT_DOWN, self.scheduleMenu)
|
||||
|
||||
def handleListDrag(self, x, y, data):
|
||||
'''
|
||||
"""
|
||||
Handles dragging of items from various pyfa displays which support it
|
||||
|
||||
data is list with two indices:
|
||||
data[0] is hard-coded str of originating source
|
||||
data[1] is typeID or index of data we want to manipulate
|
||||
'''
|
||||
"""
|
||||
|
||||
if data[0] == "market":
|
||||
wx.PostEvent(self.mainFrame, mb.ItemSelected(itemID=int(data[1])))
|
||||
wx.PostEvent(self.mainFrame, marketBrowser.ItemSelected(itemID=int(data[1])))
|
||||
|
||||
def kbEvent(self, event):
|
||||
keycode = event.GetKeyCode()
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from gui.contextMenu import ContextMenu
|
||||
import gui.mainFrame
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
import gui.globalEvents as GE
|
||||
from service.fit import Fit
|
||||
|
||||
@@ -2,6 +2,7 @@ from gui.contextMenu import ContextMenu
|
||||
from eos.saveddata.fit import Fit as es_Fit
|
||||
import gui.mainFrame
|
||||
import gui.globalEvents as GE
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
from service.fit import Fit
|
||||
from eos.saveddata.cargo import Cargo as es_Cargo
|
||||
@@ -49,7 +50,6 @@ class AmountChanger(wx.Dialog):
|
||||
self.button.Bind(wx.EVT_BUTTON, self.change)
|
||||
|
||||
def change(self, event):
|
||||
sFit = Fit.getInstance()
|
||||
if self.input.GetLineText(0).strip() == '':
|
||||
event.Skip()
|
||||
return
|
||||
@@ -70,7 +70,8 @@ class AmountChanger(wx.Dialog):
|
||||
event.Skip()
|
||||
|
||||
# checks to make sure it's valid number
|
||||
def onChar(self, event):
|
||||
@staticmethod
|
||||
def onChar(event):
|
||||
key = event.GetKeyCode()
|
||||
|
||||
acceptable_characters = "1234567890"
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
from gui.contextMenu import ContextMenu
|
||||
import gui.mainFrame
|
||||
import gui.globalEvents as GE
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
from service.fit import Fit
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from gui.contextMenu import ContextMenu
|
||||
import gui.mainFrame
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
from gui.bitmapLoader import BitmapLoader
|
||||
from eos.saveddata.character import Skill
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
from gui.contextMenu import ContextMenu
|
||||
import gui.mainFrame
|
||||
import gui.globalEvents as GE
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
from gui.bitmapLoader import BitmapLoader
|
||||
from service.fit import Fit
|
||||
@@ -9,7 +10,7 @@ from service.damagePattern import DamagePattern as import_DamagePattern
|
||||
try:
|
||||
from collections import OrderedDict
|
||||
except ImportError:
|
||||
from gui.utils.compat import OrderedDict
|
||||
from utils.compat import OrderedDict
|
||||
|
||||
|
||||
class DamagePattern(ContextMenu):
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from gui.contextMenu import ContextMenu
|
||||
import gui.mainFrame
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
import gui.globalEvents as GE
|
||||
from service.fit import Fit
|
||||
|
||||
@@ -2,6 +2,7 @@ from gui.contextMenu import ContextMenu
|
||||
import gui.mainFrame
|
||||
import gui.globalEvents as GE
|
||||
from service.fit import Fit
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
from gui.contextMenu import ContextMenu
|
||||
import gui.mainFrame
|
||||
import gui.globalEvents as GE
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
from gui.bitmapLoader import BitmapLoader
|
||||
from service.fit import Fit
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
from gui.contextMenu import ContextMenu
|
||||
import gui.mainFrame
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
from gui.contextMenu import ContextMenu
|
||||
import gui.mainFrame
|
||||
import gui.globalEvents as GE
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
from service.implantSet import ImplantSets as s_ImplantSets
|
||||
from service.character import Character
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from gui.contextMenu import ContextMenu
|
||||
import gui.mainFrame
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
import gui.globalEvents as GE
|
||||
from service.fit import Fit
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
from gui.contextMenu import ContextMenu
|
||||
from gui.itemStats import ItemStatsDialog
|
||||
import gui.mainFrame
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
from service.fit import Fit
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
# coding: utf-8
|
||||
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
|
||||
from service.fit import Fit
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
# coding: utf-8
|
||||
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
|
||||
from service.fit import Fit
|
||||
@@ -96,7 +97,8 @@ class ModuleAmmoPicker(ContextMenu):
|
||||
|
||||
return chargeDamageType, totalDamage
|
||||
|
||||
def numericConverter(self, string):
|
||||
@staticmethod
|
||||
def numericConverter(string):
|
||||
return int(string) if string.isdigit() else string
|
||||
|
||||
def nameSorter(self, charge):
|
||||
@@ -117,7 +119,8 @@ class ModuleAmmoPicker(ContextMenu):
|
||||
|
||||
return item
|
||||
|
||||
def addSeperator(self, m, text):
|
||||
@staticmethod
|
||||
def addSeperator(m, text):
|
||||
id_ = ContextMenu.nextID()
|
||||
m.Append(id_, u'─ %s ─' % text)
|
||||
m.Enable(id_, False)
|
||||
@@ -157,7 +160,7 @@ class ModuleAmmoPicker(ContextMenu):
|
||||
item = self.addCharge(rootMenu if msw else m, charge)
|
||||
items.append(item)
|
||||
else:
|
||||
if sub is None:
|
||||
if sub is None and item and base:
|
||||
sub = wx.Menu()
|
||||
sub.Bind(wx.EVT_MENU, self.handleAmmoSwitch)
|
||||
self.addSeperator(sub, "Less Damage")
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import gui.mainFrame
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
import gui.globalEvents as GE
|
||||
from gui.builtinContextMenus.moduleAmmoPicker import ModuleAmmoPicker
|
||||
import eos.db
|
||||
from eos.db.saveddata.queries import getFit as db_getFit
|
||||
from service.fit import Fit
|
||||
|
||||
|
||||
class ModuleGlobalAmmoPicker(ModuleAmmoPicker):
|
||||
def __init__(self):
|
||||
super(ModuleGlobalAmmoPicker, self).__init__()
|
||||
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
|
||||
def getText(self, itmContext, selection):
|
||||
@@ -26,7 +28,7 @@ class ModuleGlobalAmmoPicker(ModuleAmmoPicker):
|
||||
|
||||
sFit = Fit.getInstance()
|
||||
fitID = self.mainFrame.getActiveFit()
|
||||
fit = eos.db.getFit(fitID)
|
||||
fit = db_getFit(fitID)
|
||||
|
||||
selectedModule = self.modules[0]
|
||||
allModules = []
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from gui.contextMenu import ContextMenu
|
||||
import gui.mainFrame
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
from gui.shipBrowser import FitSelected
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from gui.contextMenu import ContextMenu
|
||||
import gui.mainFrame
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
import gui.globalEvents as GE
|
||||
from service.market import Market
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
from gui.contextMenu import ContextMenu
|
||||
import gui.mainFrame
|
||||
import gui.globalEvents as GE
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
from service.fit import Fit
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
from gui.contextMenu import ContextMenu
|
||||
import gui.mainFrame
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
from gui.contextMenu import ContextMenu
|
||||
import gui.mainFrame
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
from gui.contextMenu import ContextMenu
|
||||
import gui.mainFrame
|
||||
import gui.globalEvents as GE
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
from gui.bitmapLoader import BitmapLoader
|
||||
from service.targetResists import TargetResists as svc_TargetResists
|
||||
@@ -9,7 +10,7 @@ from service.fit import Fit
|
||||
try:
|
||||
from collections import OrderedDict
|
||||
except ImportError:
|
||||
from gui.utils.compat import OrderedDict
|
||||
from utils.compat import OrderedDict
|
||||
|
||||
|
||||
class TargetResists(ContextMenu):
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
from gui.contextMenu import ContextMenu
|
||||
import gui.mainFrame
|
||||
import gui.globalEvents as GE
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
from service.market import Market
|
||||
from service.fit import Fit
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
|
||||
__all__ = ["pyfaGeneralPreferences", "pyfaHTMLExportPreferences", "pyfaUpdatePreferences",
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
|
||||
# =============================================================================
|
||||
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
from gui.preferenceView import PreferenceView
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
|
||||
from gui.preferenceView import PreferenceView
|
||||
@@ -7,6 +8,7 @@ import gui.mainFrame
|
||||
|
||||
from service.settings import CRESTSettings
|
||||
|
||||
# noinspection PyPackageRequirements
|
||||
from wx.lib.intctrl import IntCtrl
|
||||
|
||||
if 'wxMac' not in wx.PlatformInfo or ('wxMac' in wx.PlatformInfo and wx.VERSION >= (3, 0)):
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
import copy
|
||||
|
||||
@@ -425,7 +426,8 @@ class PFGaugePref(PreferenceView):
|
||||
self.SetColours()
|
||||
event.Skip()
|
||||
|
||||
def OnOk(self, event):
|
||||
@staticmethod
|
||||
def OnOk(event):
|
||||
# Apply New Settings
|
||||
event.Skip()
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
|
||||
from gui.preferenceView import PreferenceView
|
||||
@@ -7,7 +8,8 @@ import gui.mainFrame
|
||||
import gui.globalEvents as GE
|
||||
from service.settings import SettingsProvider
|
||||
from service.fit import Fit
|
||||
|
||||
from service.price import Price
|
||||
from service.market import Market
|
||||
|
||||
class PFGeneralPref(PreferenceView):
|
||||
title = "General"
|
||||
@@ -79,7 +81,16 @@ class PFGeneralPref(PreferenceView):
|
||||
wx.DefaultPosition, wx.DefaultSize, 0)
|
||||
mainSizer.Add(self.cbOpenFitInNew, 0, wx.ALL | wx.EXPAND, 5)
|
||||
|
||||
wx.BoxSizer(wx.HORIZONTAL)
|
||||
priceSizer = wx.BoxSizer(wx.HORIZONTAL)
|
||||
|
||||
self.stDefaultSystem = wx.StaticText(panel, wx.ID_ANY, u"Default Market Prices:", wx.DefaultPosition, wx.DefaultSize, 0)
|
||||
self.stDefaultSystem.Wrap(-1)
|
||||
priceSizer.Add(self.stDefaultSystem, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5)
|
||||
|
||||
self.chPriceSystem = wx.Choice( panel, choices=Price.systemsList.keys())
|
||||
priceSizer.Add(self.chPriceSystem, 1, wx.ALL | wx.EXPAND, 5)
|
||||
|
||||
mainSizer.Add(priceSizer, 0, wx.ALL|wx.EXPAND, 0)
|
||||
|
||||
self.sFit = Fit.getInstance()
|
||||
|
||||
@@ -96,6 +107,7 @@ class PFGeneralPref(PreferenceView):
|
||||
self.cbGaugeAnimation.SetValue(self.sFit.serviceFittingOptions["enableGaugeAnimation"])
|
||||
self.cbExportCharges.SetValue(self.sFit.serviceFittingOptions["exportCharges"])
|
||||
self.cbOpenFitInNew.SetValue(self.sFit.serviceFittingOptions["openFitInNew"])
|
||||
self.chPriceSystem.SetStringSelection(self.sFit.serviceFittingOptions["priceSystem"])
|
||||
|
||||
self.cbGlobalChar.Bind(wx.EVT_CHECKBOX, self.OnCBGlobalCharStateChange)
|
||||
self.cbGlobalDmgPattern.Bind(wx.EVT_CHECKBOX, self.OnCBGlobalDmgPatternStateChange)
|
||||
@@ -110,6 +122,7 @@ class PFGeneralPref(PreferenceView):
|
||||
self.cbGaugeAnimation.Bind(wx.EVT_CHECKBOX, self.onCBGaugeAnimation)
|
||||
self.cbExportCharges.Bind(wx.EVT_CHECKBOX, self.onCBExportCharges)
|
||||
self.cbOpenFitInNew.Bind(wx.EVT_CHECKBOX, self.onCBOpenFitInNew)
|
||||
self.chPriceSystem.Bind(wx.EVT_CHOICE, self.onPriceSelection)
|
||||
|
||||
self.cbRackLabels.Enable(self.sFit.serviceFittingOptions["rackSlots"] or False)
|
||||
|
||||
@@ -181,5 +194,18 @@ class PFGeneralPref(PreferenceView):
|
||||
def getImage(self):
|
||||
return BitmapLoader.getBitmap("prefs_settings", "gui")
|
||||
|
||||
def onPriceSelection(self, event):
|
||||
system = self.chPriceSystem.GetString(self.chPriceSystem.GetSelection())
|
||||
Price.currentSystemId = Price.systemsList.get(system)
|
||||
self.sFit.serviceFittingOptions["priceSystem"] = system
|
||||
|
||||
fitID = self.mainFrame.getActiveFit()
|
||||
|
||||
sMkt = Market.getInstance()
|
||||
sMkt.clearPriceCache()
|
||||
|
||||
self.sFit.refreshFit(fitID)
|
||||
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID))
|
||||
event.Skip()
|
||||
|
||||
PFGeneralPref.register()
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
import os
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
|
||||
from gui.preferenceView import PreferenceView
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
|
||||
from gui.preferenceView import PreferenceView
|
||||
@@ -39,7 +40,7 @@ class PFUpdatePref(PreferenceView):
|
||||
|
||||
mainSizer.Add(self.suppressPrerelease, 0, wx.ALL | wx.EXPAND, 5)
|
||||
|
||||
if (self.UpdateSettings.get('version')):
|
||||
if self.UpdateSettings.get('version'):
|
||||
self.versionSizer = wx.BoxSizer(wx.VERTICAL)
|
||||
|
||||
self.versionTitle = wx.StaticText(panel, wx.ID_ANY, "Suppressing {0} Notifications".format(
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
|
||||
# =============================================================================
|
||||
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
from gui.statsView import StatsView
|
||||
from gui.bitmapLoader import BitmapLoader
|
||||
@@ -130,8 +131,8 @@ class CapacitorViewFull(StatsView):
|
||||
capStable = fit.capStable if fit is not None else False
|
||||
lblNameTime = "label%sCapacitorTime"
|
||||
lblNameState = "label%sCapacitorState"
|
||||
if isinstance(capState, tuple):
|
||||
t = "%.1f%%-%.1f%%" % capState
|
||||
if isinstance(capState, tuple) and len(capState) >= 2:
|
||||
t = ("{0}%-{1}%", capState[0], capState[1])
|
||||
s = ""
|
||||
else:
|
||||
if capStable:
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
|
||||
# =============================================================================
|
||||
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
import gui.mainFrame
|
||||
from gui.statsView import StatsView
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
|
||||
# =============================================================================
|
||||
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
import gui.mainFrame
|
||||
from gui.statsView import StatsView
|
||||
|
||||
@@ -17,11 +17,13 @@
|
||||
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
|
||||
# =============================================================================
|
||||
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
from gui.statsView import StatsView
|
||||
from gui.bitmapLoader import BitmapLoader
|
||||
from gui.utils.numberFormatter import formatAmount
|
||||
from service.market import Market
|
||||
from service.price import Price
|
||||
|
||||
|
||||
class PriceViewFull(StatsView):
|
||||
@@ -70,26 +72,12 @@ class PriceViewFull(StatsView):
|
||||
setattr(self, "labelPrice%s" % type.capitalize(), lbl)
|
||||
hbox.Add(lbl, 0, wx.ALIGN_LEFT)
|
||||
|
||||
|
||||
def refreshPanel(self, fit):
|
||||
if fit is not None:
|
||||
self.fit = fit
|
||||
# Compose a list of all the data we need & request it
|
||||
typeIDs = []
|
||||
typeIDs.append(fit.ship.item.ID)
|
||||
|
||||
for mod in fit.modules:
|
||||
if not mod.isEmpty:
|
||||
typeIDs.append(mod.itemID)
|
||||
|
||||
for drone in fit.drones:
|
||||
typeIDs.append(drone.itemID)
|
||||
|
||||
for fighter in fit.fighters:
|
||||
if fighter.amountActive > 0:
|
||||
typeIDs.append(fighter.itemID)
|
||||
|
||||
for cargo in fit.cargo:
|
||||
typeIDs.append(cargo.itemID)
|
||||
typeIDs = Price.fitItemsList(fit)
|
||||
|
||||
sMkt = Market.getInstance()
|
||||
sMkt.getPrices(typeIDs, self.processPrices)
|
||||
|
||||
@@ -17,12 +17,13 @@
|
||||
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
|
||||
# =============================================================================
|
||||
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
from gui.statsView import StatsView
|
||||
from gui.bitmapLoader import BitmapLoader
|
||||
from gui.utils.numberFormatter import formatAmount
|
||||
import gui.mainFrame
|
||||
import gui.builtinStatsViews.resistancesViewFull as rvf
|
||||
from gui.builtinStatsViews.resistancesViewFull import EFFECTIVE_HP_TOGGLED
|
||||
from service.fit import Fit
|
||||
|
||||
|
||||
@@ -33,7 +34,7 @@ class RechargeViewFull(StatsView):
|
||||
StatsView.__init__(self)
|
||||
self.parent = parent
|
||||
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
self.mainFrame.Bind(rvf.EFFECTIVE_HP_TOGGLED, self.toggleEffective)
|
||||
self.mainFrame.Bind(EFFECTIVE_HP_TOGGLED, self.toggleEffective)
|
||||
self.effective = True
|
||||
|
||||
def getHeaderText(self, fit):
|
||||
|
||||
@@ -17,10 +17,11 @@
|
||||
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
|
||||
# =============================================================================
|
||||
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
from gui.statsView import StatsView
|
||||
from gui.bitmapLoader import BitmapLoader
|
||||
from gui import pygauge as PG
|
||||
from gui.pygauge import PyGauge
|
||||
from gui.utils.numberFormatter import formatAmount
|
||||
import gui.mainFrame
|
||||
import gui.globalEvents as GE
|
||||
@@ -132,7 +133,7 @@ class ResistancesViewFull(StatsView):
|
||||
bc = pgColour[1]
|
||||
currGColour += 1
|
||||
|
||||
lbl = PG.PyGauge(contentPanel, wx.ID_ANY, 100)
|
||||
lbl = PyGauge(contentPanel, wx.ID_ANY, 100)
|
||||
lbl.SetMinSize((48, 16))
|
||||
lbl.SetBackgroundColour(wx.Colour(bc[0], bc[1], bc[2]))
|
||||
lbl.SetBarColour(wx.Colour(fc[0], fc[1], fc[2]))
|
||||
|
||||
@@ -17,12 +17,13 @@
|
||||
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
|
||||
# =============================================================================
|
||||
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
from gui.statsView import StatsView
|
||||
from gui.bitmapLoader import BitmapLoader
|
||||
from gui import pygauge as PG
|
||||
from gui.pygauge import PyGauge
|
||||
import gui.mainFrame
|
||||
import gui.chromeTabs
|
||||
from gui.chromeTabs import EVT_NOTEBOOK_PAGE_CHANGED
|
||||
|
||||
from eos.saveddata.module import Hardpoint
|
||||
|
||||
@@ -37,7 +38,7 @@ class ResourcesViewFull(StatsView):
|
||||
StatsView.__init__(self)
|
||||
self.parent = parent
|
||||
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
self.mainFrame.additionsPane.notebook.Bind(gui.chromeTabs.EVT_NOTEBOOK_PAGE_CHANGED, self.pageChanged)
|
||||
self.mainFrame.additionsPane.notebook.Bind(EVT_NOTEBOOK_PAGE_CHANGED, self.pageChanged)
|
||||
|
||||
def pageChanged(self, event):
|
||||
page = self.mainFrame.additionsPane.getName(event.GetSelection())
|
||||
@@ -175,7 +176,7 @@ class ResourcesViewFull(StatsView):
|
||||
|
||||
# Gauges modif. - Darriele
|
||||
|
||||
gauge = PG.PyGauge(parent, wx.ID_ANY, 1)
|
||||
gauge = PyGauge(parent, wx.ID_ANY, 1)
|
||||
gauge.SetValueRange(0, 0)
|
||||
gauge.SetMinSize((self.getTextExtentW("1.999M/1.99M MW"), 23))
|
||||
gauge.SetFractionDigits(2)
|
||||
@@ -216,52 +217,61 @@ class ResourcesViewFull(StatsView):
|
||||
("label%sTotalCargoBay", lambda: fit.ship.getModifiedItemAttr("capacity"), 3, 0, 9),
|
||||
)
|
||||
panel = "Full"
|
||||
|
||||
usedTurretHardpoints = 0
|
||||
labelUTH = ""
|
||||
totalTurretHardpoints = 0
|
||||
labelTTH = ""
|
||||
usedLauncherHardpoints = 0
|
||||
labelULH = ""
|
||||
totalLauncherHardPoints = 0
|
||||
labelTLH = ""
|
||||
usedDronesActive = 0
|
||||
labelUDA = ""
|
||||
totalDronesActive = 0
|
||||
labelTDA = ""
|
||||
usedFighterTubes = 0
|
||||
labelUFT = ""
|
||||
totalFighterTubes = 0
|
||||
labelTFT = ""
|
||||
usedCalibrationPoints = 0
|
||||
labelUCP = ""
|
||||
totalCalibrationPoints = 0
|
||||
labelTCP = ""
|
||||
|
||||
for labelName, value, prec, lowest, highest in stats:
|
||||
label = getattr(self, labelName % panel)
|
||||
value = value() if fit is not None else 0
|
||||
value = value if value is not None else 0
|
||||
|
||||
if labelName % panel == "label%sUsedTurretHardpoints" % panel:
|
||||
usedTurretHardpoints = value
|
||||
labelUTH = label
|
||||
|
||||
if labelName % panel == "label%sTotalTurretHardpoints" % panel:
|
||||
elif labelName % panel == "label%sTotalTurretHardpoints" % panel:
|
||||
totalTurretHardpoints = value
|
||||
labelTTH = label
|
||||
|
||||
if labelName % panel == "label%sUsedLauncherHardpoints" % panel:
|
||||
elif labelName % panel == "label%sUsedLauncherHardpoints" % panel:
|
||||
usedLauncherHardpoints = value
|
||||
labelULH = label
|
||||
|
||||
if labelName % panel == "label%sTotalLauncherHardpoints" % panel:
|
||||
elif labelName % panel == "label%sTotalLauncherHardpoints" % panel:
|
||||
totalLauncherHardPoints = value
|
||||
labelTLH = label
|
||||
|
||||
if labelName % panel == "label%sUsedDronesActive" % panel:
|
||||
elif labelName % panel == "label%sUsedDronesActive" % panel:
|
||||
usedDronesActive = value
|
||||
labelUDA = label
|
||||
|
||||
if labelName % panel == "label%sTotalDronesActive" % panel:
|
||||
elif labelName % panel == "label%sTotalDronesActive" % panel:
|
||||
totalDronesActive = value
|
||||
labelTDA = label
|
||||
|
||||
if labelName % panel == "label%sUsedFighterTubes" % panel:
|
||||
elif labelName % panel == "label%sUsedFighterTubes" % panel:
|
||||
usedFighterTubes = value
|
||||
labelUFT = label
|
||||
|
||||
if labelName % panel == "label%sTotalFighterTubes" % panel:
|
||||
elif labelName % panel == "label%sTotalFighterTubes" % panel:
|
||||
totalFighterTubes = value
|
||||
labelTFT = label
|
||||
|
||||
if labelName % panel == "label%sUsedCalibrationPoints" % panel:
|
||||
elif labelName % panel == "label%sUsedCalibrationPoints" % panel:
|
||||
usedCalibrationPoints = value
|
||||
labelUCP = label
|
||||
|
||||
if labelName % panel == "label%sTotalCalibrationPoints" % panel:
|
||||
elif labelName % panel == "label%sTotalCalibrationPoints" % panel:
|
||||
totalCalibrationPoints = value
|
||||
labelTCP = label
|
||||
|
||||
@@ -316,6 +326,8 @@ class ResourcesViewFull(StatsView):
|
||||
lambda: fit.ship.getModifiedItemAttr("droneBandwidth"),
|
||||
lambda: fit.ship.getModifiedItemAttr("capacity"),
|
||||
)
|
||||
else:
|
||||
resMax = None
|
||||
|
||||
i = 0
|
||||
for resourceType in ("cpu", "pg", "droneBay", "fighterBay", "droneBandwidth", "cargoBay"):
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
|
||||
# =============================================================================
|
||||
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
from gui.statsView import StatsView
|
||||
from gui.utils.numberFormatter import formatAmount
|
||||
@@ -202,16 +203,14 @@ class TargetingMiscViewFull(StatsView):
|
||||
label.SetToolTip(
|
||||
wx.ToolTip("Type: %s\n%.1f%% Chance of Jam" % (fit.scanType, fit.jamChance)))
|
||||
else:
|
||||
label.SetToolTip(wx.ToolTip("Type: %s" % (fit.scanType)))
|
||||
label.SetToolTip(wx.ToolTip("Type: %s" % fit.scanType))
|
||||
elif labelName == "labelFullAlignTime":
|
||||
alignTime = "Align:\t%.3fs" % mainValue
|
||||
mass = 'Mass:\t{:,.0f}kg'.format(fit.ship.getModifiedItemAttr("mass"))
|
||||
agility = "Agility:\t%.3fx" % (fit.ship.getModifiedItemAttr("agility") or 0)
|
||||
label.SetToolTip(wx.ToolTip("%s\n%s\n%s" % (alignTime, mass, agility)))
|
||||
elif labelName == "labelFullCargo":
|
||||
tipLines = []
|
||||
tipLines.append(
|
||||
u"Cargohold: {:,.2f}m\u00B3 / {:,.2f}m\u00B3".format(fit.cargoBayUsed, newValues["main"]))
|
||||
tipLines = [u"Cargohold: {:,.2f}m\u00B3 / {:,.2f}m\u00B3".format(fit.cargoBayUsed, newValues["main"])]
|
||||
for attrName, tipAlias in cargoNamesOrder.items():
|
||||
if newValues[attrName] > 0:
|
||||
tipLines.append(u"{}: {:,.2f}m\u00B3".format(tipAlias, newValues[attrName]))
|
||||
@@ -231,7 +230,7 @@ class TargetingMiscViewFull(StatsView):
|
||||
if fit.jamChance > 0:
|
||||
label.SetToolTip(wx.ToolTip("Type: %s\n%.1f%% Chance of Jam" % (fit.scanType, fit.jamChance)))
|
||||
else:
|
||||
label.SetToolTip(wx.ToolTip("Type: %s" % (fit.scanType)))
|
||||
label.SetToolTip(wx.ToolTip("Type: %s" % fit.scanType))
|
||||
else:
|
||||
label.SetToolTip(wx.ToolTip(""))
|
||||
elif labelName == "labelFullCargo":
|
||||
@@ -239,9 +238,7 @@ class TargetingMiscViewFull(StatsView):
|
||||
cachedCargo = self._cachedValues[counter]
|
||||
# if you add stuff to cargo, the capacity doesn't change and thus it is still cached
|
||||
# This assures us that we force refresh of cargo tooltip
|
||||
tipLines = []
|
||||
tipLines.append(
|
||||
u"Cargohold: {:,.2f}m\u00B3 / {:,.2f}m\u00B3".format(fit.cargoBayUsed, cachedCargo["main"]))
|
||||
tipLines = [u"Cargohold: {:,.2f}m\u00B3 / {:,.2f}m\u00B3".format(fit.cargoBayUsed, cachedCargo["main"])]
|
||||
for attrName, tipAlias in cargoNamesOrder.items():
|
||||
if cachedCargo[attrName] > 0:
|
||||
tipLines.append(u"{}: {:,.2f}m\u00B3".format(tipAlias, cachedCargo[attrName]))
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
# =============================================================================
|
||||
|
||||
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
from eos.saveddata.fighter import Fighter
|
||||
from gui.viewColumn import ViewColumn
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
|
||||
# =============================================================================
|
||||
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
from eos.saveddata.fighter import Fighter
|
||||
from gui.viewColumn import ViewColumn
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
# =============================================================================
|
||||
|
||||
from gui.viewColumn import ViewColumn
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
from eos.saveddata.module import Module
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
|
||||
# =============================================================================
|
||||
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
|
||||
from gui.viewColumn import ViewColumn
|
||||
@@ -82,7 +83,7 @@ class AttributeDisplay(ViewColumn):
|
||||
if self.info.name == "volume":
|
||||
str_ = (formatAmount(attr, 3, 0, 3))
|
||||
if hasattr(mod, "amount"):
|
||||
str_ = str_ + u"m\u00B3 (%s m\u00B3)" % (formatAmount(attr * mod.amount, 3, 0, 3))
|
||||
str_ += u"m\u00B3 (%s m\u00B3)" % (formatAmount(attr * mod.amount, 3, 0, 3))
|
||||
attr = str_
|
||||
|
||||
if isinstance(attr, (float, int)):
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
from eos.saveddata.implant import Implant
|
||||
from eos.saveddata.drone import Drone
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
|
||||
# =============================================================================
|
||||
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
from eos.saveddata.cargo import Cargo
|
||||
from eos.saveddata.implant import Implant
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
|
||||
# =============================================================================
|
||||
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
|
||||
from eos.saveddata.mode import Mode
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
|
||||
# =============================================================================
|
||||
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
|
||||
from eos.saveddata.mode import Mode
|
||||
@@ -73,7 +74,7 @@ class MaxRange(ViewColumn):
|
||||
return -1
|
||||
|
||||
def getParameters(self):
|
||||
return (("displayName", bool, False), ("showIcon", bool, True))
|
||||
return ("displayName", bool, False), ("showIcon", bool, True)
|
||||
|
||||
def getToolTip(self, mod):
|
||||
return "Optimal + Falloff"
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
|
||||
# =============================================================================
|
||||
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
|
||||
from service.fit import Fit
|
||||
@@ -58,7 +59,7 @@ class Miscellanea(ViewColumn):
|
||||
return -1
|
||||
|
||||
def getParameters(self):
|
||||
return (("displayName", bool, False), ("showIcon", bool, True))
|
||||
return ("displayName", bool, False), ("showIcon", bool, True)
|
||||
|
||||
def __getData(self, stuff):
|
||||
item = stuff.item
|
||||
@@ -504,8 +505,8 @@ class Miscellanea(ViewColumn):
|
||||
for number_of_cycles in {5, 10, 25}:
|
||||
tooltip = "{0}\n{1} charges lasts {2} seconds ({3} cycles)".format(
|
||||
tooltip,
|
||||
formatAmount(number_of_cycles*cycles, 3, 0, 3),
|
||||
formatAmount((duration+reload_time)*number_of_cycles, 3, 0, 3),
|
||||
formatAmount(number_of_cycles * cycles, 3, 0, 3),
|
||||
formatAmount((duration + reload_time) * number_of_cycles, 3, 0, 3),
|
||||
formatAmount(number_of_cycles, 3, 0, 3)
|
||||
)
|
||||
text = "{0} / {1}s (+{2}s)".format(
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
|
||||
# =============================================================================
|
||||
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
|
||||
from eos.saveddata.cargo import Cargo
|
||||
|
||||
@@ -56,7 +56,7 @@ class PropertyDisplay(ViewColumn):
|
||||
def getText(self, stuff):
|
||||
attr = getattr(stuff, self.propertyName, None)
|
||||
if attr:
|
||||
return (formatAmount(attr, 3, 0, 3))
|
||||
return formatAmount(attr, 3, 0, 3)
|
||||
else:
|
||||
return ""
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
# =============================================================================
|
||||
|
||||
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
|
||||
from eos.saveddata.fit import Fit
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
import gui.globalEvents as GE
|
||||
import gui.chromeTabs
|
||||
from gui.chromeTabs import EVT_NOTEBOOK_PAGE_CHANGED
|
||||
import gui.mainFrame
|
||||
|
||||
|
||||
@@ -11,13 +12,13 @@ class BlankPage(wx.Panel):
|
||||
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
self.parent = parent
|
||||
|
||||
self.parent.Bind(gui.chromeTabs.EVT_NOTEBOOK_PAGE_CHANGED, self.pageChanged)
|
||||
self.parent.Bind(EVT_NOTEBOOK_PAGE_CHANGED, self.pageChanged)
|
||||
self.SetBackgroundColour(wx.SystemSettings_GetColour(wx.SYS_COLOUR_WINDOW))
|
||||
|
||||
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=None))
|
||||
|
||||
def Destroy(self):
|
||||
self.parent.Unbind(gui.chromeTabs.EVT_NOTEBOOK_PAGE_CHANGED, handler=self.pageChanged)
|
||||
self.parent.Unbind(EVT_NOTEBOOK_PAGE_CHANGED, handler=self.pageChanged)
|
||||
wx.Panel.Destroy(self)
|
||||
|
||||
def pageChanged(self, event):
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
from gui.bitmapLoader import BitmapLoader
|
||||
|
||||
|
||||
@@ -17,7 +17,9 @@
|
||||
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
|
||||
# =============================================================================
|
||||
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
# noinspection PyPackageRequirements
|
||||
import wx.lib.newevent
|
||||
import gui.mainFrame
|
||||
import gui.marketBrowser
|
||||
@@ -31,7 +33,8 @@ from gui.builtinViewColumns.state import State
|
||||
from gui.bitmapLoader import BitmapLoader
|
||||
import gui.builtinViews.emptyView
|
||||
from gui.utils.exportHtml import exportHtml
|
||||
from logging import getLogger, Formatter
|
||||
from logging import getLogger
|
||||
from gui.chromeTabs import EVT_NOTEBOOK_PAGE_CHANGED
|
||||
|
||||
from service.fit import Fit
|
||||
from service.market import Market
|
||||
@@ -97,8 +100,8 @@ FitSpawner.register()
|
||||
|
||||
# Drag'n'drop handler
|
||||
class FittingViewDrop(wx.PyDropTarget):
|
||||
def __init__(self, dropFn):
|
||||
wx.PyDropTarget.__init__(self)
|
||||
def __init__(self, dropFn, *args, **kwargs):
|
||||
super(FittingViewDrop, self).__init__(*args, **kwargs)
|
||||
self.dropFn = dropFn
|
||||
# this is really transferring an EVE itemID
|
||||
self.dropData = wx.PyTextDataObject()
|
||||
@@ -157,7 +160,7 @@ class FittingView(d.Display):
|
||||
self.Bind(wx.EVT_SHOW, self.OnShow)
|
||||
self.Bind(wx.EVT_MOTION, self.OnMouseMove)
|
||||
self.Bind(wx.EVT_LEAVE_WINDOW, self.OnLeaveWindow)
|
||||
self.parent.Bind(gui.chromeTabs.EVT_NOTEBOOK_PAGE_CHANGED, self.pageChanged)
|
||||
self.parent.Bind(EVT_NOTEBOOK_PAGE_CHANGED, self.pageChanged)
|
||||
|
||||
def OnLeaveWindow(self, event):
|
||||
self.SetToolTip(None)
|
||||
@@ -185,13 +188,13 @@ class FittingView(d.Display):
|
||||
event.Skip()
|
||||
|
||||
def handleListDrag(self, x, y, data):
|
||||
'''
|
||||
"""
|
||||
Handles dragging of items from various pyfa displays which support it
|
||||
|
||||
data is list with two items:
|
||||
data[0] is hard-coded str of originating source
|
||||
data[1] is typeID or index of data we want to manipulate
|
||||
'''
|
||||
"""
|
||||
|
||||
if data[0] == "fitting":
|
||||
self.swapItems(x, y, int(data[1]))
|
||||
@@ -206,7 +209,7 @@ class FittingView(d.Display):
|
||||
wx.PostEvent(self.mainFrame, gui.shipBrowser.FitSelected(fitID=fitID))
|
||||
|
||||
def Destroy(self):
|
||||
self.parent.Unbind(gui.chromeTabs.EVT_NOTEBOOK_PAGE_CHANGED, handler=self.pageChanged)
|
||||
self.parent.Unbind(EVT_NOTEBOOK_PAGE_CHANGED, handler=self.pageChanged)
|
||||
self.mainFrame.Unbind(GE.FIT_CHANGED, handler=self.fitChanged)
|
||||
self.mainFrame.Unbind(gui.shipBrowser.EVT_FIT_RENAMED, handler=self.fitRenamed)
|
||||
self.mainFrame.Unbind(gui.shipBrowser.EVT_FIT_REMOVED, handler=self.fitRemoved)
|
||||
@@ -259,11 +262,11 @@ class FittingView(d.Display):
|
||||
event.Skip()
|
||||
|
||||
def fitRemoved(self, event):
|
||||
'''
|
||||
"""
|
||||
If fit is removed and active, the page is deleted.
|
||||
We also refresh the fit of the new current page in case
|
||||
delete fit caused change in stats (projected)
|
||||
'''
|
||||
"""
|
||||
fitID = event.fitID
|
||||
|
||||
if fitID == self.getActiveFit():
|
||||
@@ -355,7 +358,7 @@ class FittingView(d.Display):
|
||||
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.activeFitID))
|
||||
|
||||
def addModule(self, x, y, srcIdx):
|
||||
'''Add a module from the market browser'''
|
||||
"""Add a module from the market browser"""
|
||||
|
||||
dstRow, _ = self.HitTest((x, y))
|
||||
if dstRow != -1 and dstRow not in self.blanks:
|
||||
@@ -368,7 +371,7 @@ class FittingView(d.Display):
|
||||
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.mainFrame.getActiveFit()))
|
||||
|
||||
def swapCargo(self, x, y, srcIdx):
|
||||
'''Swap a module from cargo to fitting window'''
|
||||
"""Swap a module from cargo to fitting window"""
|
||||
mstate = wx.GetMouseState()
|
||||
|
||||
dstRow, _ = self.HitTest((x, y))
|
||||
@@ -382,7 +385,7 @@ class FittingView(d.Display):
|
||||
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.mainFrame.getActiveFit()))
|
||||
|
||||
def swapItems(self, x, y, srcIdx):
|
||||
'''Swap two modules in fitting window'''
|
||||
"""Swap two modules in fitting window"""
|
||||
mstate = wx.GetMouseState()
|
||||
sFit = Fit.getInstance()
|
||||
fit = sFit.getFit(self.activeFitID)
|
||||
@@ -403,20 +406,23 @@ class FittingView(d.Display):
|
||||
if mod1.slot != mod2.slot:
|
||||
return
|
||||
|
||||
if clone and mod2.isEmpty:
|
||||
sFit.cloneModule(self.mainFrame.getActiveFit(), srcIdx, mod2.modPosition)
|
||||
else:
|
||||
sFit.swapModules(self.mainFrame.getActiveFit(), srcIdx, mod2.modPosition)
|
||||
if getattr(mod2, "modPosition"):
|
||||
if clone and mod2.isEmpty:
|
||||
sFit.cloneModule(self.mainFrame.getActiveFit(), srcIdx, mod2.modPosition)
|
||||
else:
|
||||
sFit.swapModules(self.mainFrame.getActiveFit(), srcIdx, mod2.modPosition)
|
||||
|
||||
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.mainFrame.getActiveFit()))
|
||||
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.mainFrame.getActiveFit()))
|
||||
else:
|
||||
logger.error("Missing module position for: %s", str(getattr(mod2, "ID", "Unknown")))
|
||||
|
||||
def generateMods(self):
|
||||
'''
|
||||
"""
|
||||
Generate module list.
|
||||
|
||||
This also injects dummy modules to visually separate racks. These modules are only
|
||||
known to the display, and not the backend, so it's safe.
|
||||
'''
|
||||
"""
|
||||
|
||||
sFit = Fit.getInstance()
|
||||
fit = sFit.getFit(self.activeFitID)
|
||||
@@ -425,7 +431,7 @@ class FittingView(d.Display):
|
||||
|
||||
if fit is not None:
|
||||
self.mods = fit.modules[:]
|
||||
self.mods.sort(key=lambda mod: (slotOrder.index(mod.slot), mod.position))
|
||||
self.mods.sort(key=lambda _mod: (slotOrder.index(_mod.slot), _mod.position))
|
||||
|
||||
# Blanks is a list of indexes that mark non-module positions (such
|
||||
# as Racks and tactical Modes. This allows us to skip over common
|
||||
@@ -536,13 +542,13 @@ class FittingView(d.Display):
|
||||
self.PopupMenu(menu)
|
||||
|
||||
def click(self, event):
|
||||
'''
|
||||
"""
|
||||
Handle click event on modules.
|
||||
|
||||
This is only useful for the State column. If multiple items are selected,
|
||||
and we have clicked the State column, iterate through the selections and
|
||||
change State
|
||||
'''
|
||||
"""
|
||||
row, _, col = self.HitTestSubItem(event.Position)
|
||||
|
||||
# only do State column and ignore invalid rows
|
||||
@@ -584,12 +590,12 @@ class FittingView(d.Display):
|
||||
return self.slotColourMap.get(slot) or self.GetBackgroundColour()
|
||||
|
||||
def refresh(self, stuff):
|
||||
'''
|
||||
"""
|
||||
Displays fitting
|
||||
|
||||
Sends data to d.Display.refresh where the rows and columns are set up, then does a
|
||||
bit of post-processing (colors)
|
||||
'''
|
||||
"""
|
||||
self.Freeze()
|
||||
d.Display.refresh(self, stuff)
|
||||
|
||||
@@ -644,6 +650,7 @@ class FittingView(d.Display):
|
||||
def Snapshot(self):
|
||||
return self.FVsnapshot
|
||||
|
||||
# noinspection PyPropertyAccess
|
||||
def MakeSnapshot(self, maxColumns=1337):
|
||||
|
||||
if self.FVsnapshot:
|
||||
@@ -677,7 +684,6 @@ class FittingView(d.Display):
|
||||
isize = 16
|
||||
headerSize = max(isize, tdc.GetTextExtent("W")[0]) + padding * 2
|
||||
|
||||
maxWidth = 0
|
||||
maxRowHeight = isize
|
||||
rows = 0
|
||||
for st in self.mods:
|
||||
@@ -741,7 +747,7 @@ class FittingView(d.Display):
|
||||
maxWidth += columnsWidths[i]
|
||||
|
||||
mdc = wx.MemoryDC()
|
||||
mbmp = wx.EmptyBitmap(maxWidth, (maxRowHeight) * rows + padding * 4 + headerSize)
|
||||
mbmp = wx.EmptyBitmap(maxWidth, maxRowHeight * rows + padding * 4 + headerSize)
|
||||
|
||||
mdc.SelectObject(mbmp)
|
||||
|
||||
@@ -771,8 +777,7 @@ class FittingView(d.Display):
|
||||
bmp = col.bitmap
|
||||
opts.m_labelBitmap = bmp
|
||||
|
||||
width = render.DrawHeaderButton(self, mdc, (cx, padding, columnsWidths[i], headerSize), wx.CONTROL_CURRENT,
|
||||
sortArrow=wx.HDR_SORT_ICON_NONE, params=opts)
|
||||
render.DrawHeaderButton(self, mdc, (cx, padding, columnsWidths[i], headerSize), wx.CONTROL_CURRENT, sortArrow=wx.HDR_SORT_ICON_NONE, params=opts)
|
||||
|
||||
cx += columnsWidths[i]
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
# noinspection PyPackageRequirements
|
||||
from wx.lib.buttons import GenBitmapButton
|
||||
|
||||
from service.market import Market
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
# =============================================================================
|
||||
|
||||
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
from gui.bitmapLoader import BitmapLoader
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
|
||||
# =============================================================================
|
||||
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
import gui.display as d
|
||||
from gui.builtinViewColumns.state import State
|
||||
@@ -27,8 +28,8 @@ from service.market import Market
|
||||
|
||||
|
||||
class CargoViewDrop(wx.PyDropTarget):
|
||||
def __init__(self, dropFn):
|
||||
wx.PyDropTarget.__init__(self)
|
||||
def __init__(self, dropFn, *args, **kwargs):
|
||||
super(CargoViewDrop, self).__init__(*args, **kwargs)
|
||||
self.dropFn = dropFn
|
||||
# this is really transferring an EVE itemID
|
||||
self.dropData = wx.PyTextDataObject()
|
||||
@@ -66,13 +67,13 @@ class CargoView(d.Display):
|
||||
self.Bind(wx.EVT_RIGHT_DOWN, self.scheduleMenu)
|
||||
|
||||
def handleListDrag(self, x, y, data):
|
||||
'''
|
||||
"""
|
||||
Handles dragging of items from various pyfa displays which support it
|
||||
|
||||
data is list with two indices:
|
||||
data[0] is hard-coded str of originating source
|
||||
data[1] is typeID or index of data we want to manipulate
|
||||
'''
|
||||
"""
|
||||
|
||||
if data[0] == "fitting":
|
||||
self.swapModule(x, y, int(data[1]))
|
||||
@@ -104,7 +105,7 @@ class CargoView(d.Display):
|
||||
event.Skip()
|
||||
|
||||
def swapModule(self, x, y, modIdx):
|
||||
'''Swap a module from fitting window with cargo'''
|
||||
"""Swap a module from fitting window with cargo"""
|
||||
sFit = Fit.getInstance()
|
||||
fit = sFit.getFit(self.mainFrame.getActiveFit())
|
||||
dstRow, _ = self.HitTest((x, y))
|
||||
|
||||
@@ -17,9 +17,12 @@
|
||||
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
|
||||
# =============================================================================
|
||||
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
|
||||
# noinspection PyPackageRequirements
|
||||
import wx.lib.newevent
|
||||
# noinspection PyPackageRequirements
|
||||
import wx.gizmos
|
||||
from gui.bitmapLoader import BitmapLoader
|
||||
from gui.contextMenu import ContextMenu
|
||||
@@ -625,9 +628,9 @@ class APIView(wx.Panel):
|
||||
try:
|
||||
activeChar = self.charEditor.entityEditor.getActiveEntity()
|
||||
list = sChar.apiCharList(activeChar.ID, self.inputID.GetLineText(0), self.inputKey.GetLineText(0))
|
||||
except AuthenticationError, e:
|
||||
except AuthenticationError:
|
||||
self.stStatus.SetLabel("Authentication failure. Please check keyID and vCode combination.")
|
||||
except TimeoutError, e:
|
||||
except TimeoutError:
|
||||
self.stStatus.SetLabel("Request timed out. Please check network connectivity and/or proxy settings.")
|
||||
except Exception, e:
|
||||
self.stStatus.SetLabel("Error:\n%s" % e.message)
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
|
||||
# =============================================================================
|
||||
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
from gui.bitmapLoader import BitmapLoader
|
||||
import gui.globalEvents as GE
|
||||
|
||||
@@ -17,7 +17,9 @@
|
||||
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
|
||||
# =============================================================================
|
||||
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
# noinspection PyPackageRequirements
|
||||
import wx.lib.newevent
|
||||
import gui.utils.colorUtils as colorUtils
|
||||
import gui.utils.drawUtils as drawUtils
|
||||
@@ -34,7 +36,7 @@ PageAdded, EVT_NOTEBOOK_PAGE_ADDED = wx.lib.newevent.NewEvent()
|
||||
PageClosed, EVT_NOTEBOOK_PAGE_CLOSED = wx.lib.newevent.NewEvent()
|
||||
|
||||
|
||||
class VetoAble():
|
||||
class VetoAble(object):
|
||||
def __init__(self):
|
||||
self.__vetoed = False
|
||||
|
||||
@@ -45,7 +47,7 @@ class VetoAble():
|
||||
return self.__vetoed
|
||||
|
||||
|
||||
class NotebookTabChangeEvent():
|
||||
class NotebookTabChangeEvent(object):
|
||||
def __init__(self, old, new):
|
||||
self.__old = old
|
||||
self.__new = new
|
||||
@@ -146,7 +148,8 @@ class PFNotebook(wx.Panel):
|
||||
if self.activePage == page:
|
||||
self.ShowActive()
|
||||
|
||||
def GetBorders(self):
|
||||
@staticmethod
|
||||
def GetBorders():
|
||||
"""Gets border widths to better determine page size in ShowActive()"""
|
||||
|
||||
bx = wx.SystemSettings_GetMetric(wx.SYS_BORDER_X)
|
||||
@@ -335,7 +338,7 @@ class PFNotebook(wx.Panel):
|
||||
event.Skip()
|
||||
|
||||
|
||||
class PFTabRenderer:
|
||||
class PFTabRenderer(object):
|
||||
def __init__(self, size=(36, 24), text=wx.EmptyString, img=None, inclination=6, closeButton=True):
|
||||
"""
|
||||
Renders a new tab
|
||||
@@ -438,7 +441,8 @@ class PFTabRenderer:
|
||||
def SetTabImage(self, img):
|
||||
self.tabImg = img
|
||||
|
||||
def CopyRegion(self, region):
|
||||
@staticmethod
|
||||
def CopyRegion(region):
|
||||
rect = region.GetBox()
|
||||
|
||||
newRegion = wx.Region(rect.X, rect.Y, rect.Width, rect.Height)
|
||||
@@ -527,8 +531,8 @@ class PFTabRenderer:
|
||||
self.tabRegion = wx.RegionFromBitmap(self.tabBackBitmap)
|
||||
self.closeBtnRegion = wx.RegionFromBitmap(self.ctabCloseBmp)
|
||||
self.closeBtnRegion.Offset(
|
||||
self.contentWidth + self.leftWidth - self.ctabCloseBmp.GetWidth() / 2,
|
||||
(self.tabHeight - self.ctabCloseBmp.GetHeight()) / 2
|
||||
self.contentWidth + self.leftWidth - self.ctabCloseBmp.GetWidth() / 2,
|
||||
(self.tabHeight - self.ctabCloseBmp.GetHeight()) / 2
|
||||
)
|
||||
|
||||
def InitColors(self):
|
||||
@@ -591,9 +595,9 @@ class PFTabRenderer:
|
||||
cbmp = wx.BitmapFromImage(cimg)
|
||||
|
||||
mdc.DrawBitmap(
|
||||
cbmp,
|
||||
self.contentWidth + self.leftWidth - self.ctabCloseBmp.GetWidth() / 2,
|
||||
(height - self.ctabCloseBmp.GetHeight()) / 2,
|
||||
cbmp,
|
||||
self.contentWidth + self.leftWidth - self.ctabCloseBmp.GetWidth() / 2,
|
||||
(height - self.ctabCloseBmp.GetHeight()) / 2,
|
||||
)
|
||||
|
||||
mdc.SelectObject(wx.NullBitmap)
|
||||
@@ -609,11 +613,11 @@ class PFTabRenderer:
|
||||
|
||||
def __repr__(self):
|
||||
return "PFTabRenderer(text={}, disabled={}) at {}".format(
|
||||
self.text, self.disabled, hex(id(self))
|
||||
self.text, self.disabled, hex(id(self))
|
||||
)
|
||||
|
||||
|
||||
class PFAddRenderer:
|
||||
class PFAddRenderer(object):
|
||||
def __init__(self):
|
||||
"""Renders the add tab button"""
|
||||
self.addImg = BitmapLoader.getImage("ctabadd", "gui")
|
||||
@@ -652,7 +656,8 @@ class PFAddRenderer:
|
||||
region = wx.RegionFromBitmap(self.tbmp)
|
||||
return region
|
||||
|
||||
def CopyRegion(self, region):
|
||||
@staticmethod
|
||||
def CopyRegion(region):
|
||||
rect = region.GetBox()
|
||||
|
||||
newRegion = wx.Region(rect.X, rect.Y, rect.Width, rect.Height)
|
||||
@@ -973,7 +978,8 @@ class PFTabsContainer(wx.Panel):
|
||||
return tab
|
||||
return None
|
||||
|
||||
def TabHitTest(self, tab, x, y):
|
||||
@staticmethod
|
||||
def TabHitTest(tab, x, y):
|
||||
tabRegion = tab.GetTabRegion()
|
||||
tabPos = tab.GetPosition()
|
||||
tabPosX, tabPosY = tabPos
|
||||
@@ -1117,13 +1123,13 @@ class PFTabsContainer(wx.Panel):
|
||||
else:
|
||||
mdc = wx.BufferedPaintDC(self)
|
||||
|
||||
selected = 0
|
||||
|
||||
if 'wxMac' in wx.PlatformInfo and wx.VERSION < (3, 0):
|
||||
color = wx.Colour(0, 0, 0)
|
||||
brush = wx.Brush(color)
|
||||
|
||||
# noinspection PyPackageRequirements,PyUnresolvedReferences,PyUnresolvedReferences,PyUnresolvedReferences
|
||||
from Carbon.Appearance import kThemeBrushDialogBackgroundActive
|
||||
# noinspection PyUnresolvedReferences
|
||||
brush.MacSetTheme(kThemeBrushDialogBackgroundActive)
|
||||
else:
|
||||
color = wx.SystemSettings_GetColour(wx.SYS_COLOUR_3DFACE)
|
||||
@@ -1253,7 +1259,7 @@ class PFTabsContainer(wx.Panel):
|
||||
if self.tabMinWidth < 1:
|
||||
self.tabMinWidth = 1
|
||||
for tab in self.tabs:
|
||||
w, h = tab.GetSize()
|
||||
tab.GetSize()
|
||||
tab.SetSize((self.tabMinWidth, self.height))
|
||||
|
||||
if self.GetTabsCount() > 0:
|
||||
@@ -1268,6 +1274,7 @@ class PFTabsContainer(wx.Panel):
|
||||
|
||||
pos = tabsWidth
|
||||
selected = None
|
||||
selpos = None
|
||||
for i in range(len(self.tabs) - 1, -1, -1):
|
||||
tab = self.tabs[i]
|
||||
width = tab.tabWidth - self.inclination * 2
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
|
||||
# =============================================================================
|
||||
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
import gui.display as d
|
||||
import gui.globalEvents as GE
|
||||
@@ -28,20 +29,20 @@ from service.fit import Fit
|
||||
from eos.saveddata.drone import Drone as es_Drone
|
||||
|
||||
|
||||
class DummyItem:
|
||||
class DummyItem(object):
|
||||
def __init__(self, txt):
|
||||
self.name = txt
|
||||
self.icon = None
|
||||
|
||||
|
||||
class DummyEntry:
|
||||
class DummyEntry(object):
|
||||
def __init__(self, txt):
|
||||
self.item = DummyItem(txt)
|
||||
|
||||
|
||||
class CommandViewDrop(wx.PyDropTarget):
|
||||
def __init__(self, dropFn):
|
||||
wx.PyDropTarget.__init__(self)
|
||||
def __init__(self, dropFn, *args, **kwargs):
|
||||
super(CommandViewDrop, self).__init__(*args, **kwargs)
|
||||
self.dropFn = dropFn
|
||||
# this is really transferring an EVE itemID
|
||||
self.dropData = wx.PyTextDataObject()
|
||||
@@ -78,14 +79,15 @@ class CommandView(d.Display):
|
||||
self.Bind(wx.EVT_LIST_BEGIN_DRAG, self.startDrag)
|
||||
self.SetDropTarget(CommandViewDrop(self.handleListDrag))
|
||||
|
||||
def handleListDrag(self, x, y, data):
|
||||
'''
|
||||
@staticmethod
|
||||
def handleListDrag(x, y, data):
|
||||
"""
|
||||
Handles dragging of items from various pyfa displays which support it
|
||||
|
||||
data is list with two indices:
|
||||
data[0] is hard-coded str of originating source
|
||||
data[1] is typeID or index of data we want to manipulate
|
||||
'''
|
||||
"""
|
||||
pass
|
||||
|
||||
def kbEvent(self, event):
|
||||
@@ -118,7 +120,8 @@ class CommandView(d.Display):
|
||||
dropSource.SetData(data)
|
||||
dropSource.DoDragDrop()
|
||||
|
||||
def fitSort(self, fit):
|
||||
@staticmethod
|
||||
def fitSort(fit):
|
||||
return fit.name
|
||||
|
||||
def fitChanged(self, event):
|
||||
@@ -151,7 +154,7 @@ class CommandView(d.Display):
|
||||
self.deselectItems()
|
||||
|
||||
# todo: verify
|
||||
if stuff == []:
|
||||
if not stuff:
|
||||
stuff = [DummyEntry("Drag a fit to this area")]
|
||||
|
||||
self.update(stuff)
|
||||
@@ -159,7 +162,7 @@ class CommandView(d.Display):
|
||||
def get(self, row):
|
||||
numFits = len(self.fits)
|
||||
|
||||
if (numFits) == 0:
|
||||
if numFits == 0:
|
||||
return None
|
||||
|
||||
return self.fits[row]
|
||||
@@ -191,7 +194,7 @@ class CommandView(d.Display):
|
||||
fitSrcContext = "commandFit"
|
||||
fitItemContext = item.name
|
||||
context = ((fitSrcContext, fitItemContext),)
|
||||
context = context + (("command",),)
|
||||
context += ("command",),
|
||||
menu = ContextMenu.getMenu((item,), *context)
|
||||
elif sel == -1:
|
||||
fitID = self.mainFrame.getActiveFit()
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
|
||||
# =============================================================================
|
||||
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
import logging
|
||||
|
||||
@@ -58,7 +59,7 @@ class ContextMenu(object):
|
||||
rootMenu.selection = (selection,) if not hasattr(selection, "__iter__") else selection
|
||||
empty = True
|
||||
for i, fullContext in enumerate(fullContexts):
|
||||
amount = 0
|
||||
display_amount = 0
|
||||
srcContext = fullContext[0]
|
||||
try:
|
||||
itemContext = fullContext[1]
|
||||
@@ -68,7 +69,7 @@ class ContextMenu(object):
|
||||
# loop through registered menus
|
||||
m = menuHandler()
|
||||
if m.display(srcContext, selection):
|
||||
amount += 1
|
||||
display_amount += 1
|
||||
texts = m.getText(itemContext, selection)
|
||||
|
||||
if isinstance(texts, basestring):
|
||||
@@ -115,11 +116,11 @@ class ContextMenu(object):
|
||||
|
||||
empty = False
|
||||
|
||||
if amount > 0 and i != len(fullContexts) - 1:
|
||||
if display_amount > 0 and i != len(fullContexts) - 1:
|
||||
rootMenu.AppendSeparator()
|
||||
|
||||
debug_end = len(cls._ids)
|
||||
if (debug_end - debug_start):
|
||||
if debug_end - debug_start:
|
||||
logger.debug("%d new IDs created for this menu" % (debug_end - debug_start))
|
||||
|
||||
return rootMenu if empty is False else None
|
||||
@@ -177,4 +178,29 @@ class ContextMenu(object):
|
||||
return None
|
||||
|
||||
|
||||
from gui.builtinContextMenus import * # noqa
|
||||
# noinspection PyUnresolvedReferences
|
||||
from gui.builtinContextMenus import ( # noqa: E402,F401
|
||||
ammoPattern,
|
||||
amount,
|
||||
cargo,
|
||||
changeAffectingSkills,
|
||||
damagePattern,
|
||||
droneRemoveStack,
|
||||
droneSplit,
|
||||
factorReload,
|
||||
fighterAbilities,
|
||||
implantSets,
|
||||
itemRemove,
|
||||
itemStats,
|
||||
marketJump,
|
||||
metaSwap,
|
||||
moduleAmmoPicker,
|
||||
moduleGlobalAmmoPicker,
|
||||
openFit,
|
||||
priceClear,
|
||||
project,
|
||||
shipJump,
|
||||
tacticalMode,
|
||||
targetResists,
|
||||
whProjector
|
||||
)
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
# =============================================================================
|
||||
|
||||
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
|
||||
|
||||
@@ -53,7 +54,7 @@ class CopySelectDialog(wx.Dialog):
|
||||
mainSizer.Add(selector, 0, wx.EXPAND | wx.ALL, 5)
|
||||
|
||||
buttonSizer = self.CreateButtonSizer(wx.OK | wx.CANCEL)
|
||||
if (buttonSizer):
|
||||
if buttonSizer:
|
||||
mainSizer.Add(buttonSizer, 0, wx.EXPAND | wx.ALL, 5)
|
||||
|
||||
self.SetSizer(mainSizer)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import time
|
||||
import webbrowser
|
||||
import json
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
import requests
|
||||
|
||||
@@ -10,7 +11,7 @@ from service.fit import Fit
|
||||
from eos.saveddata.cargo import Cargo
|
||||
from eos.db import getItem
|
||||
|
||||
import gui.display as d
|
||||
from gui.display import Display
|
||||
import gui.globalEvents as GE
|
||||
|
||||
if 'wxMac' not in wx.PlatformInfo or ('wxMac' in wx.PlatformInfo and wx.VERSION >= (3, 0)):
|
||||
@@ -144,10 +145,9 @@ class CrestFittings(wx.Frame):
|
||||
self.updateCacheStatus(None)
|
||||
self.cacheTimer.Start(1000)
|
||||
self.fitTree.populateSkillTree(fittings)
|
||||
del waitDialog
|
||||
except requests.exceptions.ConnectionError:
|
||||
self.statusbar.SetStatusText("Connection error, please check your internet connection")
|
||||
finally:
|
||||
del waitDialog
|
||||
|
||||
def importFitting(self, event):
|
||||
selection = self.fitView.fitSelection
|
||||
@@ -340,7 +340,8 @@ class CrestMgmt(wx.Dialog):
|
||||
self.lcCharacters.SetColumnWidth(0, wx.LIST_AUTOSIZE)
|
||||
self.lcCharacters.SetColumnWidth(1, wx.LIST_AUTOSIZE)
|
||||
|
||||
def addChar(self, event):
|
||||
@staticmethod
|
||||
def addChar(event):
|
||||
sCrest = Crest.getInstance()
|
||||
uri = sCrest.startServer()
|
||||
webbrowser.open(uri)
|
||||
@@ -411,10 +412,10 @@ class FittingsTreeView(wx.Panel):
|
||||
self.parent.fitView.update(list)
|
||||
|
||||
|
||||
class FitView(d.Display):
|
||||
class FitView(Display):
|
||||
DEFAULT_COLS = ["Base Icon",
|
||||
"Base Name"]
|
||||
|
||||
def __init__(self, parent):
|
||||
d.Display.__init__(self, parent, style=wx.LC_SINGLE_SEL)
|
||||
Display.__init__(self, parent, style=wx.LC_SINGLE_SEL)
|
||||
self.fitSelection = None
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
# =============================================================================
|
||||
|
||||
import sys
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
import gui.mainFrame
|
||||
from gui.viewColumn import ViewColumn
|
||||
@@ -25,6 +26,8 @@ from gui.cachingImageList import CachingImageList
|
||||
|
||||
|
||||
class Display(wx.ListCtrl):
|
||||
DEFAULT_COLS = None
|
||||
|
||||
def __init__(self, parent, size=wx.DefaultSize, style=0):
|
||||
|
||||
wx.ListCtrl.__init__(self, parent, size=size, style=wx.LC_REPORT | style)
|
||||
@@ -64,6 +67,7 @@ class Display(wx.ListCtrl):
|
||||
i += 1
|
||||
|
||||
info = wx.ListItem()
|
||||
# noinspection PyPropertyAccess
|
||||
info.m_mask = wx.LIST_MASK_WIDTH
|
||||
self.InsertColumnInfo(i, info)
|
||||
self.SetColumnWidth(i, 0)
|
||||
@@ -88,11 +92,11 @@ class Display(wx.ListCtrl):
|
||||
|
||||
# Did the point hit any item?
|
||||
if (flags & wx.LIST_HITTEST_ONITEM) == 0:
|
||||
return (-1, 0, -1)
|
||||
return -1, 0, -1
|
||||
|
||||
# If it did hit an item and we are not in report mode, it must be the primary cell
|
||||
if not self.InReportView():
|
||||
return (rowIndex, wx.LIST_HITTEST_ONITEM, 0)
|
||||
return rowIndex, wx.LIST_HITTEST_ONITEM, 0
|
||||
|
||||
# Find which subitem is hit
|
||||
right = 0
|
||||
@@ -105,9 +109,9 @@ class Display(wx.ListCtrl):
|
||||
flag = wx.LIST_HITTEST_ONITEMICON
|
||||
else:
|
||||
flag = wx.LIST_HITTEST_ONITEMLABEL
|
||||
return (rowIndex, flag, i)
|
||||
return rowIndex, flag, i
|
||||
|
||||
return (rowIndex, 0, -1)
|
||||
return rowIndex, 0, -1
|
||||
|
||||
def OnEraseBk(self, event):
|
||||
if self.GetItemCount() > 0:
|
||||
@@ -143,6 +147,7 @@ class Display(wx.ListCtrl):
|
||||
else:
|
||||
event.Skip()
|
||||
|
||||
# noinspection PyPropertyAccess
|
||||
def addColumn(self, i, col):
|
||||
self.activeColumns.append(col)
|
||||
info = wx.ListItem()
|
||||
@@ -217,7 +222,7 @@ class Display(wx.ListCtrl):
|
||||
self.InsertStringItem(sys.maxint, "")
|
||||
|
||||
if listItemCount > stuffItemCount:
|
||||
if listItemCount - stuffItemCount > 20 and stuffItemCount < 20:
|
||||
if listItemCount - stuffItemCount > 20 > stuffItemCount:
|
||||
self.DeleteAllItems()
|
||||
for i in range(stuffItemCount):
|
||||
self.InsertStringItem(sys.maxint, "")
|
||||
|
||||
@@ -17,11 +17,12 @@
|
||||
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
|
||||
# =============================================================================
|
||||
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
|
||||
import gui.globalEvents as GE
|
||||
import gui.marketBrowser as mb
|
||||
import gui.display as d
|
||||
from gui.marketBrowser import ITEM_SELECTED, ItemSelected
|
||||
from gui.display import Display
|
||||
from gui.builtinViewColumns.state import State
|
||||
from gui.contextMenu import ContextMenu
|
||||
from service.fit import Fit
|
||||
@@ -29,8 +30,8 @@ from service.market import Market
|
||||
|
||||
|
||||
class DroneViewDrop(wx.PyDropTarget):
|
||||
def __init__(self, dropFn):
|
||||
wx.PyDropTarget.__init__(self)
|
||||
def __init__(self, dropFn, *args, **kwargs):
|
||||
super(DroneViewDrop, self).__init__(*args, **kwargs)
|
||||
self.dropFn = dropFn
|
||||
# this is really transferring an EVE itemID
|
||||
self.dropData = wx.PyTextDataObject()
|
||||
@@ -43,7 +44,7 @@ class DroneViewDrop(wx.PyDropTarget):
|
||||
return t
|
||||
|
||||
|
||||
class DroneView(d.Display):
|
||||
class DroneView(Display):
|
||||
DEFAULT_COLS = [
|
||||
"State",
|
||||
# "Base Icon",
|
||||
@@ -56,7 +57,7 @@ class DroneView(d.Display):
|
||||
]
|
||||
|
||||
def __init__(self, parent):
|
||||
d.Display.__init__(self, parent, style=wx.LC_SINGLE_SEL | wx.BORDER_NONE)
|
||||
Display.__init__(self, parent, style=wx.LC_SINGLE_SEL | wx.BORDER_NONE)
|
||||
|
||||
self.lastFitId = None
|
||||
|
||||
@@ -64,7 +65,7 @@ class DroneView(d.Display):
|
||||
self.hoveredColumn = None
|
||||
|
||||
self.mainFrame.Bind(GE.FIT_CHANGED, self.fitChanged)
|
||||
self.mainFrame.Bind(mb.ITEM_SELECTED, self.addItem)
|
||||
self.mainFrame.Bind(ITEM_SELECTED, self.addItem)
|
||||
self.Bind(wx.EVT_LEFT_DCLICK, self.removeItem)
|
||||
self.Bind(wx.EVT_LEFT_DOWN, self.click)
|
||||
self.Bind(wx.EVT_KEY_UP, self.kbEvent)
|
||||
@@ -128,20 +129,20 @@ class DroneView(d.Display):
|
||||
dropSource.DoDragDrop()
|
||||
|
||||
def handleDragDrop(self, x, y, data):
|
||||
'''
|
||||
"""
|
||||
Handles dragging of items from various pyfa displays which support it
|
||||
|
||||
data is list with two indices:
|
||||
data[0] is hard-coded str of originating source
|
||||
data[1] is typeID or index of data we want to manipulate
|
||||
'''
|
||||
"""
|
||||
if data[0] == "drone": # we want to merge drones
|
||||
srcRow = int(data[1])
|
||||
dstRow, _ = self.HitTest((x, y))
|
||||
if srcRow != -1 and dstRow != -1:
|
||||
self._merge(srcRow, dstRow)
|
||||
elif data[0] == "market":
|
||||
wx.PostEvent(self.mainFrame, mb.ItemSelected(itemID=int(data[1])))
|
||||
wx.PostEvent(self.mainFrame, ItemSelected(itemID=int(data[1])))
|
||||
|
||||
def _merge(self, src, dst):
|
||||
sFit = Fit.getInstance()
|
||||
|
||||
@@ -17,10 +17,11 @@
|
||||
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
|
||||
# =============================================================================
|
||||
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
|
||||
import gui.globalEvents as GE
|
||||
import gui.marketBrowser as mb
|
||||
import gui.marketBrowser as marketBrowser
|
||||
import gui.mainFrame
|
||||
import gui.display as d
|
||||
from gui.builtinViewColumns.state import State
|
||||
@@ -31,8 +32,8 @@ from service.market import Market
|
||||
|
||||
|
||||
class FighterViewDrop(wx.PyDropTarget):
|
||||
def __init__(self, dropFn):
|
||||
wx.PyDropTarget.__init__(self)
|
||||
def __init__(self, dropFn, *args, **kwargs):
|
||||
super(FighterViewDrop, self).__init__(*args, **kwargs)
|
||||
self.dropFn = dropFn
|
||||
# this is really transferring an EVE itemID
|
||||
self.dropData = wx.PyTextDataObject()
|
||||
@@ -126,7 +127,7 @@ class FighterDisplay(d.Display):
|
||||
self.hoveredColumn = None
|
||||
|
||||
self.mainFrame.Bind(GE.FIT_CHANGED, self.fitChanged)
|
||||
self.mainFrame.Bind(mb.ITEM_SELECTED, self.addItem)
|
||||
self.mainFrame.Bind(marketBrowser.ITEM_SELECTED, self.addItem)
|
||||
self.Bind(wx.EVT_LEFT_DCLICK, self.removeItem)
|
||||
self.Bind(wx.EVT_LEFT_DOWN, self.click)
|
||||
self.Bind(wx.EVT_KEY_UP, self.kbEvent)
|
||||
@@ -190,22 +191,23 @@ class FighterDisplay(d.Display):
|
||||
dropSource.DoDragDrop()
|
||||
|
||||
def handleDragDrop(self, x, y, data):
|
||||
'''
|
||||
"""
|
||||
Handles dragging of items from various pyfa displays which support it
|
||||
|
||||
data is list with two indices:
|
||||
data[0] is hard-coded str of originating source
|
||||
data[1] is typeID or index of data we want to manipulate
|
||||
'''
|
||||
"""
|
||||
if data[0] == "fighter": # we want to merge fighters
|
||||
srcRow = int(data[1])
|
||||
dstRow, _ = self.HitTest((x, y))
|
||||
if srcRow != -1 and dstRow != -1:
|
||||
self._merge(srcRow, dstRow)
|
||||
elif data[0] == "market":
|
||||
wx.PostEvent(self.mainFrame, mb.ItemSelected(itemID=int(data[1])))
|
||||
wx.PostEvent(self.mainFrame, marketBrowser.ItemSelected(itemID=int(data[1])))
|
||||
|
||||
def _merge(self, src, dst):
|
||||
@staticmethod
|
||||
def _merge(src, dst):
|
||||
return
|
||||
|
||||
'''
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# noinspection PyPackageRequirements
|
||||
import wx.lib.newevent
|
||||
|
||||
FitChanged, FIT_CHANGED = wx.lib.newevent.NewEvent()
|
||||
|
||||
@@ -35,4 +35,5 @@ class Graph(object):
|
||||
return None
|
||||
|
||||
|
||||
from gui.builtinGraphs import * # noqa
|
||||
# noinspection PyUnresolvedReferences
|
||||
from gui.builtinGraphs import fitDps # noqa: E402, F401
|
||||
|
||||
@@ -21,6 +21,7 @@ import os
|
||||
import logging
|
||||
import imp
|
||||
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
|
||||
from service.fit import Fit
|
||||
@@ -34,34 +35,47 @@ from config import parsePath
|
||||
# Don't actually import the thing, since it takes for fucking ever
|
||||
try:
|
||||
imp.find_module('matplotlib')
|
||||
enabled = True
|
||||
graphFrame_enabled = True
|
||||
mplImported = True
|
||||
except ImportError:
|
||||
enabled = False
|
||||
graphFrame_enabled = False
|
||||
mplImported = False
|
||||
|
||||
|
||||
mplImported = False
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
if not enabled:
|
||||
logger.info("Problems importing matplotlib; continuing without graphs")
|
||||
|
||||
|
||||
class GraphFrame(wx.Frame):
|
||||
def __init__(self, parent, style=wx.DEFAULT_FRAME_STYLE | wx.NO_FULL_REPAINT_ON_RESIZE | wx.FRAME_FLOAT_ON_PARENT):
|
||||
|
||||
global enabled
|
||||
global graphFrame_enabled
|
||||
global mplImported
|
||||
|
||||
# Import here
|
||||
self.Patch = None
|
||||
self.mpl_version = -1
|
||||
|
||||
try:
|
||||
import matplotlib as mpl
|
||||
self.mpl_version = int(mpl.__version__[0])
|
||||
if self.mpl_version >= 2:
|
||||
mpl.use('wxagg')
|
||||
mplImported = True
|
||||
else:
|
||||
mplImported = False
|
||||
from matplotlib.patches import Patch
|
||||
self.Patch = Patch
|
||||
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as Canvas
|
||||
from matplotlib.figure import Figure
|
||||
enabled = True
|
||||
graphFrame_enabled = True
|
||||
except ImportError:
|
||||
enabled = False
|
||||
mpl = Canvas = Figure = None
|
||||
graphFrame_enabled = False
|
||||
|
||||
|
||||
self.legendFix = False
|
||||
if not enabled:
|
||||
if not graphFrame_enabled:
|
||||
logger.info("Problems importing matplotlib; continuing without graphs")
|
||||
return
|
||||
|
||||
try:
|
||||
@@ -77,8 +91,8 @@ class GraphFrame(wx.Frame):
|
||||
if not mplImported:
|
||||
mpl.use('wxagg')
|
||||
|
||||
enabled = True
|
||||
if mpl.__version__[0] != "1":
|
||||
graphFrame_enabled = True
|
||||
if int(mpl.__version__[0]) < 1:
|
||||
print("pyfa: Found matplotlib version ", mpl.__version__, " - activating OVER9000 workarounds")
|
||||
print("pyfa: Recommended minimum matplotlib version is 1.0.0")
|
||||
self.legendFix = True
|
||||
@@ -236,21 +250,49 @@ class GraphFrame(wx.Frame):
|
||||
self.canvas.draw()
|
||||
return
|
||||
|
||||
if self.legendFix and len(legend) > 0:
|
||||
leg = self.subplot.legend(tuple(legend), "upper right", shadow=False)
|
||||
for t in leg.get_texts():
|
||||
t.set_fontsize('small')
|
||||
if self.mpl_version < 2:
|
||||
if self.legendFix and len(legend) > 0:
|
||||
leg = self.subplot.legend(tuple(legend), "upper right", shadow=False)
|
||||
for t in leg.get_texts():
|
||||
t.set_fontsize('small')
|
||||
|
||||
for l in leg.get_lines():
|
||||
l.set_linewidth(1)
|
||||
for l in leg.get_lines():
|
||||
l.set_linewidth(1)
|
||||
|
||||
elif not self.legendFix and len(legend) > 0:
|
||||
leg = self.subplot.legend(tuple(legend), "upper right", shadow=False, frameon=False)
|
||||
for t in leg.get_texts():
|
||||
t.set_fontsize('small')
|
||||
elif not self.legendFix and len(legend) > 0:
|
||||
leg = self.subplot.legend(tuple(legend), "upper right", shadow=False, frameon=False)
|
||||
for t in leg.get_texts():
|
||||
t.set_fontsize('small')
|
||||
|
||||
for l in leg.get_lines():
|
||||
l.set_linewidth(1)
|
||||
for l in leg.get_lines():
|
||||
l.set_linewidth(1)
|
||||
elif self.mpl_version >= 2:
|
||||
legend2 = []
|
||||
legend_colors = {
|
||||
0: "blue",
|
||||
1: "orange",
|
||||
2: "green",
|
||||
3: "red",
|
||||
4: "purple",
|
||||
5: "brown",
|
||||
6: "pink",
|
||||
7: "grey",
|
||||
}
|
||||
|
||||
for i, i_name in enumerate(legend):
|
||||
try:
|
||||
selected_color = legend_colors[i]
|
||||
except:
|
||||
selected_color = None
|
||||
legend2.append(self.Patch(color=selected_color,label=i_name),)
|
||||
|
||||
if len(legend2) > 0:
|
||||
leg = self.subplot.legend(handles=legend2)
|
||||
for t in leg.get_texts():
|
||||
t.set_fontsize('small')
|
||||
|
||||
for l in leg.get_lines():
|
||||
l.set_linewidth(1)
|
||||
|
||||
self.canvas.draw()
|
||||
self.SetStatusText("")
|
||||
|
||||
@@ -17,9 +17,10 @@
|
||||
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
|
||||
# =============================================================================
|
||||
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
import gui.display as d
|
||||
import gui.marketBrowser as mb
|
||||
import gui.marketBrowser as marketBrowser
|
||||
import gui.mainFrame
|
||||
from gui.builtinViewColumns.state import State
|
||||
from gui.contextMenu import ContextMenu
|
||||
@@ -89,7 +90,7 @@ class ImplantDisplay(d.Display):
|
||||
self.lastFitId = None
|
||||
|
||||
self.mainFrame.Bind(GE.FIT_CHANGED, self.fitChanged)
|
||||
self.mainFrame.Bind(mb.ITEM_SELECTED, self.addItem)
|
||||
self.mainFrame.Bind(marketBrowser.ITEM_SELECTED, self.addItem)
|
||||
self.Bind(wx.EVT_LEFT_DCLICK, self.removeItem)
|
||||
self.Bind(wx.EVT_LEFT_DOWN, self.click)
|
||||
self.Bind(wx.EVT_KEY_UP, self.kbEvent)
|
||||
|
||||
@@ -23,8 +23,11 @@ import csv
|
||||
import sys
|
||||
import subprocess
|
||||
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
# noinspection PyPackageRequirements
|
||||
import wx.html
|
||||
# noinspection PyPackageRequirements
|
||||
import wx.lib.mixins.listctrl as listmix
|
||||
|
||||
import config
|
||||
@@ -479,7 +482,8 @@ class ItemParams(wx.Panel):
|
||||
self.totalAttrsLabel.SetLabel("%d attributes. " % idCount)
|
||||
self.Layout()
|
||||
|
||||
def TranslateValueUnit(self, value, unitName, unitDisplayName):
|
||||
@staticmethod
|
||||
def TranslateValueUnit(value, unitName, unitDisplayName):
|
||||
def itemIDCallback():
|
||||
item = Market.getInstance().getItem(value)
|
||||
return "%s (%d)" % (item.name, value) if item is not None else str(value)
|
||||
@@ -625,17 +629,17 @@ class ItemCompare(wx.Panel):
|
||||
|
||||
if sort is not None:
|
||||
if sort == 0: # Name sort
|
||||
func = lambda x: x.name
|
||||
func = lambda _val: _val.name
|
||||
else:
|
||||
try:
|
||||
# Remember to reduce by 1, because the attrs array
|
||||
# starts at 0 while the list has the item name as column 0.
|
||||
attr = str(self.attrs.keys()[sort - 1])
|
||||
func = lambda x: x.attributes[attr].value if attr in x.attributes else None
|
||||
func = lambda _val: _val.attributes[attr].value if attr in _val.attributes else None
|
||||
except IndexError:
|
||||
# Clicked on a column that's not part of our array (price most likely)
|
||||
self.sortReverse = False
|
||||
func = lambda x: x.attributes['metaLevel'].value if 'metaLevel' in x.attributes else None
|
||||
func = lambda _val: _val.attributes['metaLevel'].value if 'metaLevel' in _val.attributes else None
|
||||
|
||||
self.items = sorted(self.items, key=func, reverse=self.sortReverse)
|
||||
|
||||
@@ -661,7 +665,7 @@ class ItemCompare(wx.Panel):
|
||||
value = item.attributes[attr].value
|
||||
if self.toggleView != 1:
|
||||
valueUnit = str(value)
|
||||
if info and info.unit:
|
||||
elif info and info.unit and self.toggleView == 1:
|
||||
valueUnit = self.TranslateValueUnit(value, info.unit.displayName, info.unit.name)
|
||||
else:
|
||||
valueUnit = formatAmount(value, 3, 0, 0)
|
||||
@@ -671,7 +675,8 @@ class ItemCompare(wx.Panel):
|
||||
self.paramList.RefreshRows()
|
||||
self.Layout()
|
||||
|
||||
def TranslateValueUnit(self, value, unitName, unitDisplayName):
|
||||
@staticmethod
|
||||
def TranslateValueUnit(value, unitName, unitDisplayName):
|
||||
def itemIDCallback():
|
||||
item = Market.getInstance().getItem(value)
|
||||
return "%s (%d)" % (item.name, value) if item is not None else str(value)
|
||||
@@ -837,7 +842,8 @@ class ItemEffects(wx.Panel):
|
||||
|
||||
self.RefreshValues(event)
|
||||
|
||||
def OnRightClick(self, event):
|
||||
@staticmethod
|
||||
def OnRightClick(event):
|
||||
"""
|
||||
Debug use: open effect file with default application.
|
||||
If effect file does not exist, create it
|
||||
|
||||
@@ -22,20 +22,24 @@ import os.path
|
||||
import logging
|
||||
|
||||
import sqlalchemy
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
# noinspection PyPackageRequirements
|
||||
from wx._core import PyDeadObjectError
|
||||
# noinspection PyPackageRequirements
|
||||
from wx.lib.wordwrap import wordwrap
|
||||
# noinspection PyPackageRequirements
|
||||
from wx.lib.inspection import InspectionTool
|
||||
import time
|
||||
|
||||
from codecs import open
|
||||
from wx._core import PyDeadObjectError
|
||||
|
||||
from wx.lib.wordwrap import wordwrap
|
||||
|
||||
import config
|
||||
|
||||
from eos.config import gamedata_version
|
||||
|
||||
import gui.aboutData
|
||||
import gui.chromeTabs
|
||||
from gui.chromeTabs import PFNotebook
|
||||
import gui.globalEvents as GE
|
||||
|
||||
from gui.bitmapLoader import BitmapLoader
|
||||
@@ -55,7 +59,8 @@ from gui.graphFrame import GraphFrame
|
||||
from gui.copySelectDialog import CopySelectDialog
|
||||
from gui.utils.clipboard import toClipboard, fromClipboard
|
||||
from gui.updateDialog import UpdateDialog
|
||||
from gui.builtinViews import * # TODO: unsure if this is needed here
|
||||
# noinspection PyUnresolvedReferences
|
||||
from gui.builtinViews import emptyView, entityEditor, fittingView, implantEditor # noqa: F401
|
||||
from gui import graphFrame
|
||||
|
||||
from service.settings import SettingsProvider
|
||||
@@ -66,14 +71,11 @@ from service.update import Update
|
||||
# import this to access override setting
|
||||
from eos.modifiedAttributeDict import ModifiedAttributeDict
|
||||
from eos.db.saveddata.loadDefaultDatabaseValues import DefaultDatabaseValues
|
||||
from eos import db
|
||||
from eos.db.saveddata.queries import getFit as db_getFit
|
||||
from service.port import Port
|
||||
from service.settings import HTMLExportSettings
|
||||
|
||||
from time import gmtime, strftime
|
||||
import logging
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
import threading
|
||||
import webbrowser
|
||||
@@ -88,10 +90,11 @@ if 'wxMac' not in wx.PlatformInfo or ('wxMac' in wx.PlatformInfo and wx.VERSION
|
||||
|
||||
disableOverrideEditor = False
|
||||
except ImportError as e:
|
||||
AttributeEditor = None
|
||||
print("Error loading Attribute Editor: %s.\nAccess to Attribute Editor is disabled." % e.message)
|
||||
disableOverrideEditor = True
|
||||
|
||||
logger = logging.getLogger("pyfa.gui.mainFrame")
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
# dummy panel(no paint no erasebk)
|
||||
@@ -141,7 +144,7 @@ class MainFrame(wx.Frame):
|
||||
def getInstance(cls):
|
||||
return cls.__instance if cls.__instance is not None else MainFrame()
|
||||
|
||||
def __init__(self, title):
|
||||
def __init__(self, title="pyfa"):
|
||||
self.title = title
|
||||
wx.Frame.__init__(self, None, wx.ID_ANY, self.title)
|
||||
|
||||
@@ -171,7 +174,7 @@ class MainFrame(wx.Frame):
|
||||
self.fitMultiSwitch = MultiSwitch(self.fitting_additions_split)
|
||||
self.additionsPane = AdditionsPane(self.fitting_additions_split)
|
||||
|
||||
self.notebookBrowsers = gui.chromeTabs.PFNotebook(self.browser_fitting_split, False)
|
||||
self.notebookBrowsers = PFNotebook(self.browser_fitting_split, False)
|
||||
|
||||
marketImg = BitmapLoader.getImage("market_small", "gui")
|
||||
shipBrowserImg = BitmapLoader.getImage("ship_small", "gui")
|
||||
@@ -440,13 +443,16 @@ class MainFrame(wx.Frame):
|
||||
dlg = PreferenceDialog(self)
|
||||
dlg.ShowModal()
|
||||
|
||||
def goWiki(self, event):
|
||||
@staticmethod
|
||||
def goWiki(event):
|
||||
webbrowser.open('https://github.com/pyfa-org/Pyfa/wiki')
|
||||
|
||||
def goForums(self, event):
|
||||
@staticmethod
|
||||
def goForums(event):
|
||||
webbrowser.open('https://forums.eveonline.com/default.aspx?g=posts&t=466425')
|
||||
|
||||
def loadDatabaseDefaults(self, event):
|
||||
@staticmethod
|
||||
def loadDatabaseDefaults(event):
|
||||
# Import values that must exist otherwise Pyfa breaks
|
||||
DefaultDatabaseValues.importRequiredDefaults()
|
||||
# Import default values for damage profiles
|
||||
@@ -700,27 +706,27 @@ class MainFrame(wx.Frame):
|
||||
self.marketBrowser.search.Focus()
|
||||
|
||||
def clipboardEft(self):
|
||||
fit = db.getFit(self.getActiveFit())
|
||||
fit = db_getFit(self.getActiveFit())
|
||||
toClipboard(Port.exportEft(fit))
|
||||
|
||||
def clipboardEftImps(self):
|
||||
fit = db.getFit(self.getActiveFit())
|
||||
fit = db_getFit(self.getActiveFit())
|
||||
toClipboard(Port.exportEftImps(fit))
|
||||
|
||||
def clipboardDna(self):
|
||||
fit = db.getFit(self.getActiveFit())
|
||||
fit = db_getFit(self.getActiveFit())
|
||||
toClipboard(Port.exportDna(fit))
|
||||
|
||||
def clipboardCrest(self):
|
||||
fit = db.getFit(self.getActiveFit())
|
||||
fit = db_getFit(self.getActiveFit())
|
||||
toClipboard(Port.exportCrest(fit))
|
||||
|
||||
def clipboardXml(self):
|
||||
fit = db.getFit(self.getActiveFit())
|
||||
fit = db_getFit(self.getActiveFit())
|
||||
toClipboard(Port.exportXml(None, fit))
|
||||
|
||||
def clipboardMultiBuy(self):
|
||||
fit = db.getFit(self.getActiveFit())
|
||||
fit = db_getFit(self.getActiveFit())
|
||||
toClipboard(Port.exportMultiBuy(fit))
|
||||
|
||||
def importFromClipboard(self, event):
|
||||
@@ -792,7 +798,7 @@ class MainFrame(wx.Frame):
|
||||
"All Files (*)|*"),
|
||||
style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST | wx.FD_MULTIPLE
|
||||
)
|
||||
if (dlg.ShowModal() == wx.ID_OK):
|
||||
if dlg.ShowModal() == wx.ID_OK:
|
||||
self.progressDialog = wx.ProgressDialog(
|
||||
"Importing fits",
|
||||
" " * 100, # set some arbitrary spacing to create width in window
|
||||
@@ -946,13 +952,12 @@ class MainFrame(wx.Frame):
|
||||
if not self.graphFrame:
|
||||
self.graphFrame = GraphFrame(self)
|
||||
|
||||
if graphFrame.enabled:
|
||||
if graphFrame.graphFrame_enabled:
|
||||
self.graphFrame.Show()
|
||||
else:
|
||||
elif graphFrame.graphFrame_enabled:
|
||||
self.graphFrame.SetFocus()
|
||||
|
||||
def openWXInspectTool(self, event):
|
||||
from wx.lib.inspection import InspectionTool
|
||||
if not InspectionTool().initialized:
|
||||
InspectionTool().Init()
|
||||
|
||||
|
||||
@@ -17,11 +17,12 @@
|
||||
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
|
||||
# =============================================================================
|
||||
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
|
||||
import config
|
||||
from service.character import Character
|
||||
#import gui.graphFrame
|
||||
import gui.graphFrame
|
||||
import gui.globalEvents as GE
|
||||
from gui.bitmapLoader import BitmapLoader
|
||||
|
||||
@@ -116,6 +117,9 @@ class MainMenuBar(wx.MenuBar):
|
||||
graphFrameItem.SetBitmap(BitmapLoader.getBitmap("graphs_small", "gui"))
|
||||
windowMenu.AppendItem(graphFrameItem)
|
||||
|
||||
if not gui.graphFrame.graphFrame_enabled:
|
||||
self.Enable(self.graphFrameId, False)
|
||||
|
||||
preferencesShortCut = "CTRL+," if 'wxMac' in wx.PlatformInfo else "CTRL+P"
|
||||
preferencesItem = wx.MenuItem(windowMenu, wx.ID_PREFERENCES, "Preferences\t" + preferencesShortCut)
|
||||
preferencesItem.SetBitmap(BitmapLoader.getBitmap("preferences_small", "gui"))
|
||||
|
||||
@@ -17,10 +17,11 @@
|
||||
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
|
||||
# =============================================================================
|
||||
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
from service.market import Market
|
||||
from service.attribute import Attribute
|
||||
import gui.display as d
|
||||
from gui.display import Display
|
||||
import gui.PFSearchBox as SBox
|
||||
from gui.cachingImageList import CachingImageList
|
||||
from gui.contextMenu import ContextMenu
|
||||
@@ -82,6 +83,7 @@ class MarketBrowser(wx.Panel):
|
||||
p.SetSizer(box)
|
||||
vbox.Add(p, 0, wx.EXPAND)
|
||||
self.metaButtons = []
|
||||
btn = None
|
||||
for name in self.sMkt.META_MAP.keys():
|
||||
btn = MetaButton(p, wx.ID_ANY, name.capitalize(), style=wx.BU_EXACTFIT)
|
||||
setattr(self, name, btn)
|
||||
@@ -216,14 +218,14 @@ class MarketTree(wx.TreeCtrl):
|
||||
self.marketBrowser.itemView.selectionMade()
|
||||
|
||||
|
||||
class ItemView(d.Display):
|
||||
class ItemView(Display):
|
||||
DEFAULT_COLS = ["Base Icon",
|
||||
"Base Name",
|
||||
"attr:power,,,True",
|
||||
"attr:cpu,,,True"]
|
||||
|
||||
def __init__(self, parent, marketBrowser):
|
||||
d.Display.__init__(self, parent)
|
||||
Display.__init__(self, parent)
|
||||
marketBrowser.Bind(wx.EVT_TREE_SEL_CHANGED, self.selectionMade)
|
||||
|
||||
self.unfilteredStore = set()
|
||||
@@ -398,7 +400,7 @@ class ItemView(d.Display):
|
||||
metagrpid = sMkt.getMetaGroupIdByItem(item)
|
||||
metatab = self.metaMap.get(metagrpid)
|
||||
metalvl = self.metalvls.get(item.ID, 0)
|
||||
return (catname, mktgrpid, parentname, metatab, metalvl, item.name)
|
||||
return catname, mktgrpid, parentname, metatab, metalvl, item.name
|
||||
|
||||
def contextMenu(self, event):
|
||||
# Check if something is selected, if so, spawn the menu for it
|
||||
@@ -429,7 +431,7 @@ class ItemView(d.Display):
|
||||
# Mark current item list as active
|
||||
self.active = items
|
||||
# Show them
|
||||
d.Display.populate(self, items)
|
||||
Display.populate(self, items)
|
||||
|
||||
def refresh(self, items):
|
||||
if len(items) > 1:
|
||||
@@ -445,7 +447,7 @@ class ItemView(d.Display):
|
||||
# set shortcut info for first 9 modules
|
||||
item.marketShortcut = i + 1
|
||||
|
||||
d.Display.refresh(self, items)
|
||||
Display.refresh(self, items)
|
||||
|
||||
def makeReverseMetaMap(self):
|
||||
"""
|
||||
|
||||
@@ -17,13 +17,13 @@
|
||||
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
|
||||
# =============================================================================
|
||||
|
||||
import gui.chromeTabs
|
||||
from gui.chromeTabs import PFNotebook
|
||||
import gui.builtinViews.emptyView
|
||||
|
||||
|
||||
class MultiSwitch(gui.chromeTabs.PFNotebook):
|
||||
class MultiSwitch(PFNotebook):
|
||||
def __init__(self, parent):
|
||||
gui.chromeTabs.PFNotebook.__init__(self, parent)
|
||||
PFNotebook.__init__(self, parent)
|
||||
# self.AddPage() # now handled by mainFrame
|
||||
self.handlers = handlers = []
|
||||
for type in TabSpawner.tabTypes:
|
||||
@@ -40,10 +40,10 @@ class MultiSwitch(gui.chromeTabs.PFNotebook):
|
||||
tabWnd = gui.builtinViews.emptyView.BlankPage(self)
|
||||
tabWnd.handleDrag = lambda type, info: self.handleDrag(type, info)
|
||||
|
||||
gui.chromeTabs.PFNotebook.AddPage(self, tabWnd, tabTitle, tabImage, True)
|
||||
PFNotebook.AddPage(self, tabWnd, tabTitle, tabImage, True)
|
||||
|
||||
def DeletePage(self, n, *args, **kwargs):
|
||||
gui.chromeTabs.PFNotebook.DeletePage(self, n, *args, **kwargs)
|
||||
PFNotebook.DeletePage(self, n, *args, **kwargs)
|
||||
if self.GetPageCount() == 0:
|
||||
self.AddPage()
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
|
||||
from service.fit import Fit
|
||||
|
||||
@@ -17,8 +17,10 @@
|
||||
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
|
||||
# =============================================================================
|
||||
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
from gui.bitmapLoader import BitmapLoader
|
||||
# noinspection PyPackageRequirements
|
||||
from wx.lib.intctrl import IntCtrl
|
||||
from gui.utils.clipboard import toClipboard, fromClipboard
|
||||
from gui.builtinViews.entityEditor import EntityEditor, BaseValidator
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
|
||||
# =============================================================================
|
||||
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
from gui.preferenceView import PreferenceView
|
||||
from gui.bitmapLoader import BitmapLoader
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
|
||||
# =============================================================================
|
||||
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
|
||||
|
||||
@@ -37,4 +38,11 @@ class PreferenceView(object):
|
||||
return wx.NullBitmap
|
||||
|
||||
|
||||
from gui.builtinPreferenceViews import * # noqa
|
||||
# noinspection PyUnresolvedReferences
|
||||
from gui.builtinPreferenceViews import ( # noqa: E402, F401
|
||||
pyfaGeneralPreferences,
|
||||
pyfaNetworkPreferences,
|
||||
pyfaHTMLExportPreferences,
|
||||
pyfaCrestPreferences,
|
||||
pyfaUpdatePreferences
|
||||
)
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
|
||||
# =============================================================================
|
||||
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
import gui.display as d
|
||||
import gui.globalEvents as GE
|
||||
@@ -30,20 +31,20 @@ from eos.saveddata.fighter import Fighter as es_Fighter
|
||||
from eos.saveddata.module import Module as es_Module
|
||||
|
||||
|
||||
class DummyItem:
|
||||
class DummyItem(object):
|
||||
def __init__(self, txt):
|
||||
self.name = txt
|
||||
self.icon = None
|
||||
|
||||
|
||||
class DummyEntry:
|
||||
class DummyEntry(object):
|
||||
def __init__(self, txt):
|
||||
self.item = DummyItem(txt)
|
||||
|
||||
|
||||
class ProjectedViewDrop(wx.PyDropTarget):
|
||||
def __init__(self, dropFn):
|
||||
wx.PyDropTarget.__init__(self)
|
||||
def __init__(self, dropFn, *args, **kwargs):
|
||||
super(ProjectedViewDrop, self).__init__(*args, **kwargs)
|
||||
self.dropFn = dropFn
|
||||
# this is really transferring an EVE itemID
|
||||
self.dropData = wx.PyTextDataObject()
|
||||
@@ -85,13 +86,13 @@ class ProjectedView(d.Display):
|
||||
self.SetDropTarget(ProjectedViewDrop(self.handleListDrag))
|
||||
|
||||
def handleListDrag(self, x, y, data):
|
||||
'''
|
||||
"""
|
||||
Handles dragging of items from various pyfa displays which support it
|
||||
|
||||
data is list with two indices:
|
||||
data[0] is hard-coded str of originating source
|
||||
data[1] is typeID or index of data we want to manipulate
|
||||
'''
|
||||
"""
|
||||
|
||||
if data[0] == "projected":
|
||||
# if source is coming from projected, we are trying to combine drones.
|
||||
@@ -146,10 +147,12 @@ class ProjectedView(d.Display):
|
||||
if sFit.mergeDrones(fitID, self.get(src), dstDrone, True):
|
||||
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID))
|
||||
|
||||
def moduleSort(self, module):
|
||||
@staticmethod
|
||||
def moduleSort(module):
|
||||
return module.item.name
|
||||
|
||||
def fighterSort(self, fighter):
|
||||
@staticmethod
|
||||
def fighterSort(fighter):
|
||||
return fighter.item.name
|
||||
|
||||
def droneSort(self, drone):
|
||||
@@ -160,7 +163,8 @@ class ProjectedView(d.Display):
|
||||
return (self.droneView.DRONE_ORDER.index(item.marketGroup.name),
|
||||
drone.item.name)
|
||||
|
||||
def fitSort(self, fit):
|
||||
@staticmethod
|
||||
def fitSort(fit):
|
||||
return fit.name
|
||||
|
||||
def fitChanged(self, event):
|
||||
@@ -203,7 +207,7 @@ class ProjectedView(d.Display):
|
||||
|
||||
self.deselectItems()
|
||||
|
||||
if stuff == []:
|
||||
if not stuff:
|
||||
stuff = [DummyEntry("Drag an item or fit, or use right-click menu for system effects")]
|
||||
|
||||
self.update(stuff)
|
||||
@@ -276,7 +280,7 @@ class ProjectedView(d.Display):
|
||||
fitSrcContext = "projectedFit"
|
||||
fitItemContext = item.name
|
||||
context = ((fitSrcContext, fitItemContext),)
|
||||
context = context + (("projected",),)
|
||||
context += ("projected",),
|
||||
menu = ContextMenu.getMenu((item,), *context)
|
||||
elif sel == -1:
|
||||
fitID = self.mainFrame.getActiveFit()
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
import csv
|
||||
import logging
|
||||
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
|
||||
try:
|
||||
# noinspection PyPackageRequirements
|
||||
import wx.propgrid as wxpg
|
||||
except:
|
||||
if wx.VERSION < (2, 9):
|
||||
@@ -11,7 +13,7 @@ except:
|
||||
else:
|
||||
raise
|
||||
|
||||
import eos.db
|
||||
from eos.db.gamedata.queries import getItem, getAttributeInfo
|
||||
from service.market import Market
|
||||
import gui.display as d
|
||||
import gui.globalEvents as GE
|
||||
@@ -98,14 +100,14 @@ class AttributeEditor(wx.Frame):
|
||||
dlg = wx.FileDialog(self, "Import pyfa override file",
|
||||
wildcard="pyfa override file (*.csv)|*.csv",
|
||||
style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST)
|
||||
if (dlg.ShowModal() == wx.ID_OK):
|
||||
if dlg.ShowModal() == wx.ID_OK:
|
||||
path = dlg.GetPath()
|
||||
with open(path, 'rb') as csvfile:
|
||||
spamreader = csv.reader(csvfile)
|
||||
for row in spamreader:
|
||||
itemID, attrID, value = row
|
||||
item = eos.db.getItem(int(itemID))
|
||||
attr = eos.db.getAttributeInfo(int(attrID))
|
||||
item = getItem(int(itemID))
|
||||
attr = getAttributeInfo(int(attrID))
|
||||
item.setOverride(attr, float(value))
|
||||
self.itemView.updateItems(True)
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
# Notes: leave the commented code as it is, those line will be removed someday
|
||||
###########################################################################
|
||||
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
from gui.bitmapLoader import BitmapLoader
|
||||
|
||||
@@ -145,7 +146,7 @@ class TogglePanel(wx.Panel):
|
||||
"""
|
||||
Handles the status changes (collapsing/expanding).
|
||||
|
||||
:param `sz`: an instance of `wx.Size`.
|
||||
:param sz: an instance of `wx.Size`.
|
||||
"""
|
||||
|
||||
# minimal size has priority over the best size so set here our min size
|
||||
|
||||
@@ -11,6 +11,7 @@ PyfaGauge is a generic Gauge implementation tailored for PYFA (Python Fitting As
|
||||
It uses the easeOutQuad equation from caurina.transitions.Tweener to do the animation stuff
|
||||
"""
|
||||
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
import copy
|
||||
|
||||
@@ -143,7 +144,7 @@ class PyGauge(wx.PyWindow):
|
||||
"""
|
||||
Sets the bar gradient. This overrides the BarColour.
|
||||
|
||||
:param `gradient`: a tuple containing the gradient start and end colours.
|
||||
:param gradient: a tuple containing the gradient start and end colours.
|
||||
"""
|
||||
if gradient is None:
|
||||
self._barGradient = None
|
||||
@@ -162,7 +163,7 @@ class PyGauge(wx.PyWindow):
|
||||
"""
|
||||
Sets the border padding.
|
||||
|
||||
:param `padding`: pixels between the border and the progress bar.
|
||||
:param padding: pixels between the border and the progress bar.
|
||||
"""
|
||||
|
||||
self._border_padding = padding
|
||||
@@ -188,7 +189,8 @@ class PyGauge(wx.PyWindow):
|
||||
Sets the range of the gauge. The gauge length is its
|
||||
value as a proportion of the range.
|
||||
|
||||
:param `range`: The maximum value of the gauge.
|
||||
:param reinit:
|
||||
:param range: The maximum value of the gauge.
|
||||
"""
|
||||
|
||||
if self._range == range:
|
||||
@@ -262,11 +264,12 @@ class PyGauge(wx.PyWindow):
|
||||
self.Animate()
|
||||
self._tooltip.SetTip("%.2f/%.2f" % (self._value, self._range if self._range > 0.01 else 0))
|
||||
|
||||
def OnEraseBackground(self, event):
|
||||
@staticmethod
|
||||
def OnEraseBackground(event):
|
||||
"""
|
||||
Handles the ``wx.EVT_ERASE_BACKGROUND`` event for L{PyGauge}.
|
||||
|
||||
:param `event`: a `wx.EraseEvent` event to be processed.
|
||||
:param event: a `wx.EraseEvent` event to be processed.
|
||||
|
||||
:note: This method is intentionally empty to reduce flicker.
|
||||
"""
|
||||
@@ -277,7 +280,7 @@ class PyGauge(wx.PyWindow):
|
||||
"""
|
||||
Handles the ``wx.EVT_PAINT`` event for L{PyGauge}.
|
||||
|
||||
:param `event`: a `wx.PaintEvent` event to be processed.
|
||||
:param event: a `wx.PaintEvent` event to be processed.
|
||||
"""
|
||||
|
||||
dc = wx.BufferedPaintDC(self)
|
||||
@@ -320,8 +323,6 @@ class PyGauge(wx.PyWindow):
|
||||
# time on them if not needed. See GH issue #282
|
||||
|
||||
pv = value
|
||||
xv = 1
|
||||
transition = 0
|
||||
|
||||
if pv <= 100:
|
||||
xv = pv / 100
|
||||
@@ -408,7 +409,7 @@ class PyGauge(wx.PyWindow):
|
||||
"""
|
||||
Handles the ``wx.EVT_TIMER`` event for L{PyfaGauge}.
|
||||
|
||||
:param `event`: a timer event
|
||||
:param event: a timer event
|
||||
"""
|
||||
oldValue = self._oldPercentage
|
||||
value = self._percentage
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
|
||||
# =============================================================================
|
||||
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
from service.targetResists import TargetResists
|
||||
from gui.bitmapLoader import BitmapLoader
|
||||
@@ -188,15 +189,17 @@ class ResistsEditorDlg(wx.Dialog):
|
||||
self.Destroy()
|
||||
|
||||
def ValuesUpdated(self, event=None):
|
||||
'''
|
||||
"""
|
||||
Event that is fired when resists values change. Iterates through all
|
||||
resist edit fields. If blank, sets it to 0.0. If it is not a proper
|
||||
decimal value, sets text color to red and refuses to save changes until
|
||||
issue is resolved
|
||||
'''
|
||||
"""
|
||||
if self.block:
|
||||
return
|
||||
|
||||
editObj = None
|
||||
|
||||
try:
|
||||
p = self.entityEditor.getActiveEntity()
|
||||
|
||||
@@ -235,7 +238,7 @@ class ResistsEditorDlg(wx.Dialog):
|
||||
self.Refresh()
|
||||
|
||||
def patternChanged(self, event=None):
|
||||
"Event fired when user selects pattern. Can also be called from script"
|
||||
"""Event fired when user selects pattern. Can also be called from script"""
|
||||
|
||||
if not self.entityEditor.checkEntitiesExist():
|
||||
self.Destroy()
|
||||
@@ -259,7 +262,7 @@ class ResistsEditorDlg(wx.Dialog):
|
||||
pass
|
||||
|
||||
def importPatterns(self, event):
|
||||
"Event fired when import from clipboard button is clicked"
|
||||
"""Event fired when import from clipboard button is clicked"""
|
||||
|
||||
text = fromClipboard()
|
||||
if text:
|
||||
@@ -277,7 +280,7 @@ class ResistsEditorDlg(wx.Dialog):
|
||||
self.stNotice.SetLabel("Could not import from clipboard")
|
||||
|
||||
def exportPatterns(self, event):
|
||||
"Event fired when export to clipboard button is clicked"
|
||||
"""Event fired when export to clipboard button is clicked"""
|
||||
sTR = TargetResists.getInstance()
|
||||
toClipboard(sTR.exportPatterns())
|
||||
self.stNotice.SetLabel("Patterns exported to clipboard")
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
# =============================================================================
|
||||
|
||||
import logging
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
|
||||
from service.implantSet import ImplantSets
|
||||
@@ -187,7 +188,7 @@ class ImplantSetEditorDlg(wx.Dialog):
|
||||
pass
|
||||
|
||||
def importPatterns(self, event):
|
||||
"Event fired when import from clipboard button is clicked"
|
||||
"""Event fired when import from clipboard button is clicked"""
|
||||
|
||||
text = fromClipboard()
|
||||
if text:
|
||||
@@ -207,7 +208,7 @@ class ImplantSetEditorDlg(wx.Dialog):
|
||||
self.stNotice.SetLabel("Could not import from clipboard")
|
||||
|
||||
def exportPatterns(self, event):
|
||||
"Event fired when export to clipboard button is clicked"
|
||||
"""Event fired when export to clipboard button is clicked"""
|
||||
|
||||
sIS = ImplantSets.getInstance()
|
||||
toClipboard(sIS.exportSets())
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
import gui.utils.drawUtils as drawUtils
|
||||
|
||||
@@ -57,7 +58,7 @@ class PFBaseButton(object):
|
||||
def GetSize(self):
|
||||
w = self.normalBmp.GetWidth()
|
||||
h = self.normalBmp.GetHeight()
|
||||
return (w, h)
|
||||
return w, h
|
||||
|
||||
def GetBitmap(self):
|
||||
return self.normalBmp
|
||||
@@ -136,7 +137,6 @@ class PFToolbar(object):
|
||||
return doRefresh
|
||||
|
||||
def MouseClick(self, event):
|
||||
mx, my = event.GetPosition()
|
||||
bx = self.toolbarX
|
||||
for button in self.buttons:
|
||||
if not button.IsVisible():
|
||||
@@ -196,11 +196,12 @@ class PFToolbar(object):
|
||||
|
||||
return height
|
||||
|
||||
def HitTest(self, target, position, area):
|
||||
@staticmethod
|
||||
def HitTest(target, position, area):
|
||||
x, y = target
|
||||
px, py = position
|
||||
aX, aY = area
|
||||
if (px > x and px < x + aX) and (py > y and py < y + aY):
|
||||
if (x < px < x + aX) and (y < py < y + aY):
|
||||
return True
|
||||
return False
|
||||
|
||||
@@ -354,7 +355,8 @@ class SFBrowserItem(wx.Window):
|
||||
|
||||
event.Skip()
|
||||
|
||||
def GetType(self):
|
||||
@staticmethod
|
||||
def GetType():
|
||||
return -1
|
||||
|
||||
def SetSelected(self, select=True):
|
||||
|
||||
@@ -3,7 +3,9 @@
|
||||
import re
|
||||
import time
|
||||
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
# noinspection PyPackageRequirements
|
||||
from wx.lib.buttons import GenBitmapButton
|
||||
|
||||
from service.fit import Fit
|
||||
@@ -195,7 +197,7 @@ class RaceSelector(wx.Window):
|
||||
padding = self.buttonsPadding
|
||||
|
||||
for bmp in self.raceBmps:
|
||||
if (mx > x and mx < x + bmp.GetWidth()) and (my > y and my < y + bmp.GetHeight()):
|
||||
if (x < mx < x + bmp.GetWidth()) and (y < my < y + bmp.GetHeight()):
|
||||
return self.raceBmps.index(bmp)
|
||||
if self.layout == wx.VERTICAL:
|
||||
y += bmp.GetHeight() + padding
|
||||
@@ -458,7 +460,8 @@ class NavigationPanel(SFItem.SFBrowserItem):
|
||||
stage, data = self.shipBrowser.browseHist.pop()
|
||||
self.gotoStage(stage, data)
|
||||
|
||||
def AdjustChannels(self, bitmap):
|
||||
@staticmethod
|
||||
def AdjustChannels(bitmap):
|
||||
img = wx.ImageFromBitmap(bitmap)
|
||||
img = img.AdjustChannels(1.05, 1.05, 1.05, 1)
|
||||
return wx.BitmapFromImage(img)
|
||||
@@ -628,7 +631,6 @@ class ShipBrowser(wx.Panel):
|
||||
event.Skip()
|
||||
|
||||
def SizeRefreshList(self, event):
|
||||
ewidth, eheight = event.GetSize()
|
||||
self.Layout()
|
||||
self.lpane.Layout()
|
||||
self.lpane.RefreshList(True)
|
||||
@@ -685,7 +687,7 @@ class ShipBrowser(wx.Panel):
|
||||
if len(self.categoryList) == 0:
|
||||
# set cache of category list
|
||||
self.categoryList = list(sMkt.getShipRoot())
|
||||
self.categoryList.sort(key=lambda ship: ship.name)
|
||||
self.categoryList.sort(key=lambda _ship: _ship.name)
|
||||
|
||||
# set map & cache of fittings per category
|
||||
for cat in self.categoryList:
|
||||
@@ -800,7 +802,8 @@ class ShipBrowser(wx.Panel):
|
||||
self.navpanel.ShowNewFitButton(False)
|
||||
self.navpanel.ShowSwitchEmptyGroupsButton(True)
|
||||
|
||||
def nameKey(self, info):
|
||||
@staticmethod
|
||||
def nameKey(info):
|
||||
return info[1]
|
||||
|
||||
def stage3(self, event):
|
||||
@@ -927,7 +930,7 @@ class ShipBrowser(wx.Panel):
|
||||
fits = event.fits
|
||||
|
||||
# sort by ship name, then fit name
|
||||
fits.sort(key=lambda fit: (fit.ship.item.name, fit.name))
|
||||
fits.sort(key=lambda _fit: (_fit.ship.item.name, _fit.name))
|
||||
|
||||
self.lastdata = fits
|
||||
self.lpane.Freeze()
|
||||
@@ -972,7 +975,8 @@ class PFStaticText(wx.Panel):
|
||||
self.SetSizer(mainSizer)
|
||||
self.Layout()
|
||||
|
||||
def GetType(self):
|
||||
@staticmethod
|
||||
def GetType():
|
||||
return -1
|
||||
|
||||
|
||||
@@ -1031,7 +1035,8 @@ class CategoryItem(SFItem.SFBrowserItem):
|
||||
self.animTimer.Stop()
|
||||
self.Refresh()
|
||||
|
||||
def OUT_QUAD(self, t, b, c, d):
|
||||
@staticmethod
|
||||
def OUT_QUAD(t, b, c, d):
|
||||
t = float(t)
|
||||
b = float(b)
|
||||
c = float(c)
|
||||
@@ -1191,8 +1196,7 @@ class ShipItem(SFItem.SFBrowserItem):
|
||||
def OnShowPopup(self, event):
|
||||
pos = event.GetPosition()
|
||||
pos = self.ScreenToClient(pos)
|
||||
contexts = []
|
||||
contexts.append(("baseShip", "Ship Basic"))
|
||||
contexts = [("baseShip", "Ship Basic")]
|
||||
menu = ContextMenu.getMenu(self.baseItem, *contexts)
|
||||
self.PopupMenu(menu, pos)
|
||||
|
||||
@@ -1205,7 +1209,8 @@ class ShipItem(SFItem.SFBrowserItem):
|
||||
self.animTimer.Stop()
|
||||
self.Refresh()
|
||||
|
||||
def OUT_QUAD(self, t, b, c, d):
|
||||
@staticmethod
|
||||
def OUT_QUAD(t, b, c, d):
|
||||
t = float(t)
|
||||
b = float(b)
|
||||
c = float(c)
|
||||
@@ -1271,17 +1276,17 @@ class ShipItem(SFItem.SFBrowserItem):
|
||||
self.toolbarx = rect.width - self.toolbar.GetWidth() - self.padding
|
||||
self.toolbary = (rect.height - self.toolbar.GetHeight()) / 2
|
||||
|
||||
self.toolbarx = self.toolbarx + self.animCount
|
||||
self.toolbarx += self.animCount
|
||||
|
||||
self.shipEffx = self.padding + (rect.height - self.shipEffBk.GetWidth()) / 2
|
||||
self.shipEffy = (rect.height - self.shipEffBk.GetHeight()) / 2
|
||||
|
||||
self.shipEffx = self.shipEffx - self.animCount
|
||||
self.shipEffx -= self.animCount
|
||||
|
||||
self.shipBmpx = self.padding + (rect.height - self.shipBmp.GetWidth()) / 2
|
||||
self.shipBmpy = (rect.height - self.shipBmp.GetHeight()) / 2
|
||||
|
||||
self.shipBmpx = self.shipBmpx - self.animCount
|
||||
self.shipBmpx -= self.animCount
|
||||
|
||||
self.raceBmpx = self.shipEffx + self.shipEffBk.GetWidth() + self.padding
|
||||
self.raceBmpy = (rect.height - self.raceBmp.GetHeight()) / 2
|
||||
@@ -1575,7 +1580,7 @@ class FitItem(SFItem.SFBrowserItem):
|
||||
self.mainFrame.additionsPane.select("Command")
|
||||
|
||||
def OnMouseCaptureLost(self, event):
|
||||
''' Destroy drag information (GH issue #479)'''
|
||||
""" Destroy drag information (GH issue #479)"""
|
||||
if self.dragging and self.dragged:
|
||||
self.dragging = False
|
||||
self.dragged = False
|
||||
@@ -1585,7 +1590,7 @@ class FitItem(SFItem.SFBrowserItem):
|
||||
self.dragWindow = None
|
||||
|
||||
def OnContextMenu(self, event):
|
||||
''' Handles context menu for fit. Dragging is handled by MouseLeftUp() '''
|
||||
""" Handles context menu for fit. Dragging is handled by MouseLeftUp() """
|
||||
sFit = Fit.getInstance()
|
||||
fit = sFit.getFit(self.mainFrame.getActiveFit())
|
||||
|
||||
@@ -1645,10 +1650,12 @@ class FitItem(SFItem.SFBrowserItem):
|
||||
self.animTimer.Stop()
|
||||
self.Refresh()
|
||||
|
||||
def CalculateDelta(self, start, end, delta):
|
||||
@staticmethod
|
||||
def CalculateDelta(start, end, delta):
|
||||
return start + (end - start) * delta
|
||||
|
||||
def OUT_QUAD(self, t, b, c, d):
|
||||
@staticmethod
|
||||
def OUT_QUAD(t, b, c, d):
|
||||
t = float(t)
|
||||
b = float(b)
|
||||
c = float(c)
|
||||
@@ -1815,17 +1822,17 @@ class FitItem(SFItem.SFBrowserItem):
|
||||
self.toolbarx = rect.width - self.toolbar.GetWidth() - self.padding
|
||||
self.toolbary = (rect.height - self.toolbar.GetHeight()) / 2
|
||||
|
||||
self.toolbarx = self.toolbarx + self.animCount
|
||||
self.toolbarx += self.animCount
|
||||
|
||||
self.shipEffx = self.padding + (rect.height - self.shipEffBk.GetWidth()) / 2
|
||||
self.shipEffy = (rect.height - self.shipEffBk.GetHeight()) / 2
|
||||
|
||||
self.shipEffx = self.shipEffx - self.animCount
|
||||
self.shipEffx -= self.animCount
|
||||
|
||||
self.shipBmpx = self.padding + (rect.height - self.shipBmp.GetWidth()) / 2
|
||||
self.shipBmpy = (rect.height - self.shipBmp.GetHeight()) / 2
|
||||
|
||||
self.shipBmpx = self.shipBmpx - self.animCount
|
||||
self.shipBmpx -= self.animCount
|
||||
|
||||
self.textStartx = self.shipEffx + self.shipEffBk.GetWidth() + self.padding
|
||||
|
||||
@@ -1865,8 +1872,6 @@ class FitItem(SFItem.SFBrowserItem):
|
||||
|
||||
mdc.DrawBitmap(self.shipBmp, self.shipBmpx, self.shipBmpy, 0)
|
||||
|
||||
shipName, shipTrait, fittings, booster, timestamp = self.shipFittingInfo
|
||||
|
||||
mdc.SetFont(self.fontNormal)
|
||||
|
||||
fitDate = time.localtime(self.timestamp)
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
|
||||
# =============================================================================
|
||||
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
|
||||
from service.fit import Fit
|
||||
@@ -92,7 +93,8 @@ class StatsPane(wx.Panel):
|
||||
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
self.mainFrame.Bind(GE.FIT_CHANGED, self.fitChanged)
|
||||
|
||||
def contextHandler(self, contentPanel):
|
||||
@staticmethod
|
||||
def contextHandler(contentPanel):
|
||||
viewName = contentPanel.viewName
|
||||
|
||||
def handler(event):
|
||||
|
||||
@@ -42,4 +42,14 @@ class StatsView(object):
|
||||
raise NotImplementedError()
|
||||
|
||||
|
||||
from gui.builtinStatsViews import * # noqa
|
||||
# noinspection PyUnresolvedReferences
|
||||
from gui.builtinStatsViews import ( # noqa: E402, F401
|
||||
resourcesViewFull,
|
||||
resistancesViewFull,
|
||||
firepowerViewFull,
|
||||
miningyieldViewFull,
|
||||
capacitorViewFull,
|
||||
rechargeViewFull,
|
||||
targetingMiscViewFull,
|
||||
priceViewFull,
|
||||
)
|
||||
|
||||
@@ -17,7 +17,9 @@
|
||||
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
|
||||
# =============================================================================
|
||||
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
# noinspection PyPackageRequirements
|
||||
import dateutil.parser
|
||||
from service.settings import UpdateSettings as svc_UpdateSettings
|
||||
|
||||
@@ -48,7 +50,7 @@ class UpdateDialog(wx.Dialog):
|
||||
|
||||
versionSizer = wx.BoxSizer(wx.HORIZONTAL)
|
||||
|
||||
if (self.releaseInfo['prerelease']):
|
||||
if self.releaseInfo['prerelease']:
|
||||
self.releaseText = wx.StaticText(self, wx.ID_ANY, "Pre-release", wx.DefaultPosition, wx.DefaultSize,
|
||||
wx.ALIGN_RIGHT)
|
||||
self.releaseText.SetFont(wx.Font(12, 74, 90, 92, False))
|
||||
@@ -118,7 +120,7 @@ class UpdateDialog(wx.Dialog):
|
||||
self.Close()
|
||||
|
||||
def SuppressChange(self, e):
|
||||
if (self.supressCheckbox.IsChecked()):
|
||||
if self.supressCheckbox.IsChecked():
|
||||
self.UpdateSettings.set('version', self.releaseInfo['tag_name'])
|
||||
else:
|
||||
self.UpdateSettings.set('version', None)
|
||||
|
||||
@@ -42,7 +42,7 @@ def IN_CUBIC(t, b, c, d):
|
||||
c = float(c)
|
||||
d = float(d)
|
||||
|
||||
t = t / d
|
||||
t /= d
|
||||
|
||||
return c * t * t * t + b
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
import gui.utils.colorUtils as colorUtils
|
||||
|
||||
@@ -59,7 +60,7 @@ class LoadAnimation(wx.Window):
|
||||
barColor = wx.SystemSettings_GetColour(wx.SYS_COLOUR_WINDOWTEXT)
|
||||
shadeColor = colorUtils.GetSuitableColor(barColor, 0.75)
|
||||
|
||||
barWidth = (rect.width) / self.bars
|
||||
barWidth = rect.width / self.bars
|
||||
barHeight = rect.height - self.padding * 2
|
||||
|
||||
x = self.padding
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
import math
|
||||
|
||||
@@ -42,7 +43,7 @@ def GetBrightnessO1(color):
|
||||
# Calculates the brightness of a color, different options
|
||||
|
||||
r, g, b = color
|
||||
return (0.299 * r + 0.587 * g + 0.114 * b)
|
||||
return 0.299 * r + 0.587 * g + 0.114 * b
|
||||
|
||||
|
||||
def GetBrightnessO2(color):
|
||||
|
||||
@@ -1,259 +0,0 @@
|
||||
# Backport of OrderedDict() class that runs on Python 2.4, 2.5, 2.6, 2.7 and pypy.
|
||||
# Passes Python2.7's test suite and incorporates all the latest updates.
|
||||
|
||||
try:
|
||||
from thread import get_ident as _get_ident
|
||||
except ImportError:
|
||||
from dummy_thread import get_ident as _get_ident
|
||||
|
||||
try:
|
||||
from _abcoll import KeysView, ValuesView, ItemsView
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
|
||||
class OrderedDict(dict):
|
||||
'Dictionary that remembers insertion order'
|
||||
|
||||
# An inherited dict maps keys to values.
|
||||
# The inherited dict provides __getitem__, __len__, __contains__, and get.
|
||||
# The remaining methods are order-aware.
|
||||
# Big-O running times for all methods are the same as for regular dictionaries.
|
||||
|
||||
# The internal self.__map dictionary maps keys to links in a doubly linked list.
|
||||
# The circular doubly linked list starts and ends with a sentinel element.
|
||||
# The sentinel element never gets deleted (this simplifies the algorithm).
|
||||
# Each link is stored as a list of length three: [PREV, NEXT, KEY].
|
||||
|
||||
def __init__(self, *args, **kwds):
|
||||
'''Initialize an ordered dictionary. Signature is the same as for
|
||||
regular dictionaries, but keyword arguments are not recommended
|
||||
because their insertion order is arbitrary.
|
||||
|
||||
'''
|
||||
if len(args) > 1:
|
||||
raise TypeError('expected at most 1 arguments, got %d' % len(args))
|
||||
try:
|
||||
self.__root
|
||||
except AttributeError:
|
||||
self.__root = root = [] # sentinel node
|
||||
root[:] = [root, root, None]
|
||||
self.__map = {}
|
||||
self.__update(*args, **kwds)
|
||||
|
||||
def __setitem__(self, key, value, dict_setitem=dict.__setitem__):
|
||||
'od.__setitem__(i, y) <==> od[i]=y'
|
||||
# Setting a new item creates a new link which goes at the end of the linked
|
||||
# list, and the inherited dictionary is updated with the new key/value pair.
|
||||
if key not in self:
|
||||
root = self.__root
|
||||
last = root[0]
|
||||
last[1] = root[0] = self.__map[key] = [last, root, key]
|
||||
dict_setitem(self, key, value)
|
||||
|
||||
def __delitem__(self, key, dict_delitem=dict.__delitem__):
|
||||
'od.__delitem__(y) <==> del od[y]'
|
||||
# Deleting an existing item uses self.__map to find the link which is
|
||||
# then removed by updating the links in the predecessor and successor nodes.
|
||||
dict_delitem(self, key)
|
||||
link_prev, link_next, key = self.__map.pop(key)
|
||||
link_prev[1] = link_next
|
||||
link_next[0] = link_prev
|
||||
|
||||
def __iter__(self):
|
||||
'od.__iter__() <==> iter(od)'
|
||||
root = self.__root
|
||||
curr = root[1]
|
||||
while curr is not root:
|
||||
yield curr[2]
|
||||
curr = curr[1]
|
||||
|
||||
def __reversed__(self):
|
||||
'od.__reversed__() <==> reversed(od)'
|
||||
root = self.__root
|
||||
curr = root[0]
|
||||
while curr is not root:
|
||||
yield curr[2]
|
||||
curr = curr[0]
|
||||
|
||||
def clear(self):
|
||||
'od.clear() -> None. Remove all items from od.'
|
||||
try:
|
||||
for node in self.__map.itervalues():
|
||||
del node[:]
|
||||
root = self.__root
|
||||
root[:] = [root, root, None]
|
||||
self.__map.clear()
|
||||
except AttributeError:
|
||||
pass
|
||||
dict.clear(self)
|
||||
|
||||
def popitem(self, last=True):
|
||||
'''od.popitem() -> (k, v), return and remove a (key, value) pair.
|
||||
Pairs are returned in LIFO order if last is true or FIFO order if false.
|
||||
|
||||
'''
|
||||
if not self:
|
||||
raise KeyError('dictionary is empty')
|
||||
root = self.__root
|
||||
if last:
|
||||
link = root[0]
|
||||
link_prev = link[0]
|
||||
link_prev[1] = root
|
||||
root[0] = link_prev
|
||||
else:
|
||||
link = root[1]
|
||||
link_next = link[1]
|
||||
root[1] = link_next
|
||||
link_next[0] = root
|
||||
key = link[2]
|
||||
del self.__map[key]
|
||||
value = dict.pop(self, key)
|
||||
return key, value
|
||||
|
||||
# -- the following methods do not depend on the internal structure --
|
||||
|
||||
def keys(self):
|
||||
'od.keys() -> list of keys in od'
|
||||
return list(self)
|
||||
|
||||
def values(self):
|
||||
'od.values() -> list of values in od'
|
||||
return [self[key] for key in self]
|
||||
|
||||
def items(self):
|
||||
'od.items() -> list of (key, value) pairs in od'
|
||||
return [(key, self[key]) for key in self]
|
||||
|
||||
def iterkeys(self):
|
||||
'od.iterkeys() -> an iterator over the keys in od'
|
||||
return iter(self)
|
||||
|
||||
def itervalues(self):
|
||||
'od.itervalues -> an iterator over the values in od'
|
||||
for k in self:
|
||||
yield self[k]
|
||||
|
||||
def iteritems(self):
|
||||
'od.iteritems -> an iterator over the (key, value) items in od'
|
||||
for k in self:
|
||||
yield (k, self[k])
|
||||
|
||||
def update(*args, **kwds):
|
||||
'''od.update(E, **F) -> None. Update od from dict/iterable E and F.
|
||||
|
||||
If E is a dict instance, does: for k in E: od[k] = E[k]
|
||||
If E has a .keys() method, does: for k in E.keys(): od[k] = E[k]
|
||||
Or if E is an iterable of items, does: for k, v in E: od[k] = v
|
||||
In either case, this is followed by: for k, v in F.items(): od[k] = v
|
||||
|
||||
'''
|
||||
if len(args) > 2:
|
||||
raise TypeError('update() takes at most 2 positional '
|
||||
'arguments (%d given)' % (len(args),))
|
||||
elif not args:
|
||||
raise TypeError('update() takes at least 1 argument (0 given)')
|
||||
self = args[0]
|
||||
# Make progressively weaker assumptions about "other"
|
||||
other = ()
|
||||
if len(args) == 2:
|
||||
other = args[1]
|
||||
if isinstance(other, dict):
|
||||
for key in other:
|
||||
self[key] = other[key]
|
||||
elif hasattr(other, 'keys'):
|
||||
for key in other.keys():
|
||||
self[key] = other[key]
|
||||
else:
|
||||
for key, value in other:
|
||||
self[key] = value
|
||||
for key, value in kwds.items():
|
||||
self[key] = value
|
||||
|
||||
__update = update # let subclasses override update without breaking __init__
|
||||
|
||||
__marker = object()
|
||||
|
||||
def pop(self, key, default=__marker):
|
||||
'''od.pop(k[,d]) -> v, remove specified key and return the corresponding value.
|
||||
If key is not found, d is returned if given, otherwise KeyError is raised.
|
||||
|
||||
'''
|
||||
if key in self:
|
||||
result = self[key]
|
||||
del self[key]
|
||||
return result
|
||||
if default is self.__marker:
|
||||
raise KeyError(key)
|
||||
return default
|
||||
|
||||
def setdefault(self, key, default=None):
|
||||
'od.setdefault(k[,d]) -> od.get(k,d), also set od[k]=d if k not in od'
|
||||
if key in self:
|
||||
return self[key]
|
||||
self[key] = default
|
||||
return default
|
||||
|
||||
def __repr__(self, _repr_running={}):
|
||||
'od.__repr__() <==> repr(od)'
|
||||
call_key = id(self), _get_ident()
|
||||
if call_key in _repr_running:
|
||||
return '...'
|
||||
_repr_running[call_key] = 1
|
||||
try:
|
||||
if not self:
|
||||
return '%s()' % (self.__class__.__name__,)
|
||||
return '%s(%r)' % (self.__class__.__name__, self.items())
|
||||
finally:
|
||||
del _repr_running[call_key]
|
||||
|
||||
def __reduce__(self):
|
||||
'Return state information for pickling'
|
||||
items = [[k, self[k]] for k in self]
|
||||
inst_dict = vars(self).copy()
|
||||
for k in vars(OrderedDict()):
|
||||
inst_dict.pop(k, None)
|
||||
if inst_dict:
|
||||
return (self.__class__, (items,), inst_dict)
|
||||
return self.__class__, (items,)
|
||||
|
||||
def copy(self):
|
||||
'od.copy() -> a shallow copy of od'
|
||||
return self.__class__(self)
|
||||
|
||||
@classmethod
|
||||
def fromkeys(cls, iterable, value=None):
|
||||
'''OD.fromkeys(S[, v]) -> New ordered dictionary with keys from S
|
||||
and values equal to v (which defaults to None).
|
||||
|
||||
'''
|
||||
d = cls()
|
||||
for key in iterable:
|
||||
d[key] = value
|
||||
return d
|
||||
|
||||
def __eq__(self, other):
|
||||
'''od.__eq__(y) <==> od==y. Comparison to another OD is order-sensitive
|
||||
while comparison to a regular mapping is order-insensitive.
|
||||
|
||||
'''
|
||||
if isinstance(other, OrderedDict):
|
||||
return len(self) == len(other) and self.items() == other.items()
|
||||
return dict.__eq__(self, other)
|
||||
|
||||
def __ne__(self, other):
|
||||
return not self == other
|
||||
|
||||
# -- the following methods are only used in Python 2.7 --
|
||||
|
||||
def viewkeys(self):
|
||||
"od.viewkeys() -> a set-like object providing a view on od's keys"
|
||||
return KeysView(self)
|
||||
|
||||
def viewvalues(self):
|
||||
"od.viewvalues() -> an object providing a view on od's values"
|
||||
return ValuesView(self)
|
||||
|
||||
def viewitems(self):
|
||||
"od.viewitems() -> a set-like object providing a view on od's items"
|
||||
return ItemsView(self)
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user