Fix up some stuff, migrate to cleaned up chrome tabs
This commit is contained in:
@@ -45,14 +45,14 @@ def __createDirs(path):
|
|||||||
|
|
||||||
|
|
||||||
def getPyfaRoot():
|
def getPyfaRoot():
|
||||||
base = getattr(sys.modules['__main__'], "__file__", sys.executable) if isFrozen() else sys.argv[0]
|
base = getattr(sys.modules['__main__'], "__file__", sys.executable) if isFrozen() else __file__
|
||||||
root = os.path.dirname(os.path.realpath(os.path.abspath(base)))
|
root = os.path.dirname(os.path.realpath(os.path.abspath(base)))
|
||||||
root = root
|
root = root
|
||||||
return root
|
return root
|
||||||
|
|
||||||
|
|
||||||
def getDefaultSave():
|
def getDefaultSave():
|
||||||
return str(os.path.expanduser(os.path.join("~", ".pyfa")), sys.getfilesystemencoding())
|
return os.path.expanduser(os.path.join("~", ".pyfa"))
|
||||||
|
|
||||||
|
|
||||||
def defPaths(customSavePath):
|
def defPaths(customSavePath):
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
import io
|
import io
|
||||||
import os.path
|
import os.path
|
||||||
import zipfile
|
import zipfile
|
||||||
|
from collections import OrderedDict
|
||||||
|
|
||||||
# noinspection PyPackageRequirements
|
# noinspection PyPackageRequirements
|
||||||
import wx
|
import wx
|
||||||
@@ -29,23 +30,18 @@ import config
|
|||||||
from logbook import Logger
|
from logbook import Logger
|
||||||
logging = Logger(__name__)
|
logging = Logger(__name__)
|
||||||
|
|
||||||
try:
|
|
||||||
from collections import OrderedDict
|
|
||||||
except ImportError:
|
|
||||||
from .utils.compat import OrderedDict
|
|
||||||
|
|
||||||
|
|
||||||
class BitmapLoader(object):
|
class BitmapLoader(object):
|
||||||
try:
|
try:
|
||||||
archive = zipfile.ZipFile(os.path.join(config.pyfaPath, 'imgs.zip'), 'r')
|
archive = zipfile.ZipFile(os.path.join(config.pyfaPath, 'imgs.zip'), 'r')
|
||||||
logging.info("Using zipped image files.")
|
logging.info("Using zipped image files.")
|
||||||
except IOError:
|
except (IOError, TypeError):
|
||||||
logging.info("Using local image files.")
|
logging.info("Using local image files.")
|
||||||
archive = None
|
archive = None
|
||||||
|
|
||||||
cachedBitmaps = OrderedDict()
|
cached_bitmaps = OrderedDict()
|
||||||
dontUseCachedBitmaps = False
|
dont_use_cached_bitmaps = False
|
||||||
max_bmps = 500
|
max_cached_bitmaps = 500
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def getStaticBitmap(cls, name, parent, location):
|
def getStaticBitmap(cls, name, parent, location):
|
||||||
@@ -55,25 +51,25 @@ class BitmapLoader(object):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def getBitmap(cls, name, location):
|
def getBitmap(cls, name, location):
|
||||||
if cls.dontUseCachedBitmaps:
|
if cls.dont_use_cached_bitmaps:
|
||||||
img = cls.getImage(name, location)
|
img = cls.getImage(name, location)
|
||||||
if img is not None:
|
if img is not None:
|
||||||
return img.ConvertToBitmap()
|
return img.ConvertToBitmap()
|
||||||
|
|
||||||
path = "%s%s" % (name, location)
|
path = "%s%s" % (name, location)
|
||||||
|
|
||||||
if len(cls.cachedBitmaps) == cls.max_bmps:
|
if len(cls.cached_bitmaps) == cls.max_cached_bitmaps:
|
||||||
cls.cachedBitmaps.popitem(False)
|
cls.cached_bitmaps.popitem(False)
|
||||||
|
|
||||||
if path not in cls.cachedBitmaps:
|
if path not in cls.cached_bitmaps:
|
||||||
img = cls.getImage(name, location)
|
img = cls.getImage(name, location)
|
||||||
if img is not None:
|
if img is not None:
|
||||||
bmp = img.ConvertToBitmap()
|
bmp = img.ConvertToBitmap()
|
||||||
else:
|
else:
|
||||||
bmp = None
|
bmp = None
|
||||||
cls.cachedBitmaps[path] = bmp
|
cls.cached_bitmaps[path] = bmp
|
||||||
else:
|
else:
|
||||||
bmp = cls.cachedBitmaps[path]
|
bmp = cls.cached_bitmaps[path]
|
||||||
|
|
||||||
return bmp
|
return bmp
|
||||||
|
|
||||||
|
|||||||
1277
gui/chrome_tabs.py
1277
gui/chrome_tabs.py
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user