1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
|
import unittest
from unittests import wtc
import wx
#---------------------------------------------------------------------------
class statusbar_Tests(wtc.WidgetTestCase):
def test_statusbarFlags(self):
wx.STB_SIZEGRIP
wx.STB_SHOW_TIPS
wx.STB_ELLIPSIZE_START
wx.STB_ELLIPSIZE_MIDDLE
wx.STB_ELLIPSIZE_END
wx.STB_DEFAULT_STYLE
wx.SB_NORMAL
wx.SB_FLAT
wx.SB_RAISED
def test_statusbarCtor(self):
sb = wx.StatusBar(self.frame)
def test_statusbarDefaultCtor(self):
sb = wx.StatusBar()
sb.Create(self.frame)
def test_statusbarFrameUse1(self):
sb = self.frame.CreateStatusBar(number=2)
self.assertTrue(isinstance(sb, wx.StatusBar))
self.assertTrue(self.frame.GetStatusBar() is sb)
sb.SetStatusText('hello', 0)
sb.SetStatusText('world', 1)
def test_statusbarFrameUse2(self):
sb = wx.StatusBar(self.frame)
self.frame.SetStatusBar(sb)
self.assertTrue(self.frame.GetStatusBar() is sb)
def test_statusbarFrameUse3(self):
class MyFrame(wx.Frame):
def __init__(self, *args, **kw):
wx.Frame.__init__(self, *args, **kw)
self.sbCreated = False
def OnCreateStatusBar(self, num, style, id, name):
sb = wx.StatusBar(self, id, style, name)
sb.SetFieldsCount(num)
self.sbCreated = True
return sb
frm = MyFrame(self.frame)
frm.CreateStatusBar()
self.assertTrue(frm.sbCreated)
frm.Show()
def test_statusbarStatusBarPane(self):
sb = self.frame.CreateStatusBar(number=2)
pane = sb.GetField(0)
self.assertTrue(isinstance(pane, wx.StatusBarPane))
pane.Width
pane.Style
pane.Text
def test_statusbarWidths1(self):
sb = wx.StatusBar(self.frame)
sb.SetFieldsCount(3)
sb.SetStatusWidths([200, -1, 100])
self.frame.SetStatusBar(sb)
self.frame.SendSizeEvent()
self.myYield()
widths = [sb.GetStatusWidth(i) for i in range(sb.GetFieldsCount())]
self.assertEqual(widths, [200, -1, 100])
def test_statusbarWidths2(self):
sb = self.frame.CreateStatusBar(3)
self.frame.SetStatusWidths([200, -1, 100])
self.frame.SendSizeEvent()
self.myYield()
widths = [sb.GetStatusWidth(i) for i in range(sb.GetFieldsCount())]
self.assertEqual(widths, [200, -1, 100])
def test_statusbarWidths3(self):
sb = wx.StatusBar(self.frame)
sb.SetFieldsCount(3, [200, -1, 100])
self.frame.SetStatusBar(sb)
self.frame.SendSizeEvent()
self.myYield()
widths = [sb.GetStatusWidth(i) for i in range(sb.GetFieldsCount())]
self.assertEqual(widths, [200, -1, 100])
def test_statusbarGetFielRect(self):
# Test that GetFieldRect has been tweaked to be compatible with Classic
sb = self.frame.CreateStatusBar(3)
self.frame.SetStatusWidths([200, -1, 100])
r = sb.GetFieldRect(1)
self.assertTrue(isinstance(r, wx.Rect))
def test_statusbarStyles(self):
sb = wx.StatusBar(self.frame)
sb.SetFieldsCount(4)
styles = [wx.SB_NORMAL, wx.SB_FLAT, wx.SB_RAISED, wx.SB_SUNKEN]
sb.SetStatusStyles(styles)
self.frame.SetStatusBar(sb)
self.frame.SendSizeEvent()
self.myYield()
current = [sb.GetStatusStyle(i) for i in range(sb.GetFieldsCount())]
self.assertEqual(current, styles)
#---------------------------------------------------------------------------
if __name__ == '__main__':
unittest.main()
|