This commit was manufactured by cvs2svn to create tag 'WX_2_8_3'.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/tags/WX_2_8_3@44921 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Bryan Petty
2007-03-19 12:50:38 +00:00
parent 0d3847e80c
commit ddae8107b7
440 changed files with 11219 additions and 10751 deletions

View File

@@ -35,7 +35,13 @@ then these squares should be transparent.
dc.SetBrush(wx.Brush(brushclr))
rect.SetPosition(pos)
dc.DrawRoundedRectangleRect(rect, 8)
# some additional testing stuff
#dc.SetPen(wx.Pen(wx.Colour(0,0,255, 196)))
#dc.SetBrush(wx.Brush(wx.Colour(0,0,255, 64)))
#dc.DrawCircle(50, 275, 25)
#dc.DrawEllipse(100, 275, 75, 50)
#----------------------------------------------------------------------

View File

@@ -25,10 +25,10 @@ class TestPanel(wx.Panel):
ctrl = wx.animate.AnimationCtrl(self, -1, ani)
ctrl.SetUseWindowBackgroundColour()
ctrl.Play()
sizer.Add(ctrl, 0, wx.ALL, 10)
sizer.AddF(ctrl, wx.SizerFlags().Border(wx.ALL, 10))
border = wx.BoxSizer()
border.Add(sizer, 1, wx.EXPAND|wx.ALL, 20)
border.AddF(sizer, wx.SizerFlags(1).Expand().Border(wx.ALL, 20))
self.SetSizer(border)

View File

@@ -764,7 +764,8 @@ class CustomTreeCtrlDemo(wx.Panel):
splitter = wx.SplitterWindow(self, -1, style=wx.CLIP_CHILDREN | wx.SP_LIVE_UPDATE | wx.SP_3D)
# Create the CustomTreeCtrl, using a derived class defined below
self.tree = CustomTreeCtrl(splitter, -1, log=self.log, style=wx.SUNKEN_BORDER)
self.tree = CustomTreeCtrl(splitter, -1, log=self.log,
style= wx.SUNKEN_BORDER| CT.TR_HAS_BUTTONS | CT.TR_HAS_VARIABLE_ROW_HEIGHT)
self.leftpanel = wx.ScrolledWindow(splitter, -1, style=wx.SUNKEN_BORDER)
self.leftpanel.SetScrollRate(20,20)
@@ -1239,11 +1240,10 @@ class CustomTreeCtrl(CT.CustomTreeCtrl):
def __init__(self, parent, id=wx.ID_ANY, pos=wx.DefaultPosition,
size=wx.DefaultSize,
style=wx.SUNKEN_BORDER,
ctstyle=CT.TR_HAS_BUTTONS | CT.TR_HAS_VARIABLE_ROW_HEIGHT,
style=wx.SUNKEN_BORDER | CT.TR_HAS_BUTTONS | CT.TR_HAS_VARIABLE_ROW_HEIGHT,
log=None):
CT.CustomTreeCtrl.__init__(self, parent, id, pos, size, style, ctstyle)
CT.CustomTreeCtrl.__init__(self, parent, id, pos, size, style)
alldata = dir(CT)

View File

@@ -110,8 +110,8 @@ class TestPanel(wx.Panel):
useMetal = self.cb.IsChecked()
dlg = TestDialog(self, -1, "Sample Dialog", size=(350, 200),
#style=wxCAPTION | wxSYSTEM_MENU | wxTHICK_FRAME,
style=wx.DEFAULT_DIALOG_STYLE,
#style=wx.CAPTION | wx.SYSTEM_MENU | wx.THICK_FRAME,
style=wx.DEFAULT_DIALOG_STYLE, # & ~wx.CLOSE_BOX,
useMetal=useMetal,
)
dlg.CenterOnScreen()

View File

@@ -15,7 +15,10 @@ class TestPanel(wx.Panel):
def OnButton(self, evt):
# In this case we include a "New directory" button.
dlg = wx.DirDialog(self, "Choose a directory:",
style=wx.DD_DEFAULT_STYLE|wx.DD_NEW_DIR_BUTTON)
style=wx.DD_DEFAULT_STYLE
#| wx.DD_DIR_MUST_EXIST
#| wx.DD_CHANGE_DIR
)
# If the user selects OK, then we process the dialog's data.
# This is done by getting the path data from the dialog - BEFORE

View File

@@ -58,6 +58,11 @@ class DragCanvas(wx.ScrolledWindow):
shape.fullscreen = True
self.shapes.append(shape)
bmp = images.getTheKidBitmap()
shape = DragShape(bmp)
shape.pos = (200, 5)
self.shapes.append(shape)
# Make a shape from some text
text = "Some Text"
bg_colour = wx.Colour(57, 115, 57) # matches the bg image
@@ -84,11 +89,6 @@ class DragCanvas(wx.ScrolledWindow):
self.shapes.append(shape)
bmp = images.getTheKidBitmap()
shape = DragShape(bmp)
shape.pos = (200, 5)
self.shapes.append(shape)
self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground)
self.Bind(wx.EVT_PAINT, self.OnPaint)
self.Bind(wx.EVT_LEFT_DOWN, self.OnLeftDown)

View File

@@ -91,11 +91,11 @@ class SimpleView(wx.Panel):
#----------------------------------------------------------------------
def runTest(frame, nb, log):
if wx.Platform == "__WXMAC__":
from Main import MessagePanel
win = MessagePanel(nb, 'This demo currently fails on the Mac. The problem is being looked into...',
'Sorry', wx.ICON_WARNING)
return win
## if wx.Platform == "__WXMAC__":
## from Main import MessagePanel
## win = MessagePanel(nb, 'This demo currently fails on the Mac. The problem is being looked into...',
## 'Sorry', wx.ICON_WARNING)
## return win
if 1:
win = gizmos.DynamicSashWindow(nb, -1, style = wx.CLIP_CHILDREN

View File

@@ -19,7 +19,13 @@ class TestPanel(wx.Panel):
def OnPaint(self, evt):
dc = wx.PaintDC(self)
gc = wx.GraphicsContext.Create(dc)
try:
gc = wx.GraphicsContext.Create(dc)
except NotImplementedError:
dc.DrawText("This build of wxPython does not support the wx.GraphicsContext "
"family of classes.",
25, 25)
return
font = wx.SystemSettings.GetFont(wx.SYS_DEFAULT_GUI_FONT)
font.SetWeight(wx.BOLD)
@@ -64,6 +70,13 @@ class TestPanel(wx.Panel):
gc.DrawText("Scale", 0, -BASE2)
gc.Translate(0, 20)
# for testing clipping
#gc.Clip(0, 0, 100, 100)
#rgn = wx.RegionFromPoints([ (0,0), (75,0), (75,25,), (100, 25),
# (100,100), (0,100), (0,0) ])
#gc.ClipRegion(rgn)
#gc.ResetClip()
gc.SetBrush(wx.Brush(wx.Colour(178, 34, 34, 128))) # 128 == half transparent
for cnt in range(8):
gc.Scale(1.08, 1.08) # increase scale by 8%
@@ -75,7 +88,7 @@ class TestPanel(wx.Panel):
gc.PushState() # save it again
gc.Translate(400, 200)
gc.DrawText("Rotate", 0, -BASE2)
gc.Translate(0, 75)
for angle in range(0, 360, 30):
gc.PushState() # save this new current state so we can pop back to

View File

@@ -242,7 +242,8 @@ class TestFrame(wx.Frame):
if __name__ == '__main__':
import sys
app = wx.PySimpleApp()
from wx.lib.mixins.inspect import InspectableApp
app = InspectableApp(False)
frame = TestFrame(None, sys.stdout)
frame.Show(True)
#import wx.py

View File

@@ -177,7 +177,10 @@ class LanguageSelectPanel(wx.Panel):
# create a locale object for this language
self.locale = wx.Locale(lang)
self.locale.AddCatalog('wxpydemo')
if self.locale.IsOk():
self.locale.AddCatalog('wxpydemo')
else:
self.locale = None
def translateExample(self):
self.translatedST.SetLabel(_(self.englishBaseCh.GetStringSelection()))

View File

@@ -70,6 +70,7 @@ _treeList = [
'SearchCtrl',
'SizedControls',
'AUI_MDI',
'TreeMixin',
]),
# managed windows == things with a (optional) caption you can close
@@ -214,6 +215,7 @@ _treeList = [
'Throbber',
'Ticker',
'TimeCtrl',
'TreeMixin',
'VListBox',
]),
@@ -1374,6 +1376,7 @@ class wxPythonDemo(wx.Frame):
#---------------------------------------------
def RecreateTree(self, evt=None):
self.tree.Freeze()
self.tree.DeleteAllItems()
self.root = self.tree.AddRoot("wxPython Overview")
firstChild = None
@@ -1393,6 +1396,7 @@ class wxPythonDemo(wx.Frame):
self.tree.Expand(firstChild)
if filter:
self.tree.ExpandAll()
self.tree.Thaw()
def WriteText(self, text):
if text[-1:] == '\n':
@@ -1685,9 +1689,17 @@ class wxPythonDemo(wx.Frame):
def OnOpenWidgetInspector(self, evt):
# Activate the widget inspector that was mixed in with the
# app, see MyApp and MyApp.OnInit below.
wx.GetApp().ShowInspectionTool()
# Activate the widget inspection tool
from wx.lib.inspection import InspectionTool
if not InspectionTool().initialized:
InspectionTool().Init()
# Find a widget to be selected in the tree. Use either the
# one under the cursor, if any, or this frame.
wnd = wx.FindWindowAtPointer()
if not wnd:
wnd = self
InspectionTool().Show(wnd, True)
#---------------------------------------------
@@ -1789,8 +1801,7 @@ class MySplashScreen(wx.SplashScreen):
self.Raise()
import wx.lib.mixins.inspect
class MyApp(wx.App, wx.lib.mixins.inspect.InspectionMixin):
class MyApp(wx.App):
def OnInit(self):
"""
Create and show the splash screen. It will then create and show
@@ -1811,9 +1822,6 @@ class MyApp(wx.App, wx.lib.mixins.inspect.InspectionMixin):
splash = MySplashScreen()
splash.Show()
# Setup the InspectionMixin
self.Init()
return True

View File

@@ -157,10 +157,8 @@ class MyCanvas(wx.ScrolledWindow):
self.x, self.y = self.ConvertEventCoords(event)
def ConvertEventCoords(self, event):
xView, yView = self.GetViewStart()
xDelta, yDelta = self.GetScrollPixelsPerUnit()
return (event.GetX() + (xView * xDelta),
event.GetY() + (yView * yDelta))
newpos = self.CalcUnscrolledPosition(event.GetX(), event.GetY())
return newpos
def OnLeftButtonEvent(self, event):
if event.LeftDown():
@@ -172,23 +170,34 @@ class MyCanvas(wx.ScrolledWindow):
elif event.Dragging() and self.drawing:
if BUFFERED:
# If doing buffered drawing, create the buffered DC, giving it
# it a real DC to blit to when done.
cdc = wx.ClientDC(self)
self.PrepareDC(cdc)
dc = wx.BufferedDC(cdc, self.buffer)
# If doing buffered drawing we'll just update the
# buffer here and then refresh that portion of the
# window, then that portion of the buffer will be
# redrawn in the EVT_PAINT handler.
dc = wx.BufferedDC(None, self.buffer)
else:
# otherwise we'll draw directly to a wx.ClientDC
dc = wx.ClientDC(self)
self.PrepareDC(dc)
dc.BeginDrawing()
dc.SetPen(wx.Pen('MEDIUM FOREST GREEN', 4))
coords = (self.x, self.y) + self.ConvertEventCoords(event)
self.curLine.append(coords)
dc.DrawLine(*coords)
self.SetXY(event)
dc.EndDrawing()
if BUFFERED:
# figure out what part of the window to refresh
x1,y1, x2,y2 = dc.GetBoundingBox()
x1,y1 = self.CalcScrolledPosition(x1, y1)
x2,y2 = self.CalcScrolledPosition(x2, y2)
# make a rectangle
rect = wx.Rect()
rect.SetTopLeft((x1,y1))
rect.SetBottomRight((x2,y2))
rect.Inflate(2,2)
# refresh it
self.RefreshRect(rect)
elif event.LeftUp() and self.drawing:
self.lines.append(self.curLine)

View File

@@ -41,8 +41,9 @@ class TestPanel(wx.Panel):
self.Bind(wx.EVT_SEARCHCTRL_SEARCH_BTN, self.OnSearch, self.search)
self.Bind(wx.EVT_SEARCHCTRL_CANCEL_BTN, self.OnCancel, self.search)
self.search.Bind(wx.EVT_TEXT_ENTER, self.OnDoSearch, self.search)
self.Bind(wx.EVT_TEXT_ENTER, self.OnDoSearch, self.search)
##self.Bind(wx.EVT_TEXT, self.OnDoSearch, self.search)
def OnToggleSearchButton(self, evt):
self.search.ShowSearchButton( evt.GetInt() )

View File

@@ -310,7 +310,9 @@ def runTest(frame, nb, log):
win = TestPanel(nb, log)
return win
if __name__ == "__main__":
app = wx.PySimpleApp()
dlg = FormDialog()
dlg.ShowModal()
if __name__ == '__main__':
import sys,os
import run
run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])

261
wxPython/demo/TreeMixin.py Normal file
View File

@@ -0,0 +1,261 @@
import wx, wx.lib.customtreectrl, wx.gizmos
import wx.lib.mixins.treemixin as treemixin
class TreeModel(object):
''' TreeModel holds the domain objects that are shown in the different
tree controls. Each domain object is simply a two-tuple consisting of
a label and a list of child tuples, i.e. (label, [list of child tuples]).
'''
def __init__(self, *args, **kwargs):
self.items = []
self.itemCounter = 0
super(TreeModel, self).__init__(*args, **kwargs)
def GetItem(self, indices):
text, children = 'Hidden root', self.items
for index in indices:
text, children = children[index]
return text, children
def GetText(self, indices):
return self.GetItem(indices)[0]
def GetChildren(self, indices):
return self.GetItem(indices)[1]
def GetChildrenCount(self, indices):
return len(self.GetChildren(indices))
def SetChildrenCount(self, indices, count):
children = self.GetChildren(indices)
while len(children) > count:
children.pop()
while len(children) < count:
children.append(('item %d'%self.itemCounter, []))
self.itemCounter += 1
def MoveItem(self, itemToMoveIndices, newParentIndices):
itemToMove = self.GetItem(itemToMoveIndices)
newParentChildren = self.GetChildren(newParentIndices)
newParentChildren.append(itemToMove)
oldParentChildren = self.GetChildren(itemToMoveIndices[:-1])
oldParentChildren.remove(itemToMove)
class DemoTreeMixin(treemixin.VirtualTree, treemixin.DragAndDrop,
treemixin.ExpansionState):
def __init__(self, *args, **kwargs):
self.model = kwargs.pop('treemodel')
self.log = kwargs.pop('log')
super(DemoTreeMixin, self).__init__(*args, **kwargs)
self.CreateImageList()
def CreateImageList(self):
size = (16, 16)
self.imageList = wx.ImageList(*size)
for art in wx.ART_FOLDER, wx.ART_FILE_OPEN, wx.ART_NORMAL_FILE:
self.imageList.Add(wx.ArtProvider.GetBitmap(art, wx.ART_OTHER,
size))
self.AssignImageList(self.imageList)
def OnGetItemText(self, indices):
return self.model.GetText(indices)
def OnGetChildrenCount(self, indices):
return self.model.GetChildrenCount(indices)
def OnGetItemFont(self, indices):
# Show how to change the item font. Here we use a small font for
# items that have children and the default font otherwise.
if self.model.GetChildrenCount(indices) > 0:
return wx.SMALL_FONT
else:
return super(DemoTreeMixin, self).OnGetItemFont(indices)
def OnGetItemTextColour(self, indices):
# Show how to change the item text colour. In this case second level
# items are coloured red and third level items are blue. All other
# items have the default text colour.
if len(indices) % 2 == 0:
return wx.RED
elif len(indices) % 3 == 0:
return wx.BLUE
else:
return super(DemoTreeMixin, self).OnGetItemTextColour(indices)
def OnGetItemBackgroundColour(self, indices):
# Show how to change the item background colour. In this case the
# background colour of each third item is green.
if indices[-1] == 2:
return wx.GREEN
else:
return super(DemoTreeMixin,
self).OnGetItemBackgroundColour(indices)
def OnGetItemImage(self, indices, which):
# Return the right icon depending on whether the item has children.
if which in [wx.TreeItemIcon_Normal, wx.TreeItemIcon_Selected]:
if self.model.GetChildrenCount(indices):
return 0
else:
return 2
else:
return 1
def OnDrop(self, dropTarget, dragItem):
dropIndices = self.ItemIndices(dropTarget)
dropText = self.model.GetText(dropIndices)
dragIndices = self.ItemIndices(dragItem)
dragText = self.model.GetText(dragIndices)
self.log.write('drop %s %s on %s %s'%(dragText, dragIndices,
dropText, dropIndices))
self.model.MoveItem(dragIndices, dropIndices)
self.GetParent().RefreshItems()
class VirtualTreeCtrl(DemoTreeMixin, wx.TreeCtrl):
pass
class VirtualTreeListCtrl(DemoTreeMixin, wx.gizmos.TreeListCtrl):
def __init__(self, *args, **kwargs):
kwargs['style'] = wx.TR_DEFAULT_STYLE | wx.TR_FULL_ROW_HIGHLIGHT
super(VirtualTreeListCtrl, self).__init__(*args, **kwargs)
self.AddColumn('Column 0')
self.AddColumn('Column 1')
for art in wx.ART_TIP, wx.ART_WARNING:
self.imageList.Add(wx.ArtProvider.GetBitmap(art, wx.ART_OTHER,
(16, 16)))
def OnGetItemText(self, indices, column=0):
# Return a different label depending on column.
return '%s, column %d'%\
(super(VirtualTreeListCtrl, self).OnGetItemText(indices), column)
def OnGetItemImage(self, indices, which, column=0):
# Also change the image of the other columns when the item has
# children.
if column == 0:
return super(VirtualTreeListCtrl, self).OnGetItemImage(indices,
which)
elif self.OnGetChildrenCount(indices):
return 4
else:
return 3
class VirtualCustomTreeCtrl(DemoTreeMixin,
wx.lib.customtreectrl.CustomTreeCtrl):
def __init__(self, *args, **kwargs):
self.checked = {}
kwargs['ctstyle'] = wx.TR_DEFAULT_STYLE | wx.TR_HIDE_ROOT | \
wx.TR_HAS_BUTTONS | wx.TR_FULL_ROW_HIGHLIGHT
super(VirtualCustomTreeCtrl, self).__init__(*args, **kwargs)
self.Bind(wx.lib.customtreectrl.EVT_TREE_ITEM_CHECKED,
self.OnItemChecked)
def OnGetItemType(self, indices):
if len(indices) == 1:
return 1
elif len(indices) == 2:
return 2
else:
return 0
def OnGetItemChecked(self, indices):
return self.checked.get(tuple(indices), False)
def OnItemChecked(self, event):
item = event.GetItem()
indices = tuple(self.ItemIndices(item))
if self.GetItemType(item) == 2:
# It's a radio item; reset other items on the same level
for index in range(self.GetChildrenCount(self.GetItemParent(item))):
self.checked[indices[:-1]+(index,)] = False
self.checked[indices] = True
class TreeNotebook(wx.Notebook):
def __init__(self, *args, **kwargs):
treemodel = kwargs.pop('treemodel')
log = kwargs.pop('log')
super(TreeNotebook, self).__init__(*args, **kwargs)
self.trees = []
for class_, title in [(VirtualTreeCtrl, 'TreeCtrl'),
(VirtualTreeListCtrl, 'TreeListCtrl'),
(VirtualCustomTreeCtrl, 'CustomTreeCtrl')]:
tree = class_(self, treemodel=treemodel, log=log)
self.trees.append(tree)
self.AddPage(tree, title)
self.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED, self.OnPageChanged)
def OnPageChanged(self, event):
oldTree = self.GetPage(event.OldSelection)
newTree = self.GetPage(event.Selection)
newTree.SetExpansionState(oldTree.GetExpansionState())
newTree.RefreshItems()
event.Skip()
def GetIndicesOfSelectedItems(self):
tree = self.trees[self.GetSelection()]
if tree.GetSelections():
return [tree.ItemIndices(item) for item in tree.GetSelections()]
else:
return [()]
def RefreshItems(self):
tree = self.trees[self.GetSelection()]
tree.RefreshItems()
tree.UnselectAll()
class TestPanel(wx.Panel):
def __init__(self, parent, log):
self.log = log
super(TestPanel, self).__init__(parent)
self.treemodel = TreeModel()
self.CreateControls()
self.LayoutControls()
def CreateControls(self):
self.notebook = TreeNotebook(self, treemodel=self.treemodel,
log=self.log)
self.label = wx.StaticText(self, label='Number of children: ')
self.childrenCountCtrl = wx.SpinCtrl(self, value='0', max=10000)
self.button = wx.Button(self, label='Update children')
self.button.Bind(wx.EVT_BUTTON, self.OnEnter)
def LayoutControls(self):
hSizer = wx.BoxSizer(wx.HORIZONTAL)
options = dict(flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL, border=2)
hSizer.Add(self.label, **options)
hSizer.Add(self.childrenCountCtrl, 2, **options)
hSizer.Add(self.button, **options)
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(self.notebook, 1, wx.EXPAND)
sizer.Add(hSizer, 0, wx.EXPAND)
self.SetSizer(sizer)
def OnEnter(self, event):
indicesList = self.notebook.GetIndicesOfSelectedItems()
newChildrenCount = self.childrenCountCtrl.GetValue()
for indices in indicesList:
text = self.treemodel.GetText(indices)
oldChildrenCount = self.treemodel.GetChildrenCount(indices)
self.log.write('%s %s now has %d children (was %d)'%(text, indices,
newChildrenCount, oldChildrenCount))
self.treemodel.SetChildrenCount(indices, newChildrenCount)
self.notebook.RefreshItems()
def runTest(frame, nb, log):
win = TestPanel(nb, log)
return win
if __name__ == '__main__':
import sys, os, run
run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])

View File

@@ -18,7 +18,7 @@ on the command line.
"""
import wx
import wx.lib.mixins.inspect
import wx.lib.mixins.inspection
import sys, os
# stuff for debugging
@@ -40,7 +40,7 @@ class Log:
write = WriteText
class RunDemoApp(wx.App, wx.lib.mixins.inspect.InspectionMixin):
class RunDemoApp(wx.App, wx.lib.mixins.inspection.InspectionMixin):
def __init__(self, name, module, useShell):
self.name = name
self.demoModule = module