phoenix-port and unittest for wx.lib.stattext

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxPython/Phoenix/trunk@72064 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2012-07-13 03:17:49 +00:00
parent c93c093b88
commit a3f21f8f92
2 changed files with 34 additions and 10 deletions

View File

@@ -0,0 +1,26 @@
import imp_unittest, unittest
import wtc
import wx
import wx.lib.stattext
#---------------------------------------------------------------------------
class lib_stattext_Tests(wtc.WidgetTestCase):
def test_lib_stattext1(self):
pnl = wx.Panel(self.frame)
w = wx.lib.stattext.GenStaticText(pnl, label="This is a test", pos=(10,10))
bs1 = w.GetEffectiveMinSize()
w.SetLabel("This is a New Label")
w.SetFont(wx.FFont(16, wx.FONTFAMILY_ROMAN))
bs2 = w.GetEffectiveMinSize()
self.assertEqual(w.GetLabel(), "This is a New Label")
self.assertEqual(w.Label, "This is a New Label")
self.assertTrue(bs2.height > bs1.height)
#---------------------------------------------------------------------------
if __name__ == '__main__':
unittest.main()

View File

@@ -7,9 +7,9 @@
# Author: Robin Dunn
#
# Created: 8-July-2002
# RCS-ID: $Id$
# Copyright: (c) 2002 by Total Control Software
# Licence: wxWindows license
# Tags: phoenix-port, unittest
#----------------------------------------------------------------------
# 12/12/2003 - Jeff Grimmett (grimmtooth@softhome.net)
#
@@ -27,17 +27,17 @@ if wx.Platform == "__WXMAC__":
#----------------------------------------------------------------------
class GenStaticText(wx.PyControl):
class GenStaticText(wx.Control):
labelDelta = 1
def __init__(self, parent, ID=-1, label="",
pos=wx.DefaultPosition, size=wx.DefaultSize,
style=0,
name="genstattext"):
wx.PyControl.__init__(self, parent, ID, pos, size, style|wx.NO_BORDER,
wx.Control.__init__(self, parent, ID, pos, size, style|wx.NO_BORDER,
wx.DefaultValidator, name)
wx.PyControl.SetLabel(self, label) # don't check wx.ST_NO_AUTORESIZE yet
wx.Control.SetLabel(self, label) # don't check wx.ST_NO_AUTORESIZE yet
self.InheritAttributes()
self.SetInitialSize(size)
@@ -55,7 +55,7 @@ class GenStaticText(wx.PyControl):
Sets the static text label and updates the control's size to exactly
fit the label unless the control has wx.ST_NO_AUTORESIZE flag.
"""
wx.PyControl.SetLabel(self, label)
wx.Control.SetLabel(self, label)
style = self.GetWindowStyleFlag()
self.InvalidateBestSize()
if not style & wx.ST_NO_AUTORESIZE:
@@ -68,7 +68,7 @@ class GenStaticText(wx.PyControl):
Sets the static text font and updates the control's size to exactly
fit the label unless the control has wx.ST_NO_AUTORESIZE flag.
"""
wx.PyControl.SetFont(self, font)
wx.Control.SetFont(self, font)
style = self.GetWindowStyleFlag()
self.InvalidateBestSize()
if not style & wx.ST_NO_AUTORESIZE:
@@ -103,15 +103,13 @@ class GenStaticText(wx.PyControl):
def Enable(self, enable=True):
"""Overridden Enable() method to properly refresh the widget. """
wx.PyControl.Enable(self, enable)
wx.Control.Enable(self, enable)
self.Refresh()
def Disable(self):
"""Overridden Disable() method to properly refresh the widget. """
wx.PyControl.Disable(self)
wx.Control.Disable(self)
self.Refresh()