]> git.saurik.com Git - wxWidgets.git/commitdiff
testing tweaks
authorRobin Dunn <robin@alldunn.com>
Thu, 24 Jun 2004 20:25:53 +0000 (20:25 +0000)
committerRobin Dunn <robin@alldunn.com>
Thu, 24 Jun 2004 20:25:53 +0000 (20:25 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@28013 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

wxPython/misc/notebooktest.py [new file with mode: 0644]
wxPython/misc/widgetLayoutTest.cfg
wxPython/misc/widgetLayoutTest.py

diff --git a/wxPython/misc/notebooktest.py b/wxPython/misc/notebooktest.py
new file mode 100644 (file)
index 0000000..00ee349
--- /dev/null
@@ -0,0 +1,58 @@
+
+import wx
+
+
+class TestNotebook(wx.Notebook):
+    def __init__(self, parent, ID=-1):
+        wx.Notebook.__init__(self, parent, ID)
+
+        # page 1
+        # just a panel with a small fixed size
+        p = wx.Panel(self, size=(50,50))
+        self.AddPage(p, "page 1")
+
+        # page 2
+        # a medium sized panel with manually layed out controls
+        p = wx.Panel(self)
+        b = wx.Button(p, -1, "a button", (20,20))
+        b = wx.Button(p, -1, "another button", (80,80))
+        b = wx.Button(p, -1, "and yet another button", (140,140))
+        b.Bind(wx.EVT_BUTTON, self.ShowBestSizes)
+        self.AddPage(p, "page 2")
+
+        # page 3
+        # a larger panel with lots of controls in a sizer.
+        text = "one two buckle my shoe three four shut the door "\
+               "five six pick up sticks seven eight lay them straight "\
+               "nine ten big fat hen"
+        p = wx.Panel(self)
+        fgs = wx.FlexGridSizer(cols=4, vgap=5, hgap=5)
+        for word in text.split():
+            label = wx.StaticText(p, -1, word+":")
+            tc = wx.TextCtrl(p, -1, "", size=(120,-1))
+            fgs.Add(label, flag=wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.LEFT, border=10)
+            fgs.Add(tc, flag=wx.RIGHT, border=10)
+        box = wx.BoxSizer()
+        box.Add(fgs, 1, wx.EXPAND|wx.ALL, 10)
+        p.SetSizer(box)
+        self.AddPage(p, "page 3")
+
+
+    # show the best size of each page
+    def ShowBestSizes(self, evt):
+        for num in range(self.GetPageCount()):
+            page = self.GetPage(num)
+            print page.GetBestSize()
+            
+
+if __name__ == '__main__':
+    app = wx.PySimpleApp()
+    f = wx.Frame(None, -1, "Notebook Test")
+    nb = TestNotebook(f)
+    s = wx.BoxSizer()
+    s.Add(nb)           # notebook is added directly to the sizer
+    f.SetSizer(s)
+    s.Fit(f)            # sizer calculates layout to set frame size
+    f.Show()
+    app.MainLoop()
+
index f5b42bb32066e6e9e26f8c2518725f05dd716dcc..dc0d613f58082b1b02e2e80fde92bd6511b27661 100644 (file)
@@ -3,6 +3,7 @@
 ['wx', 'Button', '-1, "normal"', ''],
 ['wx', 'Button', '-1, "with a longer, longer label"', ''],
 ['wx', 'Button', '-1, "default"', 'w.SetDefault()'],
+['wx', 'Button', '-1, "larger font"', 'w.SetFont(wx.Font(20, wx.SWISS, wx.NORMAL, wx.NORMAL))\n\n\n'],
 ['wx', 'CheckBox', '-1, "checkbox"', ''],
 ['wx', 'CheckBox', '-1, "checkbox with longer label"', ''],
 ['wx', 'CheckListBox', '-1, size=(100,-1), choices="one two three four five six seven eight".split()', ''],
@@ -51,5 +52,4 @@
 ['wx.calendar', 'CalendarCtrl', '-1', ''],
 ['wx.calendar', 'CalendarCtrl', '-1, style=wx.calendar.CAL_SEQUENTIAL_MONTH_SELECTION', ''],
 ['wx.lib.stattext', 'GenStaticText', '-1, "New font"', 'f = wx.Font(18, wx.SWISS, wx.NORMAL, wx.BOLD)\nw.SetFont(f)\n'],
-['wx', 'Button', '-1, "larger font"', 'w.SetFont(wx.Font(20, wx.SWISS, wx.NORMAL, wx.NORMAL))\n##w.SetMinSize(wx.DefaultSize)\n'],
 ]
index 7a4fada0a7b57f76b9bb9537e2437318072dab7a..3bc942752aaffad209ca90452cf91d341800107b 100644 (file)
@@ -49,7 +49,7 @@ class LayoutTestFrame(wx.Frame):
         self.destroyBtn = destroyBtn
 
         bottomPanel = wx.Panel(p, style=wx.SUNKEN_BORDER, name="bottomPanel")
-        bottomPanel.SetSizeHints((640,240))
+        bottomPanel.SetMinSize((640,240))
         bottomPanel.SetDefaultBackgroundColour("light blue")
 
         self.testPanel = wx.Panel(bottomPanel, name="testPanel")
@@ -338,10 +338,10 @@ class LayoutTestFrame(wx.Frame):
         self.testPanel.SetSizer(None, True)
         self.testPanel.Refresh()
 
-        # ensure the panel shrinks again
-        self.testPanel.SetSizeHints((20,20))
+        # ensure the panel shrinks again now that it has no sizer
+        self.testPanel.SetMinSize((20,20))
         self.bottomSizer.Layout()
-        self.testPanel.SetSizeHints(wx.DefaultSize)
+        self.testPanel.SetMinSize(wx.DefaultSize)
 
         # make the create button be default now
         self.createBtn.SetDefault()
@@ -409,6 +409,7 @@ class SizeInfoPane(wx.Panel):
         self._minsize     = wx.TextCtrl(self, -1, "", style=wx.TE_READONLY)
         self._bestsize    = wx.TextCtrl(self, -1, "", style=wx.TE_READONLY)
         self._adjbstsize  = wx.TextCtrl(self, -1, "", style=wx.TE_READONLY)
+        self._bestfit     = wx.TextCtrl(self, -1, "", style=wx.TE_READONLY)
 
         # setup the layout
         fgs = wx.FlexGridSizer(2, 2, 5, 5)
@@ -430,6 +431,10 @@ class SizeInfoPane(wx.Panel):
                 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL)
         fgs.Add(self._adjbstsize, 0, wx.EXPAND)
 
+        fgs.Add(wx.StaticText(self, -1, "BestFittingSize:"),
+                0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL)
+        fgs.Add(self._bestfit, 0, wx.EXPAND)
+
         sbs = wx.StaticBoxSizer(sb, wx.VERTICAL)
         sbs.Add(fgs, 0, wx.EXPAND|wx.ALL, 4)
 
@@ -441,13 +446,14 @@ class SizeInfoPane(wx.Panel):
         self._minsize.SetValue(    str(win.GetMinSize()) )
         self._bestsize.SetValue(   str(win.GetBestSize()) )
         self._adjbstsize.SetValue( str(win.GetAdjustedBestSize()) )
-        
+        self._bestfit.SetValue(    str(win.GetBestFittingSize()) )
 
     def Clear(self):
         self._size.SetValue("")
         self._minsize.SetValue("")
         self._bestsize.SetValue("")
         self._adjbstsize.SetValue("")
+        self._bestfit.SetValue("")