diff --git a/demo/agw/SpeedMeter.py b/demo/agw/SpeedMeter.py index 3610a3b2..43955984 100644 --- a/demo/agw/SpeedMeter.py +++ b/demo/agw/SpeedMeter.py @@ -25,6 +25,13 @@ except ImportError: # if it's not there locally, try the wxPython lib. # Beginning Of SPEEDMETER Demo wxPython Code #---------------------------------------------------------------------- +def _getAndScaleIcon(filename, width, height): + img = wx.Image(filename, wx.BITMAP_TYPE_ICO) + img.Rescale(width, height) + icon = wx.Icon(img.ConvertToBitmap()) + return icon + + class SpeedMeterDemo(wx.Panel): def __init__(self, parent, log): @@ -183,9 +190,8 @@ class SpeedMeterDemo(wx.Panel): self.SpeedWindow3.SetHandColour(wx.Colour(255, 255, 0)) # Define The Icon We Want - icon = wx.Icon(os.path.normpath(os.path.join(bitmapDir, "smfuel.ico")), wx.BITMAP_TYPE_ICO) - icon.SetWidth(24) - icon.SetHeight(24) + icon = _getAndScaleIcon( + os.path.normpath(os.path.join(bitmapDir, "smfuel.ico")), 24, 24) # Draw The Icon In The Center Of SpeedMeter self.SpeedWindow3.SetMiddleIcon(icon) @@ -245,9 +251,8 @@ class SpeedMeterDemo(wx.Panel): self.SpeedWindow4.SetHandStyle("Arrow") # Define The Icon We Want - icon = wx.Icon(os.path.normpath(os.path.join(bitmapDir, "smtemp.ico")), wx.BITMAP_TYPE_ICO) - icon.SetWidth(16) - icon.SetHeight(16) + icon = _getAndScaleIcon( + os.path.normpath(os.path.join(bitmapDir, "smtemp.ico")), 16, 16) # Draw The Icon In The Center Of SpeedMeter self.SpeedWindow4.SetMiddleIcon(icon) @@ -355,9 +360,8 @@ class SpeedMeterDemo(wx.Panel): # Set The Second Gradient Colour, Which Is The Colour Near The Center Of The SpeedMeter self.SpeedWindow6.SetSecondGradientColour(wx.WHITE) - icon = wx.Icon(os.path.normpath(os.path.join(bitmapDir, "smpi.ico")), wx.BITMAP_TYPE_ICO) - icon.SetHeight(12) - icon.SetWidth(12) + icon = _getAndScaleIcon( + os.path.normpath(os.path.join(bitmapDir, "smpi.ico")), 12, 12) self.SpeedWindow6.SetMiddleIcon(icon) self.SpeedWindow6.SetSpeedValue(pi/3) diff --git a/wx/lib/agw/speedmeter.py b/wx/lib/agw/speedmeter.py index 63eab9c7..f196b51f 100644 --- a/wx/lib/agw/speedmeter.py +++ b/wx/lib/agw/speedmeter.py @@ -268,15 +268,24 @@ SM_DRAW_FANCY_TICKS = 1024 SM_MOUSE_TRACK = 1 """ Flag to allow the left/right click of the mouse to change the :class:`SpeedMeter` value interactively. """ -fontfamily = list(range(70, 78)) -familyname = ["default", "decorative", "roman", "script", "swiss", "modern", "teletype"] +fontfamily = [wx.FONTFAMILY_DEFAULT, wx.FONTFAMILY_DECORATIVE, wx.FONTFAMILY_ROMAN, + wx.FONTFAMILY_SCRIPT, wx.FONTFAMILY_SWISS, wx.FONTFAMILY_MODERN, + wx.FONTFAMILY_TELETYPE, wx.FONTFAMILY_UNKNOWN] +familyname = ["default", "decorative", "roman", "script", "swiss", "modern", + "teletype", "unknown"] -weights = list(range(90, 93)) -weightsname = ["normal", "light", "bold"] +weights = [ wx.FONTWEIGHT_INVALID, wx.FONTWEIGHT_THIN, wx.FONTWEIGHT_EXTRALIGHT, + wx.FONTWEIGHT_LIGHT, wx.FONTWEIGHT_NORMAL, wx.FONTWEIGHT_MEDIUM, + wx.FONTWEIGHT_SEMIBOLD, wx.FONTWEIGHT_BOLD, wx.FONTWEIGHT_EXTRABOLD, + wx.FONTWEIGHT_HEAVY, wx.FONTWEIGHT_EXTRAHEAVY] +weightsname = ["invalid", "thin", "extra-light", "normal", "medium", "semi-bold", + "bold", "extra-bold", "heavy", "extra-heavy"] -styles = [90, 93, 94] +styles = [ wx.FONTSTYLE_NORMAL, wx.FONTSTYLE_ITALIC, wx.FONTSTYLE_SLANT] stylesname = ["normal", "italic", "slant"] + + #---------------------------------------------------------------------- # BUFFERENDWINDOW Class # This Class Has Been Taken From The wxPython Wiki, And Slightly @@ -476,6 +485,7 @@ class SpeedMeter(BufferedWindow): self._agwStyle = agwStyle self._bufferedstyle = bufferedstyle self._mousestyle = mousestyle + self._middleicon = None if self._agwStyle & SM_DRAW_SECTORS and self._agwStyle & SM_DRAW_GRADIENT: errstr = "\nERROR: Incompatible Options: SM_DRAW_SECTORS Can Not Be Used In " @@ -1040,7 +1050,7 @@ class SpeedMeter(BufferedWindow): # Here We Draw The Icon In The Middle, Near The Start Of The Arrow (If Present) # This Is Like The "Fuel" Icon In The Cars - if self._agwStyle & SM_DRAW_MIDDLE_ICON: + if self._agwStyle & SM_DRAW_MIDDLE_ICON and self.GetMiddleIcon(): middleicon = self.GetMiddleIcon() middlewidth, middleheight = self.GetMiddleIconDimens() diff --git a/wx/lib/fancytext.py b/wx/lib/fancytext.py index 111cd11c..db979820 100644 --- a/wx/lib/fancytext.py +++ b/wx/lib/fancytext.py @@ -69,12 +69,33 @@ if sys.platform == "win32": else: _greekEncoding = str(wx.FONTENCODING_ISO8859_7) -_families = {"fixed" : wx.FONTFAMILY_TELETYPE, "default" : wx.FONTFAMILY_DEFAULT, - "decorative" : wx.FONTFAMILY_DECORATIVE, "roman" : wx.FONTFAMILY_ROMAN, - "script" : wx.FONTFAMILY_SCRIPT, "swiss" : wx.FONTFAMILY_SWISS, - "modern" : wx.FONTFAMILY_MODERN} -_styles = {"normal" : wx.FONTSTYLE_NORMAL, "slant" : wx.FONTSTYLE_SLANT, "italic" : wx.FONTSTYLE_ITALIC} -_weights = {"normal" : wx.FONTWEIGHT_NORMAL, "light" : wx.FONTWEIGHT_LIGHT, "bold" : wx.FONTWEIGHT_BOLD} +_families = { "fixed" : wx.FONTFAMILY_TELETYPE, + "default" : wx.FONTFAMILY_DEFAULT, + "decorative" : wx.FONTFAMILY_DECORATIVE, + "roman" : wx.FONTFAMILY_ROMAN, + "script" : wx.FONTFAMILY_SCRIPT, + "swiss" : wx.FONTFAMILY_SWISS, + "modern" : wx.FONTFAMILY_MODERN, + "teletype" : wx.FONTFAMILY_TELETYPE, + "unknown" : wx.FONTFAMILY_UNKNOWN } + +_styles = { "normal" : wx.FONTSTYLE_NORMAL, + "slant" : wx.FONTSTYLE_SLANT, + "italic" : wx.FONTSTYLE_ITALIC } + +_weights = {"normal" : wx.FONTWEIGHT_NORMAL, + "light" : wx.FONTWEIGHT_LIGHT, + "bold" : wx.FONTWEIGHT_BOLD, + "invalid" : wx.FONTWEIGHT_INVALID, + "thin" : wx.FONTWEIGHT_THIN, + "extra-light" : wx.FONTWEIGHT_EXTRALIGHT, + "medium" : wx.FONTWEIGHT_MEDIUM, + "semi-bold" : wx.FONTWEIGHT_SEMIBOLD, + "extra-bold" : wx.FONTWEIGHT_EXTRABOLD, + "heavy" : wx.FONTWEIGHT_HEAVY, + "extra-heavy" : wx.FONTWEIGHT_EXTRAHEAVY, + } + # The next three classes: Renderer, SizeRenderer and DCRenderer are # what you will need to override to extend the XML language. All of