Fixed font discrepancy from different wxPython versions.

This commit is contained in:
blitzmann
2014-05-16 00:59:56 -04:00
committed by Gleb Golubitsky
parent b4f4024903
commit a603a4359a
4 changed files with 30 additions and 13 deletions

View File

@@ -21,6 +21,7 @@ import wx
import wx.lib.newevent
import gui.utils.colorUtils as colorUtils
import gui.utils.drawUtils as drawUtils
import gui.utils.fonts as fonts
from gui import bitmapLoader
_PageChanging, EVT_NOTEBOOK_PAGE_CHANGING = wx.lib.newevent.NewEvent()
@@ -352,14 +353,13 @@ class PFTabRenderer:
self.text = text
self.tabSize = (width, height)
self.closeButton = closeButton
self.fontSize = fontSize
self.selected = False
self.closeBtnHovering = False
self.tabBitmap = None
self.tabBackBitmap = None
self.cbSize = 5
self.padding = 4
self.font = wx.FontFromPixelSize((0, self.fontSize), wx.SWISS, wx.NORMAL, wx.NORMAL, False)
self.font = wx.FontFromPixelSize(fonts.NORMAL, wx.SWISS, wx.NORMAL, wx.NORMAL, False)
self.tabImg = img
self.position = (0, 0) # Not used internally for rendering - helper for tab container
@@ -1275,7 +1275,7 @@ class PFNotebookPagePreview(wx.Frame):
self.padding = 15
self.transp = 0
hfont = wx.FontFromPixelSize((0, 14), wx.SWISS, wx.NORMAL, wx.NORMAL, False)
hfont = wx.FontFromPixelSize(fonts.NORMAL, wx.SWISS, wx.NORMAL, wx.NORMAL, False)
self.SetFont(hfont)
tx, ty = self.GetTextExtent(self.title)
@@ -1338,7 +1338,7 @@ class PFNotebookPagePreview(wx.Frame):
mdc.SetBackground(wx.Brush(color))
mdc.Clear()
font = wx.FontFromPixelSize((0, 14), wx.SWISS, wx.NORMAL,wx.NORMAL, False)
font = wx.FontFromPixelSize(fonts.NORMAL, wx.SWISS, wx.NORMAL, wx.NORMAL, False)
mdc.SetFont(font)
x,y = mdc.GetTextExtent(self.title)

View File

@@ -18,6 +18,7 @@ import math
from gui.utils import colorUtils
import gui.utils.drawUtils as drawUtils
import gui.utils.animEffects as animEffects
import gui.utils.fonts as fonts
class PyGauge(wx.PyWindow):
"""
@@ -74,7 +75,7 @@ class PyGauge(wx.PyWindow):
self._oldPercentage = 0
self._showRemaining = False
self.font = wx.FontFromPixelSize((0,14),wx.SWISS, wx.NORMAL, wx.NORMAL, False)
self.font = wx.FontFromPixelSize(fonts.NORMAL,wx.SWISS, wx.NORMAL, wx.NORMAL, False)
self.SetBarGradient((wx.Colour(119,119,119),wx.Colour(153,153,153)))
self.SetBackgroundColour(wx.Colour(51,51,51))

View File

@@ -16,6 +16,7 @@ import gui.utils.animEffects as animEffects
import gui.sfBrowserItem as SFItem
from gui.contextMenu import ContextMenu
import gui.utils.fonts as fonts
import service
@@ -354,7 +355,7 @@ class NavigationPanel(SFItem.SFBrowserItem):
self.recentSearches = []
self.inSearch = False
self.fontSmall = wx.FontFromPixelSize((0,12),wx.SWISS, wx.NORMAL, wx.NORMAL, False)
self.fontSmall = wx.FontFromPixelSize(fonts.SMALL,wx.SWISS, wx.NORMAL, wx.NORMAL, False)
w,h = size
self.BrowserSearchBox = wx.TextCtrl(self, wx.ID_ANY, "", wx.DefaultPosition, (-1, h - 2 if 'wxGTK' in wx.PlatformInfo else -1 ), wx.TE_PROCESS_ENTER | (wx.BORDER_NONE if 'wxGTK' in wx.PlatformInfo else 0))
self.BrowserSearchBox.Show(False)
@@ -938,7 +939,7 @@ class CategoryItem(SFItem.SFBrowserItem):
self.padding = 4
self.fontBig = wx.FontFromPixelSize((0,15),wx.SWISS, wx.NORMAL, wx.NORMAL, False)
self.fontBig = wx.FontFromPixelSize(fonts.BIG,wx.SWISS, wx.NORMAL, wx.NORMAL, False)
self.animTimerId = wx.NewId()
@@ -1052,9 +1053,9 @@ class ShipItem(SFItem.SFBrowserItem):
self.shipID = shipID
self.fontBig = wx.FontFromPixelSize((0,15),wx.SWISS, wx.NORMAL, wx.BOLD, False)
self.fontNormal = wx.FontFromPixelSize((0,14),wx.SWISS, wx.NORMAL, wx.NORMAL, False)
self.fontSmall = wx.FontFromPixelSize((0,12),wx.SWISS, wx.NORMAL, wx.NORMAL, False)
self.fontBig = wx.FontFromPixelSize(fonts.BIG,wx.SWISS, wx.NORMAL, wx.BOLD, False)
self.fontNormal = wx.FontFromPixelSize(fonts.NORMAL,wx.SWISS, wx.NORMAL, wx.NORMAL, False)
self.fontSmall = wx.FontFromPixelSize(fonts.SMALL,wx.SWISS, wx.NORMAL, wx.NORMAL, False)
self.shipBmp = None
if shipID:
@@ -1440,9 +1441,9 @@ class FitItem(SFItem.SFBrowserItem):
self.dragMotionTrigger = self.dragMotionTrail
self.dragWindow = None
self.fontBig = wx.FontFromPixelSize((0,15),wx.SWISS, wx.NORMAL, wx.BOLD, False)
self.fontNormal = wx.FontFromPixelSize((0,14),wx.SWISS, wx.NORMAL, wx.NORMAL, False)
self.fontSmall = wx.FontFromPixelSize((0,12),wx.SWISS, wx.NORMAL, wx.NORMAL, False)
self.fontBig = wx.FontFromPixelSize(fonts.BIG,wx.SWISS, wx.NORMAL, wx.BOLD, False)
self.fontNormal = wx.FontFromPixelSize(fonts.NORMAL,wx.SWISS, wx.NORMAL, wx.NORMAL, False)
self.fontSmall = wx.FontFromPixelSize(fonts.SMALL,wx.SWISS, wx.NORMAL, wx.NORMAL, False)
self.SetDraggable()

15
gui/utils/fonts.py Normal file
View File

@@ -0,0 +1,15 @@
'''
Font file to handle the differences in font calculations between
different wxPython versions
'''
import wx
if 'wxMSW' in wx.PlatformInfo and wx.VERSION < (2,9):
SMALL = (0,12)
NORMAL = (0,14)
BIG = (0,15)
else:
SMALL = (0,10)
NORMAL = (0,11)
BIG = (0,12)