Added a generic StaticBitmap class in wx.lib.statbmp for the same
reasons that stattext was created, so it could be mouse sensitive on all platforms like normal windows. Also updated stattext.py and buttons.py to handle attribute (font & colour) defaults and inheritance the new way. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@27278 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -10,6 +10,7 @@ class TestPanel(wx.Panel):
|
|||||||
def __init__(self, parent, log):
|
def __init__(self, parent, log):
|
||||||
wx.Panel.__init__(self, parent, -1)
|
wx.Panel.__init__(self, parent, -1)
|
||||||
self.log = log
|
self.log = log
|
||||||
|
##self.SetBackgroundColour("sky blue")
|
||||||
|
|
||||||
sizer = wx.FlexGridSizer(1, 3, 20, 20)
|
sizer = wx.FlexGridSizer(1, 3, 20, 20)
|
||||||
|
|
||||||
@@ -43,6 +44,7 @@ class TestPanel(wx.Panel):
|
|||||||
b.SetFont(wx.Font(20, wx.SWISS, wx.NORMAL, wx.BOLD, False))
|
b.SetFont(wx.Font(20, wx.SWISS, wx.NORMAL, wx.BOLD, False))
|
||||||
b.SetBezelWidth(5)
|
b.SetBezelWidth(5)
|
||||||
###b.SetBestSize()
|
###b.SetBestSize()
|
||||||
|
b.SetSizeHints(wx.DefaultSize)
|
||||||
b.SetBackgroundColour("Navy")
|
b.SetBackgroundColour("Navy")
|
||||||
b.SetForegroundColour(wx.WHITE)
|
b.SetForegroundColour(wx.WHITE)
|
||||||
b.SetToolTipString("This is a BIG button...")
|
b.SetToolTipString("This is a BIG button...")
|
||||||
|
@@ -2,25 +2,36 @@
|
|||||||
import wx
|
import wx
|
||||||
import images
|
import images
|
||||||
|
|
||||||
|
|
||||||
|
USE_GENERIC = 0
|
||||||
|
|
||||||
|
if USE_GENERIC:
|
||||||
|
from wx.lib.stattext import GenStaticText as StaticText
|
||||||
|
from wx.lib.statbmp import GenStaticBitmap as StaticBitmap
|
||||||
|
else:
|
||||||
|
StaticText = wx.StaticText
|
||||||
|
StaticBitmap = wx.StaticBitmap
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
|
|
||||||
class TestPanel(wx.Panel):
|
class TestPanel(wx.Panel):
|
||||||
def __init__(self, parent, log):
|
def __init__(self, parent, log):
|
||||||
wx.Panel.__init__(self, parent, -1)
|
wx.Panel.__init__(self, parent, -1)
|
||||||
self.log = log
|
self.log = log
|
||||||
self.count = 0
|
##self.SetBackgroundColour("sky blue")
|
||||||
|
|
||||||
wx.StaticText(self, -1, "This is a wx.StaticBitmap.", (45, 15))
|
StaticText(self, -1, "This is a wx.StaticBitmap.", (45, 15))
|
||||||
|
|
||||||
bmp = images.getTest2Bitmap()
|
bmp = images.getTest2Bitmap()
|
||||||
mask = wx.Mask(bmp, wx.BLUE)
|
mask = wx.Mask(bmp, wx.BLUE)
|
||||||
bmp.SetMask(mask)
|
bmp.SetMask(mask)
|
||||||
wx.StaticBitmap(self, -1, bmp, (80, 50), (bmp.GetWidth(), bmp.GetHeight()))
|
StaticBitmap(self, -1, bmp, (80, 50), (bmp.GetWidth(), bmp.GetHeight()))
|
||||||
|
|
||||||
bmp = images.getRobinBitmap()
|
bmp = images.getRobinBitmap()
|
||||||
wx.StaticBitmap(self, -1, bmp, (80, 150))
|
StaticBitmap(self, -1, bmp, (80, 150))
|
||||||
|
|
||||||
wx.StaticText(self, -1, "Hey, if Ousterhout can do it, so can I.", (200, 175))
|
StaticText(self, -1, "Hey, if Ousterhout can do it, so can I.", (200, 175))
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
|
@@ -3,6 +3,7 @@ import wx
|
|||||||
|
|
||||||
|
|
||||||
USE_GENERIC = 0
|
USE_GENERIC = 0
|
||||||
|
|
||||||
if USE_GENERIC:
|
if USE_GENERIC:
|
||||||
from wx.lib.stattext import GenStaticText as StaticText
|
from wx.lib.stattext import GenStaticText as StaticText
|
||||||
else:
|
else:
|
||||||
@@ -14,30 +15,35 @@ else:
|
|||||||
class TestPanel(wx.Panel):
|
class TestPanel(wx.Panel):
|
||||||
def __init__(self, parent):
|
def __init__(self, parent):
|
||||||
wx.Panel.__init__(self, parent, -1)
|
wx.Panel.__init__(self, parent, -1)
|
||||||
|
##self.SetBackgroundColour("sky blue")
|
||||||
|
|
||||||
StaticText(self, -1, "This is an example of static text", (20, 10))
|
StaticText(self, -1, "This is an example of static text", (20, 10))
|
||||||
StaticText(self, -1, "using the wx.StaticText Control.", (20, 30))
|
StaticText(self, -1, "using the wx.StaticText Control.", (20, 30))
|
||||||
|
|
||||||
StaticText(
|
StaticText(
|
||||||
self, -1, "Is this yellow?", (20, 70), (90, -1)
|
self, -1, "Is this yellow?", (20, 70), (120, -1)
|
||||||
).SetBackgroundColour('Yellow')
|
).SetBackgroundColour('Yellow')
|
||||||
|
|
||||||
StaticText(
|
StaticText(
|
||||||
self, -1, "align center", (120, 70), (90, -1), wx.ALIGN_CENTER
|
self, -1, "align center", (160, 70), (120, -1), wx.ALIGN_CENTER
|
||||||
).SetBackgroundColour('Yellow')
|
).SetBackgroundColour('Yellow')
|
||||||
|
|
||||||
StaticText(
|
StaticText(
|
||||||
self, -1, "align right", (220, 70), (90, -1), wx.ALIGN_RIGHT
|
self, -1, "align right", (300, 70), (120, -1), wx.ALIGN_RIGHT
|
||||||
).SetBackgroundColour('Yellow')
|
).SetBackgroundColour('Yellow')
|
||||||
|
|
||||||
str = "This is a different font."
|
str = "This is a different font."
|
||||||
text = StaticText(self, -1, str, (20, 100))
|
text = StaticText(self, -1, str, (20, 120))
|
||||||
font = wx.Font(18, wx.SWISS, wx.NORMAL, wx.NORMAL)
|
font = wx.Font(18, wx.SWISS, wx.NORMAL, wx.NORMAL)
|
||||||
text.SetFont(font)
|
text.SetFont(font)
|
||||||
text.SetSize(text.GetBestSize())
|
text.SetSize(text.GetBestSize())
|
||||||
|
|
||||||
StaticText(self, -1, "Multi-line wx.StaticText\nline 2\nline 3\n\nafter empty line", (20,150))
|
StaticText(self, -1,
|
||||||
StaticText(self, -1, "Align right multi-line\nline 2\nline 3\n\nafter empty line", (220,150), style=wx.ALIGN_RIGHT)
|
"Multi-line wx.StaticText\nline 2\nline 3\n\nafter empty line",
|
||||||
|
(20,170))
|
||||||
|
StaticText(self, -1,
|
||||||
|
"Align right multi-line\nline 2\nline 3\n\nafter empty line",
|
||||||
|
(220,170), style=wx.ALIGN_RIGHT)
|
||||||
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
|
@@ -34,6 +34,13 @@ Deprecated the wx.iewin module.
|
|||||||
Deprecated the wx.Sizer.AddWindow, AddSizer, AddSpacer methods as well
|
Deprecated the wx.Sizer.AddWindow, AddSizer, AddSpacer methods as well
|
||||||
as their Insert* and Prepend* counterparts.
|
as their Insert* and Prepend* counterparts.
|
||||||
|
|
||||||
|
Added a generic StaticBitmap class in wx.lib.statbmp for the same
|
||||||
|
reasons that stattext was created, so it could be mouse sensitive on
|
||||||
|
all platforms like normal windows. Also updated stattext.py and
|
||||||
|
buttons.py to handle attribute (font & colour) defaults and
|
||||||
|
inheritance the new way. If you have custom controls of your own you
|
||||||
|
should review stattxt.py or one of the others to see how it is to be
|
||||||
|
done.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@@ -76,11 +76,7 @@ class GenButton(wx.PyControl):
|
|||||||
self.useFocusInd = True
|
self.useFocusInd = True
|
||||||
|
|
||||||
self.SetLabel(label)
|
self.SetLabel(label)
|
||||||
self.SetPosition(pos)
|
self.InheritAttributes()
|
||||||
font = parent.GetFont()
|
|
||||||
if not font.Ok():
|
|
||||||
font = wx.SystemSettings.GetSystemFont(wx.SYS_DEFAULT_GUI_FONT)
|
|
||||||
self.SetFont(font)
|
|
||||||
self.SetBestSize(size)
|
self.SetBestSize(size)
|
||||||
self.InitColours()
|
self.InitColours()
|
||||||
|
|
||||||
@@ -103,23 +99,15 @@ class GenButton(wx.PyControl):
|
|||||||
and set a good size.
|
and set a good size.
|
||||||
"""
|
"""
|
||||||
if size is None:
|
if size is None:
|
||||||
size = wx.Size(-1,-1)
|
size = wx.DefaultSize
|
||||||
if type(size) == type(()):
|
wx.PyControl.SetBestSize(self, size)
|
||||||
size = wx.Size(size[0], size[1])
|
|
||||||
size = wx.Size(size.width, size.height) # make a copy
|
|
||||||
|
|
||||||
best = self.GetBestSize()
|
|
||||||
if size.width == -1:
|
|
||||||
size.width = best.width
|
|
||||||
if size.height == -1:
|
|
||||||
size.height = best.height
|
|
||||||
|
|
||||||
self.SetSize(size)
|
|
||||||
|
|
||||||
|
|
||||||
def DoGetBestSize(self):
|
def DoGetBestSize(self):
|
||||||
"""Overridden base class virtual. Determines the best size of the
|
"""
|
||||||
button based on the label and bezel size."""
|
Overridden base class virtual. Determines the best size of the
|
||||||
|
button based on the label and bezel size.
|
||||||
|
"""
|
||||||
w, h, useMin = self._GetLabelSize()
|
w, h, useMin = self._GetLabelSize()
|
||||||
defSize = wx.Button.GetDefaultSize()
|
defSize = wx.Button.GetDefaultSize()
|
||||||
width = 12 + w
|
width = 12 + w
|
||||||
@@ -138,6 +126,22 @@ class GenButton(wx.PyControl):
|
|||||||
return self.IsShown() and self.IsEnabled()
|
return self.IsShown() and self.IsEnabled()
|
||||||
|
|
||||||
|
|
||||||
|
def GetDefaultAttributes(self):
|
||||||
|
"""
|
||||||
|
Overridden base class virtual. By default we should use
|
||||||
|
the same font/colour attributes as the native Button.
|
||||||
|
"""
|
||||||
|
return wx.Button.GetClassDefaultAttributes()
|
||||||
|
|
||||||
|
|
||||||
|
def ShouldInheritColours(self):
|
||||||
|
"""
|
||||||
|
Overridden base class virtual. Buttons usually don't inherit
|
||||||
|
the parent's colours.
|
||||||
|
"""
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
def Enable(self, enable=True):
|
def Enable(self, enable=True):
|
||||||
wx.PyControl.Enable(self, enable)
|
wx.PyControl.Enable(self, enable)
|
||||||
self.Refresh()
|
self.Refresh()
|
||||||
@@ -161,32 +165,12 @@ class GenButton(wx.PyControl):
|
|||||||
|
|
||||||
|
|
||||||
def InitColours(self):
|
def InitColours(self):
|
||||||
faceClr = wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNFACE)
|
"""
|
||||||
textClr = wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNTEXT)
|
Calculate a new set of highlight and shadow colours based on
|
||||||
self.faceDnClr = faceClr
|
the background colour. Works okay if the colour is dark...
|
||||||
self.SetBackgroundColour(faceClr)
|
"""
|
||||||
self.SetForegroundColour(textClr)
|
faceClr = self.GetBackgroundColour()
|
||||||
|
r, g, b = faceClr.Get()
|
||||||
shadowClr = wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNSHADOW)
|
|
||||||
highlightClr = wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNHIGHLIGHT)
|
|
||||||
self.shadowPen = wx.Pen(shadowClr, 1, wx.SOLID)
|
|
||||||
self.highlightPen = wx.Pen(highlightClr, 1, wx.SOLID)
|
|
||||||
if wx.Platform == "__WXMAC__":
|
|
||||||
self.focusIndPen = wx.Pen(textClr, 1, wx.SOLID)
|
|
||||||
else:
|
|
||||||
self.focusIndPen = wx.Pen(textClr, 1, wx.USER_DASH)
|
|
||||||
self.focusIndPen.SetDashes([1,1])
|
|
||||||
self.focusIndPen.SetCap(wx.CAP_BUTT)
|
|
||||||
self.focusClr = highlightClr
|
|
||||||
|
|
||||||
|
|
||||||
def SetBackgroundColour(self, colour):
|
|
||||||
wx.PyControl.SetBackgroundColour(self, colour)
|
|
||||||
colour = self.GetBackgroundColour()
|
|
||||||
|
|
||||||
# Calculate a new set of highlight and shadow colours based on
|
|
||||||
# the new background colour. Works okay if the colour is dark...
|
|
||||||
r, g, b = colour.Get()
|
|
||||||
fr, fg, fb = min(255,r+32), min(255,g+32), min(255,b+32)
|
fr, fg, fb = min(255,r+32), min(255,g+32), min(255,b+32)
|
||||||
self.faceDnClr = wx.Colour(fr, fg, fb)
|
self.faceDnClr = wx.Colour(fr, fg, fb)
|
||||||
sr, sg, sb = max(0,r-32), max(0,g-32), max(0,b-32)
|
sr, sg, sb = max(0,r-32), max(0,g-32), max(0,b-32)
|
||||||
@@ -195,6 +179,24 @@ class GenButton(wx.PyControl):
|
|||||||
self.highlightPen = wx.Pen(wx.Colour(hr,hg,hb), 1, wx.SOLID)
|
self.highlightPen = wx.Pen(wx.Colour(hr,hg,hb), 1, wx.SOLID)
|
||||||
self.focusClr = wx.Colour(hr, hg, hb)
|
self.focusClr = wx.Colour(hr, hg, hb)
|
||||||
|
|
||||||
|
textClr = self.GetForegroundColour()
|
||||||
|
if wx.Platform == "__WXMAC__":
|
||||||
|
self.focusIndPen = wx.Pen(textClr, 1, wx.SOLID)
|
||||||
|
else:
|
||||||
|
self.focusIndPen = wx.Pen(textClr, 1, wx.USER_DASH)
|
||||||
|
self.focusIndPen.SetDashes([1,1])
|
||||||
|
self.focusIndPen.SetCap(wx.CAP_BUTT)
|
||||||
|
|
||||||
|
|
||||||
|
def SetBackgroundColour(self, colour):
|
||||||
|
wx.PyControl.SetBackgroundColour(self, colour)
|
||||||
|
self.InitColours()
|
||||||
|
|
||||||
|
|
||||||
|
def SetForegroundColour(self, colour):
|
||||||
|
wx.PyControl.SetForegroundColour(self, colour)
|
||||||
|
self.InitColours()
|
||||||
|
|
||||||
|
|
||||||
def _GetLabelSize(self):
|
def _GetLabelSize(self):
|
||||||
""" used internally """
|
""" used internally """
|
||||||
@@ -245,11 +247,6 @@ class GenButton(wx.PyControl):
|
|||||||
|
|
||||||
def DrawFocusIndicator(self, dc, w, h):
|
def DrawFocusIndicator(self, dc, w, h):
|
||||||
bw = self.bezelWidth
|
bw = self.bezelWidth
|
||||||
## if self.hasFocus:
|
|
||||||
## self.focusIndPen.SetColour(self.GetForegroundColour())
|
|
||||||
## else:
|
|
||||||
## #self.focusIndPen.SetColour(self.GetBackgroundColour())
|
|
||||||
## self.focusIndPen.SetColour(self.GetForegroundColour())
|
|
||||||
self.focusIndPen.SetColour(self.focusClr)
|
self.focusIndPen.SetColour(self.focusClr)
|
||||||
dc.SetLogicalFunction(wx.INVERT)
|
dc.SetLogicalFunction(wx.INVERT)
|
||||||
dc.SetPen(self.focusIndPen)
|
dc.SetPen(self.focusIndPen)
|
||||||
|
86
wxPython/wx/lib/statbmp.py
Normal file
86
wxPython/wx/lib/statbmp.py
Normal file
@@ -0,0 +1,86 @@
|
|||||||
|
#----------------------------------------------------------------------
|
||||||
|
# Name: wx.lib.statbmp
|
||||||
|
# Purpose: A generic StaticBitmap class.
|
||||||
|
#
|
||||||
|
# Author: Robin Dunn
|
||||||
|
#
|
||||||
|
# Created: 12-May-2004
|
||||||
|
# RCS-ID: $Id$
|
||||||
|
# Copyright: (c) 2004 by Total Control Software
|
||||||
|
# Licence: wxWindows license
|
||||||
|
#----------------------------------------------------------------------
|
||||||
|
|
||||||
|
import wx
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------
|
||||||
|
|
||||||
|
class GenStaticBitmap(wx.PyControl):
|
||||||
|
labelDelta = 1
|
||||||
|
|
||||||
|
def __init__(self, parent, ID, bitmap,
|
||||||
|
pos = wx.DefaultPosition, size = wx.DefaultSize,
|
||||||
|
style = 0,
|
||||||
|
name = "genstatbmp"):
|
||||||
|
wx.PyControl.__init__(self, parent, ID, pos, size, style|wx.NO_BORDER,
|
||||||
|
wx.DefaultValidator, name)
|
||||||
|
self._bitmap = bitmap
|
||||||
|
self.InheritAttributes()
|
||||||
|
self.SetBestSize(size)
|
||||||
|
|
||||||
|
self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground)
|
||||||
|
self.Bind(wx.EVT_PAINT, self.OnPaint)
|
||||||
|
|
||||||
|
|
||||||
|
def SetBitmap(self, bitmap):
|
||||||
|
self._bitmap = bitmap
|
||||||
|
self.SetBestSize( (bitmap.GetWidth(), bitmap.GetHeight()) )
|
||||||
|
self.Refresh()
|
||||||
|
|
||||||
|
|
||||||
|
def GetBitmap(self):
|
||||||
|
return self._bitmap
|
||||||
|
|
||||||
|
|
||||||
|
def DoGetBestSize(self):
|
||||||
|
"""
|
||||||
|
Overridden base class virtual. Determines the best size of the
|
||||||
|
control based on the bitmap size.
|
||||||
|
"""
|
||||||
|
return wx.Size(self._bitmap.GetWidth(), self._bitmap.GetHeight())
|
||||||
|
|
||||||
|
|
||||||
|
def AcceptsFocus(self):
|
||||||
|
"""Overridden base class virtual."""
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
def GetDefaultAttributes(self):
|
||||||
|
"""
|
||||||
|
Overridden base class virtual. By default we should use
|
||||||
|
the same font/colour attributes as the native StaticBitmap.
|
||||||
|
"""
|
||||||
|
return wx.StaticBitmap.GetClassDefaultAttributes()
|
||||||
|
|
||||||
|
|
||||||
|
def ShouldInheritColours(self):
|
||||||
|
"""
|
||||||
|
Overridden base class virtual. If the parent has non-default
|
||||||
|
colours then we want this control to inherit them.
|
||||||
|
"""
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
def OnPaint(self, event):
|
||||||
|
dc = wx.PaintDC(self)
|
||||||
|
dc.DrawBitmap(self._bitmap, 0, 0, True)
|
||||||
|
|
||||||
|
|
||||||
|
def OnEraseBackground(self, event):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
@@ -32,27 +32,9 @@ class GenStaticText(wx.PyControl):
|
|||||||
wx.DefaultValidator, name)
|
wx.DefaultValidator, name)
|
||||||
|
|
||||||
wx.PyControl.SetLabel(self, label) # don't check wx.ST_NO_AUTORESIZE yet
|
wx.PyControl.SetLabel(self, label) # don't check wx.ST_NO_AUTORESIZE yet
|
||||||
self.SetPosition(pos)
|
self.defBackClr = self.GetBackgroundColour()
|
||||||
font = parent.GetFont()
|
self.InheritAttributes()
|
||||||
if not font.Ok():
|
self.SetBestSize(size)
|
||||||
font = wx.SystemSettings.GetFont(wx.SYS_DEFAULT_GUI_FONT)
|
|
||||||
wx.PyControl.SetFont(self, font) # same here
|
|
||||||
|
|
||||||
self.defBackClr = parent.GetBackgroundColour()
|
|
||||||
if not self.defBackClr.Ok():
|
|
||||||
self.defBackClr = wx.SystemSettings.GetColour(wx.SYS_COLOUR_3DFACE)
|
|
||||||
self.SetBackgroundColour(self.defBackClr)
|
|
||||||
|
|
||||||
clr = parent.GetForegroundColour()
|
|
||||||
if not clr.Ok():
|
|
||||||
clr = wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNTEXT)
|
|
||||||
self.SetForegroundColour(clr)
|
|
||||||
|
|
||||||
rw, rh = size
|
|
||||||
bw, bh = self.GetBestSize()
|
|
||||||
if rw == -1: rw = bw
|
|
||||||
if rh == -1: rh = bh
|
|
||||||
self.SetSize(wx.Size(rw, rh))
|
|
||||||
|
|
||||||
self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground)
|
self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground)
|
||||||
self.Bind(wx.EVT_PAINT, self.OnPaint)
|
self.Bind(wx.EVT_PAINT, self.OnPaint)
|
||||||
@@ -66,7 +48,9 @@ class GenStaticText(wx.PyControl):
|
|||||||
wx.PyControl.SetLabel(self, label)
|
wx.PyControl.SetLabel(self, label)
|
||||||
style = self.GetWindowStyleFlag()
|
style = self.GetWindowStyleFlag()
|
||||||
if not style & wx.ST_NO_AUTORESIZE:
|
if not style & wx.ST_NO_AUTORESIZE:
|
||||||
self.SetSize(self.GetBestSize())
|
best = self.GetBestSize()
|
||||||
|
self.SetSize(best)
|
||||||
|
self.SetSizeHints(best)
|
||||||
self.Refresh()
|
self.Refresh()
|
||||||
|
|
||||||
|
|
||||||
@@ -78,13 +62,17 @@ class GenStaticText(wx.PyControl):
|
|||||||
wx.PyControl.SetFont(self, font)
|
wx.PyControl.SetFont(self, font)
|
||||||
style = self.GetWindowStyleFlag()
|
style = self.GetWindowStyleFlag()
|
||||||
if not style & wx.ST_NO_AUTORESIZE:
|
if not style & wx.ST_NO_AUTORESIZE:
|
||||||
self.SetSize(self.GetBestSize())
|
best = self.GetBestSize()
|
||||||
|
self.SetSize(best)
|
||||||
|
self.SetSizeHints(best)
|
||||||
self.Refresh()
|
self.Refresh()
|
||||||
|
|
||||||
|
|
||||||
def DoGetBestSize(self):
|
def DoGetBestSize(self):
|
||||||
"""Overridden base class virtual. Determines the best size of the
|
"""
|
||||||
button based on the label size."""
|
Overridden base class virtual. Determines the best size of
|
||||||
|
the button based on the label size.
|
||||||
|
"""
|
||||||
label = self.GetLabel()
|
label = self.GetLabel()
|
||||||
maxWidth = totalHeight = 0
|
maxWidth = totalHeight = 0
|
||||||
for line in label.split('\n'):
|
for line in label.split('\n'):
|
||||||
@@ -102,6 +90,22 @@ class GenStaticText(wx.PyControl):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
def GetDefaultAttributes(self):
|
||||||
|
"""
|
||||||
|
Overridden base class virtual. By default we should use
|
||||||
|
the same font/colour attributes as the native StaticText.
|
||||||
|
"""
|
||||||
|
return wx.StaticText.GetClassDefaultAttributes()
|
||||||
|
|
||||||
|
|
||||||
|
def ShouldInheritColours(self):
|
||||||
|
"""
|
||||||
|
Overridden base class virtual. If the parent has non-default
|
||||||
|
colours then we want this control to inherit them.
|
||||||
|
"""
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
def OnPaint(self, event):
|
def OnPaint(self, event):
|
||||||
dc = wx.BufferedPaintDC(self)
|
dc = wx.BufferedPaintDC(self)
|
||||||
#dc = wx.PaintDC(self)
|
#dc = wx.PaintDC(self)
|
||||||
|
Reference in New Issue
Block a user