Demo tweaks to correct some visual glitches and event order issues
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@26558 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -195,7 +195,10 @@ class MimeTypesDemoPanel(wx.Panel):
|
|||||||
tsizer.Fit(self)
|
tsizer.Fit(self)
|
||||||
|
|
||||||
# Populate the Known MIME types list with what is in the database
|
# Populate the Known MIME types list with what is in the database
|
||||||
mtypes = wx.TheMimeTypesManager.EnumAllFileTypes()
|
try:
|
||||||
|
mtypes = wx.TheMimeTypesManager.EnumAllFileTypes()
|
||||||
|
except wx.PyAssertionError:
|
||||||
|
mtypes = []
|
||||||
for mt in mtypes:
|
for mt in mtypes:
|
||||||
self.mimelist.Append(mt)
|
self.mimelist.Append(mt)
|
||||||
|
|
||||||
|
@@ -13,14 +13,58 @@
|
|||||||
|
|
||||||
import wx
|
import wx
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------
|
||||||
|
|
||||||
|
class SampleWindow(wx.PyWindow):
|
||||||
|
"""
|
||||||
|
A simple window that is used as sizer items in the tests below to
|
||||||
|
show how the various sizers work.
|
||||||
|
"""
|
||||||
|
def __init__(self, parent, text, pos=wx.DefaultPosition, size=wx.DefaultSize):
|
||||||
|
wx.PyWindow.__init__(self, parent, -1,
|
||||||
|
#style=wx.RAISED_BORDER
|
||||||
|
#style=wx.SUNKEN_BORDER
|
||||||
|
style=wx.SIMPLE_BORDER
|
||||||
|
)
|
||||||
|
self.text = text
|
||||||
|
if size != wx.DefaultSize:
|
||||||
|
self.bestsize = size
|
||||||
|
else:
|
||||||
|
self.bestsize = (80,25)
|
||||||
|
self.SetSize(self.GetBestSize())
|
||||||
|
|
||||||
|
self.Bind(wx.EVT_PAINT, self.OnPaint)
|
||||||
|
self.Bind(wx.EVT_SIZE, self.OnSize)
|
||||||
|
self.Bind(wx.EVT_LEFT_UP, self.OnCloseParent)
|
||||||
|
|
||||||
|
|
||||||
|
def OnPaint(self, evt):
|
||||||
|
sz = self.GetSize()
|
||||||
|
dc = wx.PaintDC(self)
|
||||||
|
w,h = dc.GetTextExtent(self.text)
|
||||||
|
dc.Clear()
|
||||||
|
dc.DrawText(self.text, ((sz.width-w)/2, (sz.height-h)/2))
|
||||||
|
|
||||||
|
def OnSize(self, evt):
|
||||||
|
self.Refresh()
|
||||||
|
|
||||||
|
def OnCloseParent(self, evt):
|
||||||
|
p = wx.GetTopLevelParent(self)
|
||||||
|
if p:
|
||||||
|
p.Close()
|
||||||
|
|
||||||
|
def DoGetBestSize(self):
|
||||||
|
return self.bestsize
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
|
|
||||||
def makeSimpleBox1(win):
|
def makeSimpleBox1(win):
|
||||||
box = wx.BoxSizer(wx.HORIZONTAL)
|
box = wx.BoxSizer(wx.HORIZONTAL)
|
||||||
box.Add(wx.Button(win, -1, "one"), 0, wx.EXPAND)
|
box.Add(SampleWindow(win, "one"), 0, wx.EXPAND)
|
||||||
box.Add(wx.Button(win, -1, "two"), 0, wx.EXPAND)
|
box.Add(SampleWindow(win, "two"), 0, wx.EXPAND)
|
||||||
box.Add(wx.Button(win, -1, "three"), 0, wx.EXPAND)
|
box.Add(SampleWindow(win, "three"), 0, wx.EXPAND)
|
||||||
box.Add(wx.Button(win, -1, "four"), 0, wx.EXPAND)
|
box.Add(SampleWindow(win, "four"), 0, wx.EXPAND)
|
||||||
|
|
||||||
return box
|
return box
|
||||||
|
|
||||||
@@ -28,10 +72,10 @@ def makeSimpleBox1(win):
|
|||||||
|
|
||||||
def makeSimpleBox2(win):
|
def makeSimpleBox2(win):
|
||||||
box = wx.BoxSizer(wx.VERTICAL)
|
box = wx.BoxSizer(wx.VERTICAL)
|
||||||
box.Add(wx.Button(win, -1, "one"), 0, wx.EXPAND)
|
box.Add(SampleWindow(win, "one"), 0, wx.EXPAND)
|
||||||
box.Add(wx.Button(win, -1, "two"), 0, wx.EXPAND)
|
box.Add(SampleWindow(win, "two"), 0, wx.EXPAND)
|
||||||
box.Add(wx.Button(win, -1, "three"), 0, wx.EXPAND)
|
box.Add(SampleWindow(win, "three"), 0, wx.EXPAND)
|
||||||
box.Add(wx.Button(win, -1, "four"), 0, wx.EXPAND)
|
box.Add(SampleWindow(win, "four"), 0, wx.EXPAND)
|
||||||
|
|
||||||
return box
|
return box
|
||||||
|
|
||||||
@@ -39,11 +83,11 @@ def makeSimpleBox2(win):
|
|||||||
|
|
||||||
def makeSimpleBox3(win):
|
def makeSimpleBox3(win):
|
||||||
box = wx.BoxSizer(wx.HORIZONTAL)
|
box = wx.BoxSizer(wx.HORIZONTAL)
|
||||||
box.Add(wx.Button(win, -1, "one"), 0, wx.EXPAND)
|
box.Add(SampleWindow(win, "one"), 0, wx.EXPAND)
|
||||||
box.Add(wx.Button(win, -1, "two"), 0, wx.EXPAND)
|
box.Add(SampleWindow(win, "two"), 0, wx.EXPAND)
|
||||||
box.Add(wx.Button(win, -1, "three"), 0, wx.EXPAND)
|
box.Add(SampleWindow(win, "three"), 0, wx.EXPAND)
|
||||||
box.Add(wx.Button(win, -1, "four"), 0, wx.EXPAND)
|
box.Add(SampleWindow(win, "four"), 0, wx.EXPAND)
|
||||||
box.Add(wx.Button(win, -1, "five"), 1, wx.EXPAND)
|
box.Add(SampleWindow(win, "five"), 1, wx.EXPAND)
|
||||||
|
|
||||||
return box
|
return box
|
||||||
|
|
||||||
@@ -51,11 +95,11 @@ def makeSimpleBox3(win):
|
|||||||
|
|
||||||
def makeSimpleBox4(win):
|
def makeSimpleBox4(win):
|
||||||
box = wx.BoxSizer(wx.HORIZONTAL)
|
box = wx.BoxSizer(wx.HORIZONTAL)
|
||||||
box.Add(wx.Button(win, -1, "one"), 0, wx.EXPAND)
|
box.Add(SampleWindow(win, "one"), 0, wx.EXPAND)
|
||||||
box.Add(wx.Button(win, -1, "two"), 0, wx.EXPAND)
|
box.Add(SampleWindow(win, "two"), 0, wx.EXPAND)
|
||||||
box.Add(wx.Button(win, -1, "three"), 1, wx.EXPAND)
|
box.Add(SampleWindow(win, "three"), 1, wx.EXPAND)
|
||||||
box.Add(wx.Button(win, -1, "four"), 1, wx.EXPAND)
|
box.Add(SampleWindow(win, "four"), 1, wx.EXPAND)
|
||||||
box.Add(wx.Button(win, -1, "five"), 1, wx.EXPAND)
|
box.Add(SampleWindow(win, "five"), 1, wx.EXPAND)
|
||||||
|
|
||||||
return box
|
return box
|
||||||
|
|
||||||
@@ -63,11 +107,11 @@ def makeSimpleBox4(win):
|
|||||||
|
|
||||||
def makeSimpleBox5(win):
|
def makeSimpleBox5(win):
|
||||||
box = wx.BoxSizer(wx.HORIZONTAL)
|
box = wx.BoxSizer(wx.HORIZONTAL)
|
||||||
box.Add(wx.Button(win, -1, "one"), 0, wx.EXPAND)
|
box.Add(SampleWindow(win, "one"), 0, wx.EXPAND)
|
||||||
box.Add(wx.Button(win, -1, "two"), 0, wx.EXPAND)
|
box.Add(SampleWindow(win, "two"), 0, wx.EXPAND)
|
||||||
box.Add(wx.Button(win, -1, "three"), 3, wx.EXPAND)
|
box.Add(SampleWindow(win, "three"), 3, wx.EXPAND)
|
||||||
box.Add(wx.Button(win, -1, "four"), 1, wx.EXPAND)
|
box.Add(SampleWindow(win, "four"), 1, wx.EXPAND)
|
||||||
box.Add(wx.Button(win, -1, "five"), 1, wx.EXPAND)
|
box.Add(SampleWindow(win, "five"), 1, wx.EXPAND)
|
||||||
|
|
||||||
return box
|
return box
|
||||||
|
|
||||||
@@ -75,11 +119,11 @@ def makeSimpleBox5(win):
|
|||||||
|
|
||||||
def makeSimpleBox6(win):
|
def makeSimpleBox6(win):
|
||||||
box = wx.BoxSizer(wx.HORIZONTAL)
|
box = wx.BoxSizer(wx.HORIZONTAL)
|
||||||
box.Add(wx.Button(win, -1, "one"), 1, wx.ALIGN_TOP)
|
box.Add(SampleWindow(win, "one"), 1, wx.ALIGN_TOP)
|
||||||
box.Add(wx.Button(win, -1, "two"), 1, wx.EXPAND)
|
box.Add(SampleWindow(win, "two"), 1, wx.EXPAND)
|
||||||
box.Add(wx.Button(win, -1, "three"), 1, wx.ALIGN_CENTER)
|
box.Add(SampleWindow(win, "three"), 1, wx.ALIGN_CENTER)
|
||||||
box.Add(wx.Button(win, -1, "four"), 1, wx.EXPAND)
|
box.Add(SampleWindow(win, "four"), 1, wx.EXPAND)
|
||||||
box.Add(wx.Button(win, -1, "five"), 1, wx.ALIGN_BOTTOM)
|
box.Add(SampleWindow(win, "five"), 1, wx.ALIGN_BOTTOM)
|
||||||
|
|
||||||
return box
|
return box
|
||||||
|
|
||||||
@@ -87,11 +131,11 @@ def makeSimpleBox6(win):
|
|||||||
|
|
||||||
def makeSimpleBox7(win):
|
def makeSimpleBox7(win):
|
||||||
box = wx.BoxSizer(wx.HORIZONTAL)
|
box = wx.BoxSizer(wx.HORIZONTAL)
|
||||||
box.Add(wx.Button(win, 1010, "one"), 0, wx.EXPAND)
|
box.Add(SampleWindow(win, "one"), 0, wx.EXPAND)
|
||||||
box.Add(wx.Button(win, 1010, "two"), 0, wx.EXPAND)
|
box.Add(SampleWindow(win, "two"), 0, wx.EXPAND)
|
||||||
box.Add(wx.Button(win, 1010, "three"), 0, wx.EXPAND)
|
box.Add(SampleWindow(win, "three"), 0, wx.EXPAND)
|
||||||
box.Add((60, 20), 0, wx.EXPAND)
|
box.Add((60, 20), 0, wx.EXPAND)
|
||||||
box.Add(wx.Button(win, 1010, "five"), 1, wx.EXPAND)
|
box.Add(SampleWindow(win, "five"), 1, wx.EXPAND)
|
||||||
|
|
||||||
return box
|
return box
|
||||||
|
|
||||||
@@ -99,13 +143,13 @@ def makeSimpleBox7(win):
|
|||||||
|
|
||||||
def makeSimpleBox8(win):
|
def makeSimpleBox8(win):
|
||||||
box = wx.BoxSizer(wx.VERTICAL)
|
box = wx.BoxSizer(wx.VERTICAL)
|
||||||
box.Add(wx.Button(win, 1010, "one"), 0, wx.EXPAND)
|
box.Add(SampleWindow(win, "one"), 0, wx.EXPAND)
|
||||||
box.Add((0,0), 1)
|
box.Add((0,0), 1)
|
||||||
box.Add(wx.Button(win, 1010, "two"), 0, wx.ALIGN_CENTER)
|
box.Add(SampleWindow(win, "two"), 0, wx.ALIGN_CENTER)
|
||||||
box.Add((0,0), 1)
|
box.Add((0,0), 1)
|
||||||
box.Add(wx.Button(win, 1010, "three"), 0, wx.EXPAND)
|
box.Add(SampleWindow(win, "three"), 0, wx.EXPAND)
|
||||||
box.Add(wx.Button(win, 1010, "four"), 0, wx.EXPAND)
|
box.Add(SampleWindow(win, "four"), 0, wx.EXPAND)
|
||||||
# box.Add(wx.Button(win, 1010, "five"), 1, wx.EXPAND)
|
# box.Add(SampleWindow(win, "five"), 1, wx.EXPAND)
|
||||||
|
|
||||||
return box
|
return box
|
||||||
|
|
||||||
@@ -114,7 +158,7 @@ def makeSimpleBox8(win):
|
|||||||
|
|
||||||
def makeSimpleBorder1(win):
|
def makeSimpleBorder1(win):
|
||||||
bdr = wx.BoxSizer(wx.HORIZONTAL)
|
bdr = wx.BoxSizer(wx.HORIZONTAL)
|
||||||
btn = wx.Button(win, -1, "border")
|
btn = SampleWindow(win, "border")
|
||||||
btn.SetSize((80, 80))
|
btn.SetSize((80, 80))
|
||||||
bdr.Add(btn, 1, wx.EXPAND|wx.ALL, 15)
|
bdr.Add(btn, 1, wx.EXPAND|wx.ALL, 15)
|
||||||
|
|
||||||
@@ -124,7 +168,7 @@ def makeSimpleBorder1(win):
|
|||||||
|
|
||||||
def makeSimpleBorder2(win):
|
def makeSimpleBorder2(win):
|
||||||
bdr = wx.BoxSizer(wx.HORIZONTAL)
|
bdr = wx.BoxSizer(wx.HORIZONTAL)
|
||||||
btn = wx.Button(win, -1, "border")
|
btn = SampleWindow(win, "border")
|
||||||
btn.SetSize((80, 80))
|
btn.SetSize((80, 80))
|
||||||
bdr.Add(btn, 1, wx.EXPAND | wx.EAST | wx.WEST, 15)
|
bdr.Add(btn, 1, wx.EXPAND | wx.EAST | wx.WEST, 15)
|
||||||
|
|
||||||
@@ -134,7 +178,7 @@ def makeSimpleBorder2(win):
|
|||||||
|
|
||||||
def makeSimpleBorder3(win):
|
def makeSimpleBorder3(win):
|
||||||
bdr = wx.BoxSizer(wx.HORIZONTAL)
|
bdr = wx.BoxSizer(wx.HORIZONTAL)
|
||||||
btn = wx.Button(win, -1, "border")
|
btn = SampleWindow(win, "border")
|
||||||
btn.SetSize((80, 80))
|
btn.SetSize((80, 80))
|
||||||
bdr.Add(btn, 1, wx.EXPAND | wx.NORTH | wx.WEST, 15)
|
bdr.Add(btn, 1, wx.EXPAND | wx.NORTH | wx.WEST, 15)
|
||||||
|
|
||||||
@@ -146,26 +190,26 @@ def makeSimpleBorder3(win):
|
|||||||
def makeBoxInBox(win):
|
def makeBoxInBox(win):
|
||||||
box = wx.BoxSizer(wx.VERTICAL)
|
box = wx.BoxSizer(wx.VERTICAL)
|
||||||
|
|
||||||
box.Add(wx.Button(win, -1, "one"), 0, wx.EXPAND)
|
box.Add(SampleWindow(win, "one"), 0, wx.EXPAND)
|
||||||
|
|
||||||
box2 = wx.BoxSizer(wx.HORIZONTAL)
|
box2 = wx.BoxSizer(wx.HORIZONTAL)
|
||||||
box2.Add(wx.Button(win, -1, "two"), 0, wx.EXPAND)
|
box2.Add(SampleWindow(win, "two"), 0, wx.EXPAND)
|
||||||
btn3 = wx.Button(win, -1, "three")
|
btn3 = SampleWindow(win, "three")
|
||||||
box2.Add(btn3, 0, wx.EXPAND)
|
box2.Add(btn3, 0, wx.EXPAND)
|
||||||
box2.Add(wx.Button(win, -1, "four"), 0, wx.EXPAND)
|
box2.Add(SampleWindow(win, "four"), 0, wx.EXPAND)
|
||||||
box2.Add(wx.Button(win, -1, "five"), 0, wx.EXPAND)
|
box2.Add(SampleWindow(win, "five"), 0, wx.EXPAND)
|
||||||
|
|
||||||
box3 = wx.BoxSizer(wx.VERTICAL)
|
box3 = wx.BoxSizer(wx.VERTICAL)
|
||||||
box3.AddMany([ (wx.Button(win, -1, "six"), 0, wx.EXPAND),
|
box3.AddMany([ (SampleWindow(win, "six"), 0, wx.EXPAND),
|
||||||
(wx.Button(win, -1, "seven"), 2, wx.EXPAND),
|
(SampleWindow(win, "seven"), 2, wx.EXPAND),
|
||||||
(wx.Button(win, -1, "eight"), 1, wx.EXPAND),
|
(SampleWindow(win, "eight"), 1, wx.EXPAND),
|
||||||
(wx.Button(win, -1, "nine"), 1, wx.EXPAND),
|
(SampleWindow(win, "nine"), 1, wx.EXPAND),
|
||||||
])
|
])
|
||||||
|
|
||||||
box2.Add(box3, 1, wx.EXPAND)
|
box2.Add(box3, 1, wx.EXPAND)
|
||||||
box.Add(box2, 1, wx.EXPAND)
|
box.Add(box2, 1, wx.EXPAND)
|
||||||
|
|
||||||
box.Add(wx.Button(win, -1, "ten"), 0, wx.EXPAND)
|
box.Add(SampleWindow(win, "ten"), 0, wx.EXPAND)
|
||||||
|
|
||||||
##box.Hide(btn3)
|
##box.Hide(btn3)
|
||||||
|
|
||||||
@@ -186,31 +230,31 @@ def makeBorderInBox(win):
|
|||||||
insideBox = wx.BoxSizer(wx.HORIZONTAL)
|
insideBox = wx.BoxSizer(wx.HORIZONTAL)
|
||||||
|
|
||||||
box2 = wx.BoxSizer(wx.HORIZONTAL)
|
box2 = wx.BoxSizer(wx.HORIZONTAL)
|
||||||
box2.AddMany([ (wx.Button(win, -1, "one"), 0, wx.EXPAND),
|
box2.AddMany([ (SampleWindow(win, "one"), 0, wx.EXPAND),
|
||||||
(wx.Button(win, -1, "two"), 0, wx.EXPAND),
|
(SampleWindow(win, "two"), 0, wx.EXPAND),
|
||||||
(wx.Button(win, -1, "three"), 0, wx.EXPAND),
|
(SampleWindow(win, "three"), 0, wx.EXPAND),
|
||||||
(wx.Button(win, -1, "four"), 0, wx.EXPAND),
|
(SampleWindow(win, "four"), 0, wx.EXPAND),
|
||||||
(wx.Button(win, -1, "five"), 0, wx.EXPAND),
|
(SampleWindow(win, "five"), 0, wx.EXPAND),
|
||||||
])
|
])
|
||||||
|
|
||||||
insideBox.Add(box2, 0, wx.EXPAND)
|
insideBox.Add(box2, 0, wx.EXPAND)
|
||||||
|
|
||||||
bdr = wx.BoxSizer(wx.HORIZONTAL)
|
bdr = wx.BoxSizer(wx.HORIZONTAL)
|
||||||
bdr.Add(wx.Button(win, -1, "border"), 1, wx.EXPAND | wx.ALL)
|
bdr.Add(SampleWindow(win, "border"), 1, wx.EXPAND | wx.ALL)
|
||||||
insideBox.Add(bdr, 1, wx.EXPAND | wx.ALL, 20)
|
insideBox.Add(bdr, 1, wx.EXPAND | wx.ALL, 20)
|
||||||
|
|
||||||
box3 = wx.BoxSizer(wx.VERTICAL)
|
box3 = wx.BoxSizer(wx.VERTICAL)
|
||||||
box3.AddMany([ (wx.Button(win, -1, "six"), 0, wx.EXPAND),
|
box3.AddMany([ (SampleWindow(win, "six"), 0, wx.EXPAND),
|
||||||
(wx.Button(win, -1, "seven"), 2, wx.EXPAND),
|
(SampleWindow(win, "seven"), 2, wx.EXPAND),
|
||||||
(wx.Button(win, -1, "eight"), 1, wx.EXPAND),
|
(SampleWindow(win, "eight"), 1, wx.EXPAND),
|
||||||
(wx.Button(win, -1, "nine"), 1, wx.EXPAND),
|
(SampleWindow(win, "nine"), 1, wx.EXPAND),
|
||||||
])
|
])
|
||||||
insideBox.Add(box3, 1, wx.EXPAND)
|
insideBox.Add(box3, 1, wx.EXPAND)
|
||||||
|
|
||||||
outsideBox = wx.BoxSizer(wx.VERTICAL)
|
outsideBox = wx.BoxSizer(wx.VERTICAL)
|
||||||
outsideBox.Add(wx.Button(win, -1, "top"), 0, wx.EXPAND)
|
outsideBox.Add(SampleWindow(win, "top"), 0, wx.EXPAND)
|
||||||
outsideBox.Add(insideBox, 1, wx.EXPAND)
|
outsideBox.Add(insideBox, 1, wx.EXPAND)
|
||||||
outsideBox.Add(wx.Button(win, -1, "bottom"), 0, wx.EXPAND)
|
outsideBox.Add(SampleWindow(win, "bottom"), 0, wx.EXPAND)
|
||||||
|
|
||||||
return outsideBox
|
return outsideBox
|
||||||
|
|
||||||
@@ -220,16 +264,16 @@ def makeBorderInBox(win):
|
|||||||
def makeGrid1(win):
|
def makeGrid1(win):
|
||||||
gs = wx.GridSizer(3, 3, 2, 2) # rows, cols, hgap, vgap
|
gs = wx.GridSizer(3, 3, 2, 2) # rows, cols, hgap, vgap
|
||||||
|
|
||||||
gs.AddMany([ (wx.Button(win, -1, 'one'), 0, wx.EXPAND),
|
gs.AddMany([ (SampleWindow(win, 'one'), 0, wx.EXPAND),
|
||||||
(wx.Button(win, -1, 'two'), 0, wx.EXPAND),
|
(SampleWindow(win, 'two'), 0, wx.EXPAND),
|
||||||
(wx.Button(win, -1, 'three'), 0, wx.EXPAND),
|
(SampleWindow(win, 'three'), 0, wx.EXPAND),
|
||||||
(wx.Button(win, -1, 'four'), 0, wx.EXPAND),
|
(SampleWindow(win, 'four'), 0, wx.EXPAND),
|
||||||
(wx.Button(win, -1, 'five'), 0, wx.EXPAND),
|
(SampleWindow(win, 'five'), 0, wx.EXPAND),
|
||||||
#(75, 50),
|
#(75, 50),
|
||||||
(wx.Button(win, -1, 'six'), 0, wx.EXPAND),
|
(SampleWindow(win, 'six'), 0, wx.EXPAND),
|
||||||
(wx.Button(win, -1, 'seven'), 0, wx.EXPAND),
|
(SampleWindow(win, 'seven'), 0, wx.EXPAND),
|
||||||
(wx.Button(win, -1, 'eight'), 0, wx.EXPAND),
|
(SampleWindow(win, 'eight'), 0, wx.EXPAND),
|
||||||
(wx.Button(win, -1, 'nine'), 0, wx.EXPAND),
|
(SampleWindow(win, 'nine'), 0, wx.EXPAND),
|
||||||
])
|
])
|
||||||
|
|
||||||
return gs
|
return gs
|
||||||
@@ -240,23 +284,23 @@ def makeGrid2(win):
|
|||||||
gs = wx.GridSizer(3, 3) # rows, cols, hgap, vgap
|
gs = wx.GridSizer(3, 3) # rows, cols, hgap, vgap
|
||||||
|
|
||||||
box = wx.BoxSizer(wx.VERTICAL)
|
box = wx.BoxSizer(wx.VERTICAL)
|
||||||
box.Add(wx.Button(win, -1, 'A'), 0, wx.EXPAND)
|
box.Add(SampleWindow(win, 'A'), 0, wx.EXPAND)
|
||||||
box.Add(wx.Button(win, -1, 'B'), 1, wx.EXPAND)
|
box.Add(SampleWindow(win, 'B'), 1, wx.EXPAND)
|
||||||
|
|
||||||
gs2 = wx.GridSizer(2,2, 4, 4)
|
gs2 = wx.GridSizer(2,2, 4, 4)
|
||||||
gs2.AddMany([ (wx.Button(win, -1, 'C'), 0, wx.EXPAND),
|
gs2.AddMany([ (SampleWindow(win, 'C'), 0, wx.EXPAND),
|
||||||
(wx.Button(win, -1, 'E'), 0, wx.EXPAND),
|
(SampleWindow(win, 'E'), 0, wx.EXPAND),
|
||||||
(wx.Button(win, -1, 'F'), 0, wx.EXPAND),
|
(SampleWindow(win, 'F'), 0, wx.EXPAND),
|
||||||
(wx.Button(win, -1, 'G'), 0, wx.EXPAND)])
|
(SampleWindow(win, 'G'), 0, wx.EXPAND)])
|
||||||
|
|
||||||
gs.AddMany([ (wx.Button(win, -1, 'one'), 0, wx.ALIGN_RIGHT | wx.ALIGN_BOTTOM),
|
gs.AddMany([ (SampleWindow(win, 'one'), 0, wx.ALIGN_RIGHT | wx.ALIGN_BOTTOM),
|
||||||
(wx.Button(win, -1, 'two'), 0, wx.EXPAND),
|
(SampleWindow(win, 'two'), 0, wx.EXPAND),
|
||||||
(wx.Button(win, -1, 'three'), 0, wx.ALIGN_LEFT | wx.ALIGN_BOTTOM),
|
(SampleWindow(win, 'three'), 0, wx.ALIGN_LEFT | wx.ALIGN_BOTTOM),
|
||||||
(wx.Button(win, -1, 'four'), 0, wx.EXPAND),
|
(SampleWindow(win, 'four'), 0, wx.EXPAND),
|
||||||
(wx.Button(win, -1, 'five'), 0, wx.ALIGN_CENTER),
|
(SampleWindow(win, 'five'), 0, wx.ALIGN_CENTER),
|
||||||
(wx.Button(win, -1, 'six'), 0, wx.EXPAND),
|
(SampleWindow(win, 'six'), 0, wx.EXPAND),
|
||||||
(box, 0, wx.EXPAND | wx.ALL, 10),
|
(box, 0, wx.EXPAND | wx.ALL, 10),
|
||||||
(wx.Button(win, -1, 'eight'), 0, wx.EXPAND),
|
(SampleWindow(win, 'eight'), 0, wx.EXPAND),
|
||||||
(gs2, 0, wx.EXPAND | wx.ALL, 4),
|
(gs2, 0, wx.EXPAND | wx.ALL, 4),
|
||||||
])
|
])
|
||||||
|
|
||||||
@@ -267,16 +311,16 @@ def makeGrid2(win):
|
|||||||
def makeGrid3(win):
|
def makeGrid3(win):
|
||||||
gs = wx.FlexGridSizer(3, 3, 2, 2) # rows, cols, hgap, vgap
|
gs = wx.FlexGridSizer(3, 3, 2, 2) # rows, cols, hgap, vgap
|
||||||
|
|
||||||
gs.AddMany([ (wx.Button(win, -1, 'one'), 0, wx.EXPAND),
|
gs.AddMany([ (SampleWindow(win, 'one'), 0, wx.EXPAND),
|
||||||
(wx.Button(win, -1, 'two'), 0, wx.EXPAND),
|
(SampleWindow(win, 'two'), 0, wx.EXPAND),
|
||||||
(wx.Button(win, -1, 'three'), 0, wx.EXPAND),
|
(SampleWindow(win, 'three'), 0, wx.EXPAND),
|
||||||
(wx.Button(win, -1, 'four'), 0, wx.EXPAND),
|
(SampleWindow(win, 'four'), 0, wx.EXPAND),
|
||||||
#(wx.Button(win, 1010, 'five'), 0, wx.EXPAND),
|
#(SampleWindow(win, 'five'), 0, wx.EXPAND),
|
||||||
((175, 50)),
|
((175, 50)),
|
||||||
(wx.Button(win, -1, 'six'), 0, wx.EXPAND),
|
(SampleWindow(win, 'six'), 0, wx.EXPAND),
|
||||||
(wx.Button(win, -1, 'seven'), 0, wx.EXPAND),
|
(SampleWindow(win, 'seven'), 0, wx.EXPAND),
|
||||||
(wx.Button(win, -1, 'eight'), 0, wx.EXPAND),
|
(SampleWindow(win, 'eight'), 0, wx.EXPAND),
|
||||||
(wx.Button(win, -1, 'nine'), 0, wx.EXPAND),
|
(SampleWindow(win, 'nine'), 0, wx.EXPAND),
|
||||||
])
|
])
|
||||||
|
|
||||||
gs.AddGrowableRow(0)
|
gs.AddGrowableRow(0)
|
||||||
@@ -291,23 +335,23 @@ def makeGrid4(win):
|
|||||||
bsize = wx.Size(100, 50)
|
bsize = wx.Size(100, 50)
|
||||||
gs = wx.GridSizer(3, 3, 2, 2) # rows, cols, hgap, vgap
|
gs = wx.GridSizer(3, 3, 2, 2) # rows, cols, hgap, vgap
|
||||||
|
|
||||||
gs.AddMany([ (wx.Button(win, -1, 'one', bpos, bsize),
|
gs.AddMany([ (SampleWindow(win, 'one', bpos, bsize),
|
||||||
0, wx.ALIGN_TOP | wx.ALIGN_LEFT ),
|
0, wx.ALIGN_TOP | wx.ALIGN_LEFT ),
|
||||||
(wx.Button(win, -1, 'two', bpos, bsize),
|
(SampleWindow(win, 'two', bpos, bsize),
|
||||||
0, wx.ALIGN_TOP | wx.ALIGN_CENTER_HORIZONTAL ),
|
0, wx.ALIGN_TOP | wx.ALIGN_CENTER_HORIZONTAL ),
|
||||||
(wx.Button(win, -1, 'three', bpos, bsize),
|
(SampleWindow(win, 'three', bpos, bsize),
|
||||||
0, wx.ALIGN_TOP | wx.ALIGN_RIGHT ),
|
0, wx.ALIGN_TOP | wx.ALIGN_RIGHT ),
|
||||||
(wx.Button(win, -1, 'four', bpos, bsize),
|
(SampleWindow(win, 'four', bpos, bsize),
|
||||||
0, wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_LEFT ),
|
0, wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_LEFT ),
|
||||||
(wx.Button(win, -1, 'five', bpos, bsize),
|
(SampleWindow(win, 'five', bpos, bsize),
|
||||||
0, wx.ALIGN_CENTER ),
|
0, wx.ALIGN_CENTER ),
|
||||||
(wx.Button(win, -1, 'six', bpos, bsize),
|
(SampleWindow(win, 'six', bpos, bsize),
|
||||||
0, wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT ),
|
0, wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT ),
|
||||||
(wx.Button(win, -1, 'seven', bpos, bsize),
|
(SampleWindow(win, 'seven', bpos, bsize),
|
||||||
0, wx.ALIGN_BOTTOM | wx.ALIGN_LEFT ),
|
0, wx.ALIGN_BOTTOM | wx.ALIGN_LEFT ),
|
||||||
(wx.Button(win, -1, 'eight', bpos, bsize),
|
(SampleWindow(win, 'eight', bpos, bsize),
|
||||||
0, wx.ALIGN_BOTTOM | wx.ALIGN_CENTER_HORIZONTAL ),
|
0, wx.ALIGN_BOTTOM | wx.ALIGN_CENTER_HORIZONTAL ),
|
||||||
(wx.Button(win, -1, 'nine', bpos, bsize),
|
(SampleWindow(win, 'nine', bpos, bsize),
|
||||||
0, wx.ALIGN_BOTTOM | wx.ALIGN_RIGHT ),
|
0, wx.ALIGN_BOTTOM | wx.ALIGN_RIGHT ),
|
||||||
])
|
])
|
||||||
|
|
||||||
@@ -320,23 +364,23 @@ def makeShapes(win):
|
|||||||
bsize = wx.Size(100, 50)
|
bsize = wx.Size(100, 50)
|
||||||
gs = wx.GridSizer(3, 3, 2, 2) # rows, cols, hgap, vgap
|
gs = wx.GridSizer(3, 3, 2, 2) # rows, cols, hgap, vgap
|
||||||
|
|
||||||
gs.AddMany([ (wx.Button(win, -1, 'one', bpos, bsize),
|
gs.AddMany([ (SampleWindow(win, 'one', bpos, bsize),
|
||||||
0, wx.SHAPED | wx.ALIGN_TOP | wx.ALIGN_LEFT ),
|
0, wx.SHAPED | wx.ALIGN_TOP | wx.ALIGN_LEFT ),
|
||||||
(wx.Button(win, -1, 'two', bpos, bsize),
|
(SampleWindow(win, 'two', bpos, bsize),
|
||||||
0, wx.SHAPED | wx.ALIGN_TOP | wx.ALIGN_CENTER_HORIZONTAL ),
|
0, wx.SHAPED | wx.ALIGN_TOP | wx.ALIGN_CENTER_HORIZONTAL ),
|
||||||
(wx.Button(win, -1, 'three', bpos, bsize),
|
(SampleWindow(win, 'three', bpos, bsize),
|
||||||
0, wx.SHAPED | wx.ALIGN_TOP | wx.ALIGN_RIGHT ),
|
0, wx.SHAPED | wx.ALIGN_TOP | wx.ALIGN_RIGHT ),
|
||||||
(wx.Button(win, -1, 'four', bpos, bsize),
|
(SampleWindow(win, 'four', bpos, bsize),
|
||||||
0, wx.SHAPED | wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_LEFT ),
|
0, wx.SHAPED | wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_LEFT ),
|
||||||
(wx.Button(win, -1, 'five', bpos, bsize),
|
(SampleWindow(win, 'five', bpos, bsize),
|
||||||
0, wx.SHAPED | wx.ALIGN_CENTER ),
|
0, wx.SHAPED | wx.ALIGN_CENTER ),
|
||||||
(wx.Button(win, -1, 'six', bpos, bsize),
|
(SampleWindow(win, 'six', bpos, bsize),
|
||||||
0, wx.SHAPED | wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT ),
|
0, wx.SHAPED | wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT ),
|
||||||
(wx.Button(win, -1, 'seven', bpos, bsize),
|
(SampleWindow(win, 'seven', bpos, bsize),
|
||||||
0, wx.SHAPED | wx.ALIGN_BOTTOM | wx.ALIGN_LEFT ),
|
0, wx.SHAPED | wx.ALIGN_BOTTOM | wx.ALIGN_LEFT ),
|
||||||
(wx.Button(win, -1, 'eight', bpos, bsize),
|
(SampleWindow(win, 'eight', bpos, bsize),
|
||||||
0, wx.SHAPED | wx.ALIGN_BOTTOM | wx.ALIGN_CENTER_HORIZONTAL ),
|
0, wx.SHAPED | wx.ALIGN_BOTTOM | wx.ALIGN_CENTER_HORIZONTAL ),
|
||||||
(wx.Button(win, -1, 'nine', bpos, bsize),
|
(SampleWindow(win, 'nine', bpos, bsize),
|
||||||
0, wx.SHAPED | wx.ALIGN_BOTTOM | wx.ALIGN_RIGHT ),
|
0, wx.SHAPED | wx.ALIGN_BOTTOM | wx.ALIGN_RIGHT ),
|
||||||
])
|
])
|
||||||
|
|
||||||
@@ -346,11 +390,11 @@ def makeShapes(win):
|
|||||||
|
|
||||||
def makeSimpleBoxShaped(win):
|
def makeSimpleBoxShaped(win):
|
||||||
box = wx.BoxSizer(wx.HORIZONTAL)
|
box = wx.BoxSizer(wx.HORIZONTAL)
|
||||||
box.Add(wx.Button(win, -1, "one"), 0, wx.EXPAND)
|
box.Add(SampleWindow(win, "one"), 0, wx.EXPAND)
|
||||||
box.Add(wx.Button(win, -1, "two"), 0, wx.EXPAND)
|
box.Add(SampleWindow(win, "two"), 0, wx.EXPAND)
|
||||||
box.Add(wx.Button(win, -1, "three"), 0, wx.EXPAND)
|
box.Add(SampleWindow(win, "three"), 0, wx.EXPAND)
|
||||||
box.Add(wx.Button(win, -1, "four"), 0, wx.EXPAND)
|
box.Add(SampleWindow(win, "four"), 0, wx.EXPAND)
|
||||||
box.Add(wx.Button(win, -1, "five"), 1, wx.SHAPED)
|
box.Add(SampleWindow(win, "five"), 1, wx.SHAPED)
|
||||||
|
|
||||||
return box
|
return box
|
||||||
|
|
||||||
@@ -482,7 +526,6 @@ theTests = [
|
|||||||
class TestFrame(wx.Frame):
|
class TestFrame(wx.Frame):
|
||||||
def __init__(self, parent, title, sizerFunc):
|
def __init__(self, parent, title, sizerFunc):
|
||||||
wx.Frame.__init__(self, parent, -1, title)
|
wx.Frame.__init__(self, parent, -1, title)
|
||||||
self.Bind(wx.EVT_BUTTON, self.OnButton)
|
|
||||||
|
|
||||||
p = wx.Panel(self, -1)
|
p = wx.Panel(self, -1)
|
||||||
|
|
||||||
@@ -491,7 +534,6 @@ class TestFrame(wx.Frame):
|
|||||||
self.SetStatusText("Resize this frame to see how the sizers respond...")
|
self.SetStatusText("Resize this frame to see how the sizers respond...")
|
||||||
self.sizer.Fit(p)
|
self.sizer.Fit(p)
|
||||||
|
|
||||||
p.SetAutoLayout(True)
|
|
||||||
p.SetSizer(self.sizer)
|
p.SetSizer(self.sizer)
|
||||||
self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
|
self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
|
||||||
self.Fit()
|
self.Fit()
|
||||||
@@ -500,8 +542,6 @@ class TestFrame(wx.Frame):
|
|||||||
self.MakeModal(False)
|
self.MakeModal(False)
|
||||||
self.Destroy()
|
self.Destroy()
|
||||||
|
|
||||||
def OnButton(self, event):
|
|
||||||
self.Close(True)
|
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
|
|
||||||
|
@@ -38,17 +38,24 @@ class MyCustomPanel(wx.Panel):
|
|||||||
# silly example. It could just as easily have been done in
|
# silly example. It could just as easily have been done in
|
||||||
# the resource. We do it in the EVT_WINDOW_CREATE handler
|
# the resource. We do it in the EVT_WINDOW_CREATE handler
|
||||||
# because the window doesn't really exist yet in the __init__.
|
# because the window doesn't really exist yet in the __init__.
|
||||||
t = wx.StaticText(self, -1, "MyCustomPanel")
|
if self is evt.GetEventObject():
|
||||||
f = t.GetFont()
|
t = wx.StaticText(self, -1, "MyCustomPanel")
|
||||||
f.SetWeight(wx.BOLD)
|
f = t.GetFont()
|
||||||
f.SetPointSize(f.GetPointSize()+2)
|
f.SetWeight(wx.BOLD)
|
||||||
t.SetFont(f)
|
f.SetPointSize(f.GetPointSize()+2)
|
||||||
self.t = t
|
t.SetFont(f)
|
||||||
|
self.t = t
|
||||||
|
# On OSX the EVT_SIZE happens before EVT_WINDOW_CREATE !?!
|
||||||
|
# so give it another kick
|
||||||
|
wx.CallAfter(self.OnSize, None)
|
||||||
|
|
||||||
|
|
||||||
def OnSize(self, evt):
|
def OnSize(self, evt):
|
||||||
sz = self.GetSize()
|
if hasattr(self, 't'):
|
||||||
w, h = self.t.GetTextExtent(self.t.GetLabel())
|
sz = self.GetSize()
|
||||||
self.t.SetPosition(((sz.width-w)/2, (sz.height-h)/2))
|
w, h = self.t.GetTextExtent(self.t.GetLabel())
|
||||||
|
print w, h
|
||||||
|
self.t.SetPosition(((sz.width-w)/2, (sz.height-h)/2))
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
|
|
||||||
@@ -73,7 +80,9 @@ class TestPanel(wx.Panel):
|
|||||||
res.LoadFromString(resourceText)
|
res.LoadFromString(resourceText)
|
||||||
|
|
||||||
# Now create a panel from the resource data
|
# Now create a panel from the resource data
|
||||||
panel = res.LoadPanel(self, "MyPanel")
|
#panel = res.LoadPanel(self, "MyPanel")
|
||||||
|
panel = MyCustomPanel()
|
||||||
|
panel.Create(self, -1)
|
||||||
|
|
||||||
# and do the layout
|
# and do the layout
|
||||||
sizer = wx.BoxSizer(wx.VERTICAL)
|
sizer = wx.BoxSizer(wx.VERTICAL)
|
||||||
|
Reference in New Issue
Block a user