small getStaticBitmap and getBitmap mod to accept a path

This commit is contained in:
unknown
2010-08-15 14:42:41 +03:00
committed by cncfanatics
parent f79f0d803b
commit 6442c99038
4 changed files with 20 additions and 20 deletions

View File

@@ -21,11 +21,11 @@ import os.path
import config
import wx
def getStaticBitmap(name, parent):
def getStaticBitmap(name, parent, location):
static = wx.StaticBitmap(parent)
static.SetBitmap(getBitmap(name))
static.SetBitmap(getBitmap(name,location))
return static
def getBitmap(name):
path = os.path.join(config.path, "icons", name + ".png")
def getBitmap(name,location):
path = os.path.join(config.path, location, name + ".png")
return wx.Image(path).ConvertToBitmap()

View File

@@ -41,7 +41,7 @@ class MainMenuBar(wx.MenuBar):
fitMenu = wx.Menu()
self.Append(fitMenu, "F&it")
shipBrowserItem = wx.MenuItem(fitMenu, wx.ID_ANY, "Ship &Browser")
shipBrowserItem.SetBitmap(bitmapLoader.getBitmap("ship_small"))
shipBrowserItem.SetBitmap(bitmapLoader.getBitmap("ship_small", "icons"))
fitMenu.AppendItem(shipBrowserItem)
fitMenu.AppendSeparator()
fitMenu.Append(wx.ID_EDIT, "&Rename", "Rename this fit.")
@@ -57,7 +57,7 @@ class MainMenuBar(wx.MenuBar):
self.Append(charMenu, "&Character")
charEditItem = wx.MenuItem(charMenu, wx.ID_ANY, "Character &Editor")
charEditItem.SetBitmap(bitmapLoader.getBitmap("character_small"))
charEditItem.SetBitmap(bitmapLoader.getBitmap("character_small", "icons"))
charMenu.AppendItem(charEditItem)
# Help menu

View File

@@ -24,7 +24,7 @@ class MainToolBar(wx.ToolBar):
def __init__(self, parent):
wx.ToolBar.__init__(self, parent, wx.ID_ANY)
self.AddCheckLabelTool(wx.ID_ANY, "Ship Browser", bitmapLoader.getBitmap("ship_big"))
self.AddLabelTool(wx.ID_ANY, "Character Editor", bitmapLoader.getBitmap("character_big"))
self.AddCheckLabelTool(wx.ID_ANY, "Ship Browser", bitmapLoader.getBitmap("ship_big", "icons"))
self.AddLabelTool(wx.ID_ANY, "Character Editor", bitmapLoader.getBitmap("character_big", "icons"))
self.Realize()

View File

@@ -54,7 +54,7 @@ class StatsPane(wx.Panel):
sizerResources.Add(sizerHardResources, 1, wx.ALIGN_CENTER)
for type in ("turret", "launcher"):
sizerHardResources.Add(bitmapLoader.getStaticBitmap("%s_big" % type, self), 0, wx.ALIGN_CENTER)
sizerHardResources.Add(bitmapLoader.getStaticBitmap("%s_big" % type, self, "icons"), 0, wx.ALIGN_CENTER)
box = wx.BoxSizer(wx.HORIZONTAL)
sizerHardResources.Add(box, 0, wx.ALIGN_CENTER)
@@ -71,7 +71,7 @@ class StatsPane(wx.Panel):
# Calibration points
sizerHardResources.Add(bitmapLoader.getStaticBitmap("calibration_big", self))
sizerHardResources.Add(bitmapLoader.getStaticBitmap("calibration_big", self, "icons"))
box = wx.BoxSizer(wx.HORIZONTAL)
sizerHardResources.Add(box, 0, wx.ALIGN_CENTER)
@@ -96,7 +96,7 @@ class StatsPane(wx.Panel):
base = wx.BoxSizer(wx.HORIZONTAL)
main.Add(base, 0, wx.EXPAND)
base.Add(bitmapLoader.getStaticBitmap(type + "_big", self), 0, wx.ALIGN_CENTER)
base.Add(bitmapLoader.getStaticBitmap(type + "_big", self, "icons"), 0, wx.ALIGN_CENTER)
stats = wx.BoxSizer(wx.VERTICAL)
base.Add(stats, 0, wx.EXPAND)
@@ -149,12 +149,12 @@ class StatsPane(wx.Panel):
sizerResistances.Add(wx.StaticText(self, wx.ID_ANY))
for damageType in ("em", "thermal", "kinetic", "explosive"):
sizerResistances.Add(bitmapLoader.getStaticBitmap("%s_big" % damageType, self), 0, wx.ALIGN_CENTER)
sizerResistances.Add(bitmapLoader.getStaticBitmap("%s_big" % damageType, self, "icons"), 0, wx.ALIGN_CENTER)
sizerResistances.Add(wx.StaticText(self, wx.ID_ANY, "EHP"), 0, wx.ALIGN_CENTER)
for tankType in ("damagePattern", "shield", "armor", "hull"):
sizerResistances.Add(bitmapLoader.getStaticBitmap("%s_big" % tankType, self), 0, wx.ALIGN_CENTER)
sizerResistances.Add(bitmapLoader.getStaticBitmap("%s_big" % tankType, self, "icons"), 0, wx.ALIGN_CENTER)
for damageType in ("em", "thermal", "kinetic", "explosive"):
box = wx.BoxSizer(wx.HORIZONTAL)
@@ -192,10 +192,10 @@ class StatsPane(wx.Panel):
#Add an empty label first for correct alignment.
sizerTankStats.Add(wx.StaticText(self, wx.ID_ANY, ""), 0)
for tankType in ("shieldPassive", "shieldActive", "armorActive", "hullActive"):
sizerTankStats.Add(bitmapLoader.getStaticBitmap("%s_big" % tankType, self), 1, wx.ALIGN_CENTER)
sizerTankStats.Add(bitmapLoader.getStaticBitmap("%s_big" % tankType, self, "icons"), 1, wx.ALIGN_CENTER)
for stability in ("reinforced", "sustained"):
sizerTankStats.Add(bitmapLoader.getStaticBitmap("regen%s_big" % stability.capitalize(), self), 0, wx.ALIGN_CENTER)
sizerTankStats.Add(bitmapLoader.getStaticBitmap("regen%s_big" % stability.capitalize(), self, "icons"), 0, wx.ALIGN_CENTER)
for tankType in ("shieldPassive", "shieldActive", "armorActive", "hullActive"):
tankTypeCap = tankType[0].capitalize() + tankType[1:]
lbl = wx.StaticText(self, wx.ID_ANY, "0.0")
@@ -228,7 +228,7 @@ class StatsPane(wx.Panel):
sizerFirepower.Add(baseBox, 0, wx.ALIGN_CENTER)
image = "droneBay" if damageType == "drone" else damageType
baseBox.Add(bitmapLoader.getStaticBitmap("%s_big" % image, self), 0, wx.ALIGN_CENTER)
baseBox.Add(bitmapLoader.getStaticBitmap("%s_big" % image, self, "icons"), 0, wx.ALIGN_CENTER)
box = wx.BoxSizer(wx.VERTICAL)
baseBox.Add(box, 0, wx.ALIGN_CENTER)
@@ -247,7 +247,7 @@ class StatsPane(wx.Panel):
baseBox = wx.BoxSizer(wx.HORIZONTAL)
sizerFirepower.Add(baseBox, 0, wx.ALIGN_CENTER)
baseBox.Add(bitmapLoader.getStaticBitmap("volley_big", self), 0, wx.ALIGN_CENTER)
baseBox.Add(bitmapLoader.getStaticBitmap("volley_big", self, "icons"), 0, wx.ALIGN_CENTER)
box = wx.BoxSizer(wx.VERTICAL)
baseBox.Add(box, 1, wx.ALIGN_CENTER)
@@ -283,7 +283,7 @@ class StatsPane(wx.Panel):
baseBox = wx.BoxSizer(wx.HORIZONTAL)
sizerCapacitor.Add(baseBox, 1, wx.ALIGN_CENTER)
baseBox.Add(bitmapLoader.getStaticBitmap("capacitorInfo_big", self), 0, wx.ALIGN_CENTER)
baseBox.Add(bitmapLoader.getStaticBitmap("capacitorInfo_big", self, "icons"), 0, wx.ALIGN_CENTER)
box = wx.BoxSizer(wx.VERTICAL)
baseBox.Add(box, 0, wx.ALIGN_CENTER)
@@ -307,7 +307,7 @@ class StatsPane(wx.Panel):
baseBox = wx.BoxSizer(wx.HORIZONTAL)
sizerCapacitor.Add(baseBox, 1, wx.ALIGN_CENTER)
baseBox.Add(bitmapLoader.getStaticBitmap("capacitorRecharge_big", self), 0, wx.ALIGN_CENTER)
baseBox.Add(bitmapLoader.getStaticBitmap("capacitorRecharge_big", self, "icons"), 0, wx.ALIGN_CENTER)
box = wx.BoxSizer(wx.VERTICAL)
baseBox.Add(box, 0, wx.ALIGN_CENTER)
@@ -423,7 +423,7 @@ class StatsPane(wx.Panel):
box = wx.BoxSizer(wx.HORIZONTAL)
gridPrice.Add(box)
box.Add(bitmapLoader.getStaticBitmap(image, self), 0, wx.ALIGN_CENTER)
box.Add(bitmapLoader.getStaticBitmap(image, self, "icons"), 0, wx.ALIGN_CENTER)
vbox = wx.BoxSizer(wx.VERTICAL)
box.Add(vbox, 1, wx.EXPAND)