so many pep8 fixes
(cherry picked from commit bee125d)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
#===============================================================================
|
||||
# =============================================================================
|
||||
# Copyright (C) 2010 Diego Duclos
|
||||
#
|
||||
# This file is part of pyfa.
|
||||
@@ -15,18 +15,15 @@
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
|
||||
#===============================================================================
|
||||
# =============================================================================
|
||||
|
||||
import wx
|
||||
from gui.bitmapLoader import BitmapLoader
|
||||
from wx.lib.intctrl import IntCtrl
|
||||
from gui.utils.clipboard import toClipboard, fromClipboard
|
||||
from service.damagePattern import ImportError
|
||||
from gui.builtinViews.entityEditor import EntityEditor, BaseValidator
|
||||
from service.damagePattern import DamagePattern, ImportError
|
||||
###########################################################################
|
||||
## Class DmgPatternEditorDlg
|
||||
###########################################################################
|
||||
|
||||
|
||||
class DmgPatternTextValidor(BaseValidator):
|
||||
def __init__(self):
|
||||
@@ -47,7 +44,7 @@ class DmgPatternTextValidor(BaseValidator):
|
||||
raise ValueError("Damage Profile name already in use, please choose another.")
|
||||
|
||||
return True
|
||||
except ValueError, e:
|
||||
except ValueError as e:
|
||||
wx.MessageBox(u"{}".format(e), "Error")
|
||||
textCtrl.SetFocus()
|
||||
return False
|
||||
@@ -81,11 +78,12 @@ class DmgPatternEntityEditor(EntityEditor):
|
||||
sDP = DamagePattern.getInstance()
|
||||
sDP.deletePattern(entity)
|
||||
|
||||
|
||||
class DmgPatternEditorDlg(wx.Dialog):
|
||||
DAMAGE_TYPES = ("em", "thermal", "kinetic", "explosive")
|
||||
|
||||
def __init__(self, parent):
|
||||
wx.Dialog.__init__(self, parent, id = wx.ID_ANY, title = u"Damage Pattern Editor", size = wx.Size( 400,240 ))
|
||||
wx.Dialog.__init__(self, parent, id=wx.ID_ANY, title=u"Damage Pattern Editor", size=wx.Size(400, 240))
|
||||
|
||||
self.block = False
|
||||
self.SetSizeHintsSz(wx.DefaultSize, wx.DefaultSize)
|
||||
@@ -111,11 +109,11 @@ class DmgPatternEditorDlg(wx.Dialog):
|
||||
dmgeditSizer.SetNonFlexibleGrowMode(wx.FLEX_GROWMODE_SPECIFIED)
|
||||
|
||||
width = -1
|
||||
defSize = wx.Size(width,-1)
|
||||
defSize = wx.Size(width, -1)
|
||||
|
||||
for i, type in enumerate(self.DAMAGE_TYPES):
|
||||
bmp = wx.StaticBitmap(self, wx.ID_ANY, BitmapLoader.getBitmap("%s_big"%type, "gui"))
|
||||
if i%2:
|
||||
for i, type_ in enumerate(self.DAMAGE_TYPES):
|
||||
bmp = wx.StaticBitmap(self, wx.ID_ANY, BitmapLoader.getBitmap("%s_big" % type_, "gui"))
|
||||
if i % 2:
|
||||
style = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT | wx.LEFT
|
||||
border = 20
|
||||
else:
|
||||
@@ -123,13 +121,13 @@ class DmgPatternEditorDlg(wx.Dialog):
|
||||
border = 5
|
||||
|
||||
# set text edit
|
||||
setattr(self, "%sEdit"%type, IntCtrl(self, wx.ID_ANY, 0, wx.DefaultPosition, defSize))
|
||||
setattr(self, "%sPerc"%type, wx.StaticText(self, wx.ID_ANY, u"0%"))
|
||||
editObj = getattr(self, "%sEdit"%type)
|
||||
setattr(self, "%sEdit" % type_, IntCtrl(self, wx.ID_ANY, 0, wx.DefaultPosition, defSize))
|
||||
setattr(self, "%sPerc" % type_, wx.StaticText(self, wx.ID_ANY, u"0%"))
|
||||
editObj = getattr(self, "%sEdit" % type_)
|
||||
|
||||
dmgeditSizer.Add(bmp, 0, style, border)
|
||||
dmgeditSizer.Add(editObj, 0, wx.BOTTOM | wx.TOP | wx.ALIGN_CENTER_VERTICAL, 5)
|
||||
dmgeditSizer.Add(getattr(self, "%sPerc"%type), 0, wx.LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
|
||||
dmgeditSizer.Add(getattr(self, "%sPerc" % type_), 0, wx.LEFT | wx.ALIGN_CENTER_VERTICAL, 5)
|
||||
|
||||
editObj.Bind(wx.EVT_TEXT, self.ValuesUpdated)
|
||||
editObj.SetLimited(True)
|
||||
@@ -147,7 +145,7 @@ class DmgPatternEditorDlg(wx.Dialog):
|
||||
self.stNotice.Wrap(-1)
|
||||
perSizer.Add(self.stNotice, 0, wx.BOTTOM | wx.TOP | wx.LEFT, 5)
|
||||
|
||||
footerSizer.Add(perSizer, 1, wx.ALIGN_CENTER_VERTICAL, 5)
|
||||
footerSizer.Add(perSizer, 1, wx.ALIGN_CENTER_VERTICAL, 5)
|
||||
|
||||
self.totSizer = wx.BoxSizer(wx.VERTICAL)
|
||||
|
||||
@@ -156,8 +154,8 @@ class DmgPatternEditorDlg(wx.Dialog):
|
||||
mainSizer.Add(contentSizer, 1, wx.EXPAND, 0)
|
||||
|
||||
if "wxGTK" in wx.PlatformInfo:
|
||||
self.closeBtn = wx.Button( self, wx.ID_ANY, u"Close", wx.DefaultPosition, wx.DefaultSize, 0 )
|
||||
mainSizer.Add( self.closeBtn, 0, wx.ALL|wx.ALIGN_RIGHT, 5 )
|
||||
self.closeBtn = wx.Button(self, wx.ID_ANY, u"Close", wx.DefaultPosition, wx.DefaultSize, 0)
|
||||
mainSizer.Add(self.closeBtn, 0, wx.ALL | wx.ALIGN_RIGHT, 5)
|
||||
self.closeBtn.Bind(wx.EVT_BUTTON, self.closeEvent)
|
||||
|
||||
self.SetSizer(mainSizer)
|
||||
@@ -169,13 +167,13 @@ class DmgPatternEditorDlg(wx.Dialog):
|
||||
bitmap = wx.ArtProvider.GetBitmap(art, wx.ART_BUTTON)
|
||||
btn = wx.BitmapButton(self, wx.ID_ANY, bitmap)
|
||||
|
||||
btn.SetMinSize( btn.GetSize() )
|
||||
btn.SetMaxSize( btn.GetSize() )
|
||||
btn.SetMinSize(btn.GetSize())
|
||||
btn.SetMaxSize(btn.GetSize())
|
||||
|
||||
btn.Layout()
|
||||
setattr(self, name, btn)
|
||||
btn.Enable(True)
|
||||
btn.SetToolTipString("%s patterns %s clipboard" % (name, direction) )
|
||||
btn.SetToolTipString("%s patterns %s clipboard" % (name, direction))
|
||||
footerSizer.Add(btn, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_RIGHT)
|
||||
btn.Bind(wx.EVT_BUTTON, getattr(self, "{}Patterns".format(name.lower())))
|
||||
|
||||
@@ -196,12 +194,12 @@ class DmgPatternEditorDlg(wx.Dialog):
|
||||
return
|
||||
|
||||
p = self.entityEditor.getActiveEntity()
|
||||
total = sum(map(lambda attr: getattr(self, "%sEdit"%attr).GetValue(), self.DAMAGE_TYPES))
|
||||
for type in self.DAMAGE_TYPES:
|
||||
editObj = getattr(self, "%sEdit"%type)
|
||||
percObj = getattr(self, "%sPerc"%type)
|
||||
setattr(p, "%sAmount"%type, editObj.GetValue())
|
||||
percObj.SetLabel("%.1f%%"%(float(editObj.GetValue())*100/total if total > 0 else 0))
|
||||
total = sum(map(lambda attr: getattr(self, "%sEdit" % attr).GetValue(), self.DAMAGE_TYPES))
|
||||
for type_ in self.DAMAGE_TYPES:
|
||||
editObj = getattr(self, "%sEdit" % type_)
|
||||
percObj = getattr(self, "%sPerc" % type_)
|
||||
setattr(p, "%sAmount" % type_, editObj.GetValue())
|
||||
percObj.SetLabel("%.1f%%" % (float(editObj.GetValue()) * 100 / total if total > 0 else 0))
|
||||
|
||||
self.totSizer.Layout()
|
||||
|
||||
@@ -211,15 +209,15 @@ class DmgPatternEditorDlg(wx.Dialog):
|
||||
DamagePattern.getInstance().saveChanges(p)
|
||||
|
||||
def restrict(self):
|
||||
for type in self.DAMAGE_TYPES:
|
||||
editObj = getattr(self, "%sEdit"%type)
|
||||
for type_ in self.DAMAGE_TYPES:
|
||||
editObj = getattr(self, "%sEdit" % type_)
|
||||
editObj.Enable(False)
|
||||
self.entityEditor.btnRename.Enable(False)
|
||||
self.entityEditor.btnDelete.Enable(False)
|
||||
|
||||
def unrestrict(self):
|
||||
for type in self.DAMAGE_TYPES:
|
||||
editObj = getattr(self, "%sEdit"%type)
|
||||
for type_ in self.DAMAGE_TYPES:
|
||||
editObj = getattr(self, "%sEdit" % type_)
|
||||
editObj.Enable()
|
||||
self.entityEditor.btnRename.Enable()
|
||||
self.entityEditor.btnDelete.Enable()
|
||||
@@ -255,9 +253,9 @@ class DmgPatternEditorDlg(wx.Dialog):
|
||||
try:
|
||||
sDP.importPatterns(text)
|
||||
self.stNotice.SetLabel("Patterns successfully imported from clipboard")
|
||||
except ImportError, e:
|
||||
except ImportError as e:
|
||||
self.stNotice.SetLabel(str(e))
|
||||
except Exception, e:
|
||||
except Exception:
|
||||
self.stNotice.SetLabel("Could not import from clipboard: unknown errors")
|
||||
finally:
|
||||
self.entityEditor.refreshEntityList()
|
||||
@@ -266,5 +264,5 @@ class DmgPatternEditorDlg(wx.Dialog):
|
||||
|
||||
def exportPatterns(self, event):
|
||||
sDP = DamagePattern.getInstance()
|
||||
toClipboard( sDP.exportPatterns() )
|
||||
toClipboard(sDP.exportPatterns())
|
||||
self.stNotice.SetLabel("Patterns exported to clipboard")
|
||||
|
||||
Reference in New Issue
Block a user