This commit was manufactured by cvs2svn to create tag 'WX_2_8_4-rc2'.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/tags/WX_2_8_4-rc2@45760 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -58,6 +58,7 @@ MENU_DISABLE_TAB = wx.NewId()
|
||||
MENU_ENABLE_DRAG_N_DROP = wx.NewId()
|
||||
MENU_DCLICK_CLOSES_TAB = wx.NewId()
|
||||
MENU_USE_VC8_STYLE = wx.NewId()
|
||||
MENU_USE_FF2_STYLE = wx.NewId()
|
||||
MENU_HIDE_ON_SINGLE_TAB = wx.NewId()
|
||||
|
||||
MENU_SET_ACTIVE_TEXT_COLOR = wx.NewId()
|
||||
@@ -179,6 +180,10 @@ class FlatNotebookDemo(wx.Frame):
|
||||
self.Bind(wx.EVT_MENU, self.OnFancyStyle, item)
|
||||
styleMenu.AppendItem(item)
|
||||
|
||||
item = wx.MenuItem(styleMenu, MENU_USE_FF2_STYLE, "Use Firefox 2 Style", "Use Firefox 2 Style", wx.ITEM_RADIO)
|
||||
self.Bind(wx.EVT_MENU, self.OnFF2Style, item)
|
||||
styleMenu.AppendItem(item)
|
||||
|
||||
self._visualMenu.AppendMenu(wx.ID_ANY, "Tabs Style", styleMenu)
|
||||
|
||||
item = wx.MenuItem(self._visualMenu, MENU_SELECT_GRADIENT_COLOR_FROM, "Select fancy tab style 'from' color",
|
||||
@@ -443,12 +448,25 @@ class FlatNotebookDemo(wx.Frame):
|
||||
self._bShowImages = event.IsChecked()
|
||||
|
||||
|
||||
def OnFF2Style(self, event):
|
||||
|
||||
style = self.book.GetWindowStyleFlag()
|
||||
|
||||
# remove old tabs style
|
||||
mirror = ~(fnb.FNB_VC71 | fnb.FNB_VC8 | fnb.FNB_FANCY_TABS | fnb.FNB_FF2)
|
||||
style &= mirror
|
||||
|
||||
style |= fnb.FNB_FF2
|
||||
|
||||
self.book.SetWindowStyleFlag(style)
|
||||
|
||||
|
||||
def OnVC71Style(self, event):
|
||||
|
||||
style = self.book.GetWindowStyleFlag()
|
||||
|
||||
# remove old tabs style
|
||||
mirror = ~(fnb.FNB_VC71 | fnb.FNB_VC8 | fnb.FNB_FANCY_TABS)
|
||||
mirror = ~(fnb.FNB_VC71 | fnb.FNB_VC8 | fnb.FNB_FANCY_TABS | fnb.FNB_FF2)
|
||||
style &= mirror
|
||||
|
||||
style |= fnb.FNB_VC71
|
||||
@@ -461,7 +479,7 @@ class FlatNotebookDemo(wx.Frame):
|
||||
style = self.book.GetWindowStyleFlag()
|
||||
|
||||
# remove old tabs style
|
||||
mirror = ~(fnb.FNB_VC71 | fnb.FNB_VC8 | fnb.FNB_FANCY_TABS)
|
||||
mirror = ~(fnb.FNB_VC71 | fnb.FNB_VC8 | fnb.FNB_FANCY_TABS | fnb.FNB_FF2)
|
||||
style &= mirror
|
||||
|
||||
# set new style
|
||||
@@ -475,7 +493,7 @@ class FlatNotebookDemo(wx.Frame):
|
||||
style = self.book.GetWindowStyleFlag()
|
||||
|
||||
# remove old tabs style
|
||||
mirror = ~(fnb.FNB_VC71 | fnb.FNB_VC8 | fnb.FNB_FANCY_TABS)
|
||||
mirror = ~(fnb.FNB_VC71 | fnb.FNB_VC8 | fnb.FNB_FANCY_TABS | fnb.FNB_FF2)
|
||||
style &= mirror
|
||||
|
||||
self.book.SetWindowStyleFlag(style)
|
||||
@@ -486,7 +504,7 @@ class FlatNotebookDemo(wx.Frame):
|
||||
style = self.book.GetWindowStyleFlag()
|
||||
|
||||
# remove old tabs style
|
||||
mirror = ~(fnb.FNB_VC71 | fnb.FNB_VC8 | fnb.FNB_FANCY_TABS)
|
||||
mirror = ~(fnb.FNB_VC71 | fnb.FNB_VC8 | fnb.FNB_FANCY_TABS | fnb.FNB_FF2)
|
||||
style &= mirror
|
||||
|
||||
style |= fnb.FNB_FANCY_TABS
|
||||
|
||||
@@ -1,27 +1,18 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
|
||||
#print "running:", wx.__version__
|
||||
##First, make sure Numeric or numarray can be imported.
|
||||
try:
|
||||
import Numeric
|
||||
import RandomArray
|
||||
haveNumeric = True
|
||||
import numpy as N
|
||||
import numpy.random as RandomArray
|
||||
haveNumpy = True
|
||||
#print "Using numpy, version:", N.__version__
|
||||
except ImportError:
|
||||
# Numeric isn't there, let's try numarray
|
||||
try:
|
||||
import numarray as Numeric
|
||||
import numarray.random_array as RandomArray
|
||||
haveNumeric = True
|
||||
except ImportError:
|
||||
# numarray isn't there either
|
||||
haveNumeric = False
|
||||
errorText = (
|
||||
"The FloatCanvas requires either the Numeric or numarray module\n\n"
|
||||
"You can get them at:\n"
|
||||
"http://sourceforge.net/projects/numpy\n\n"
|
||||
"NOTE: The Numeric module is substantially faster than numarray for this\n"
|
||||
"purpose, if you have lots of objects\n"
|
||||
)
|
||||
# numpy isn't there
|
||||
haveNumpy = False
|
||||
errorText = (
|
||||
"The FloatCanvas requires the numpy module, version 1.* \n\n"
|
||||
"You can get info about it at:\n"
|
||||
"http://numpy.scipy.org/\n\n"
|
||||
)
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
@@ -100,7 +91,10 @@ def BuildDrawFrame(): # this gets called when needed, rather than on import
|
||||
item = draw_menu.Append(-1, "&Arrows","Run a test of Arrows")
|
||||
self.Bind(wx.EVT_MENU, self.ArrowTest, item)
|
||||
|
||||
item = draw_menu.Append(-1, "&Hide","Run a test of the Show() Hide() Show() and methods")
|
||||
item = draw_menu.Append(-1, "&ArrowLine Test","Run a test of drawing Arrow Lines")
|
||||
self.Bind(wx.EVT_MENU, self.ArrowLineTest, item)
|
||||
|
||||
item = draw_menu.Append(-1, "&Hide","Run a test of hiding and showing objects")
|
||||
self.Bind(wx.EVT_MENU, self.HideTest, item)
|
||||
|
||||
MenuBar.Append(draw_menu, "&Tests")
|
||||
@@ -122,9 +116,11 @@ def BuildDrawFrame(): # this gets called when needed, rather than on import
|
||||
|
||||
|
||||
# Add the Canvas
|
||||
self.Canvas = NavCanvas.NavCanvas(self,
|
||||
Debug = 0,
|
||||
BackgroundColor = "DARK SLATE BLUE")
|
||||
NC = NavCanvas.NavCanvas(self,
|
||||
Debug = 0,
|
||||
BackgroundColor = "DARK SLATE BLUE")
|
||||
|
||||
self.Canvas = NC.Canvas # reference the contained FloatCanvas
|
||||
|
||||
self.MsgWindow = wx.TextCtrl(self, wx.ID_ANY,
|
||||
"Look Here for output from events\n",
|
||||
@@ -135,13 +131,14 @@ def BuildDrawFrame(): # this gets called when needed, rather than on import
|
||||
|
||||
##Create a sizer to manage the Canvas and message window
|
||||
MainSizer = wx.BoxSizer(wx.VERTICAL)
|
||||
MainSizer.Add(self.Canvas, 4, wx.EXPAND)
|
||||
MainSizer.Add(NC, 4, wx.EXPAND)
|
||||
MainSizer.Add(self.MsgWindow, 1, wx.EXPAND | wx.ALL, 5)
|
||||
|
||||
self.SetSizer(MainSizer)
|
||||
wx.EVT_CLOSE(self, self.OnCloseWindow)
|
||||
self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
|
||||
|
||||
FloatCanvas.EVT_MOTION(self.Canvas, self.OnMove )
|
||||
self.Canvas.Bind(FloatCanvas.EVT_MOTION, self.OnMove)
|
||||
self.Canvas.Bind(FloatCanvas.EVT_MOUSEWHEEL, self.OnWheel)
|
||||
|
||||
self.EventsAreBound = False
|
||||
|
||||
@@ -161,56 +158,39 @@ def BuildDrawFrame(): # this gets called when needed, rather than on import
|
||||
def BindAllMouseEvents(self):
|
||||
if not self.EventsAreBound:
|
||||
## Here is how you catch FloatCanvas mouse events
|
||||
FloatCanvas.EVT_LEFT_DOWN(self.Canvas, self.OnLeftDown )
|
||||
FloatCanvas.EVT_LEFT_UP(self.Canvas, self.OnLeftUp )
|
||||
FloatCanvas.EVT_LEFT_DCLICK(self.Canvas, self.OnLeftDouble )
|
||||
self.Canvas.Bind(FloatCanvas.EVT_LEFT_DOWN, self.OnLeftDown)
|
||||
self.Canvas.Bind(FloatCanvas.EVT_LEFT_UP, self.OnLeftUp)
|
||||
self.Canvas.Bind(FloatCanvas.EVT_LEFT_DCLICK, self.OnLeftDouble)
|
||||
|
||||
FloatCanvas.EVT_MIDDLE_DOWN(self.Canvas, self.OnMiddleDown )
|
||||
FloatCanvas.EVT_MIDDLE_UP(self.Canvas, self.OnMiddleUp )
|
||||
FloatCanvas.EVT_MIDDLE_DCLICK(self.Canvas, self.OnMiddleDouble )
|
||||
self.Canvas.Bind(FloatCanvas.EVT_MIDDLE_DOWN, self.OnMiddleDown)
|
||||
self.Canvas.Bind(FloatCanvas.EVT_MIDDLE_UP, self.OnMiddleUp)
|
||||
self.Canvas.Bind(FloatCanvas.EVT_MIDDLE_DCLICK, self.OnMiddleDouble)
|
||||
|
||||
FloatCanvas.EVT_RIGHT_DOWN(self.Canvas, self.OnRightDown )
|
||||
FloatCanvas.EVT_RIGHT_UP(self.Canvas, self.OnRightUp )
|
||||
FloatCanvas.EVT_RIGHT_DCLICK(self.Canvas, self.OnRightDouble )
|
||||
self.Canvas.Bind(FloatCanvas.EVT_RIGHT_DOWN, self.OnRightDown)
|
||||
self.Canvas.Bind(FloatCanvas.EVT_RIGHT_UP, self.OnRightUp)
|
||||
self.Canvas.Bind(FloatCanvas.EVT_RIGHT_DCLICK, self.OnRightDouble)
|
||||
|
||||
FloatCanvas.EVT_MOUSEWHEEL(self.Canvas, self.OnWheel )
|
||||
self.EventsAreBound = True
|
||||
|
||||
|
||||
def UnBindAllMouseEvents(self):
|
||||
## Here is how you unbind FloatCanvas mouse events
|
||||
FloatCanvas.EVT_LEFT_DOWN(self.Canvas, None )
|
||||
FloatCanvas.EVT_LEFT_UP(self.Canvas, None )
|
||||
FloatCanvas.EVT_LEFT_DCLICK(self.Canvas, None)
|
||||
self.Canvas.Unbind(FloatCanvas.EVT_LEFT_DOWN)
|
||||
self.Canvas.Unbind(FloatCanvas.EVT_LEFT_UP)
|
||||
self.Canvas.Unbind(FloatCanvas.EVT_LEFT_DCLICK)
|
||||
|
||||
FloatCanvas.EVT_MIDDLE_DOWN(self.Canvas, None )
|
||||
FloatCanvas.EVT_MIDDLE_UP(self.Canvas, None )
|
||||
FloatCanvas.EVT_MIDDLE_DCLICK(self.Canvas, None )
|
||||
self.Canvas.Unbind(FloatCanvas.EVT_MIDDLE_DOWN)
|
||||
self.Canvas.Unbind(FloatCanvas.EVT_MIDDLE_UP)
|
||||
self.Canvas.Unbind(FloatCanvas.EVT_MIDDLE_DCLICK)
|
||||
|
||||
FloatCanvas.EVT_RIGHT_DOWN(self.Canvas, None )
|
||||
FloatCanvas.EVT_RIGHT_UP(self.Canvas, None )
|
||||
FloatCanvas.EVT_RIGHT_DCLICK(self.Canvas, None )
|
||||
|
||||
FloatCanvas.EVT_MOUSEWHEEL(self.Canvas, None )
|
||||
FloatCanvas.EVT_LEFT_DOWN(self.Canvas, None )
|
||||
FloatCanvas.EVT_LEFT_UP(self.Canvas, None )
|
||||
FloatCanvas.EVT_LEFT_DCLICK(self.Canvas, None)
|
||||
|
||||
FloatCanvas.EVT_MIDDLE_DOWN(self.Canvas, None )
|
||||
FloatCanvas.EVT_MIDDLE_UP(self.Canvas, None )
|
||||
FloatCanvas.EVT_MIDDLE_DCLICK(self.Canvas, None )
|
||||
|
||||
FloatCanvas.EVT_RIGHT_DOWN(self.Canvas, None )
|
||||
FloatCanvas.EVT_RIGHT_UP(self.Canvas, None )
|
||||
FloatCanvas.EVT_RIGHT_DCLICK(self.Canvas, None )
|
||||
|
||||
FloatCanvas.EVT_MOUSEWHEEL(self.Canvas, None )
|
||||
self.Canvas.Unbind(FloatCanvas.EVT_RIGHT_DOWN)
|
||||
self.Canvas.Unbind(FloatCanvas.EVT_RIGHT_UP)
|
||||
self.Canvas.Unbind(FloatCanvas.EVT_RIGHT_DCLICK)
|
||||
|
||||
self.EventsAreBound = False
|
||||
|
||||
|
||||
def PrintCoords(self,event):
|
||||
#print "coords are: %s"%(event.Coords,)
|
||||
#print "pixel coords are: %s\n"%(event.GetPosition(),)
|
||||
self.Log("coords are: %s"%(event.Coords,))
|
||||
self.Log("pixel coords are: %s\n"%(event.GetPosition(),))
|
||||
|
||||
@@ -256,7 +236,7 @@ def BuildDrawFrame(): # this gets called when needed, rather than on import
|
||||
self.PrintCoords(event)
|
||||
|
||||
def OnRightUp(self, event):
|
||||
self.Log("RightDown")
|
||||
self.Log("RightUp")
|
||||
self.PrintCoords(event)
|
||||
|
||||
def OnRightDouble(self, event):
|
||||
@@ -278,6 +258,7 @@ def BuildDrawFrame(): # this gets called when needed, rather than on import
|
||||
Updates the status bar with the world coordinates
|
||||
"""
|
||||
self.SetStatusText("%.2f, %.2f"%tuple(event.Coords))
|
||||
event.Skip()
|
||||
|
||||
def OnAbout(self, event):
|
||||
dlg = wx.MessageDialog(self,
|
||||
@@ -293,8 +274,7 @@ def BuildDrawFrame(): # this gets called when needed, rather than on import
|
||||
|
||||
def Clear(self,event = None):
|
||||
self.UnBindAllMouseEvents()
|
||||
self.Canvas.ClearAll()
|
||||
self.Canvas.SetProjectionFun(None)
|
||||
self.Canvas.InitAll()
|
||||
self.Canvas.Draw()
|
||||
|
||||
def OnQuit(self,event):
|
||||
@@ -304,7 +284,12 @@ def BuildDrawFrame(): # this gets called when needed, rather than on import
|
||||
self.Destroy()
|
||||
|
||||
def DrawTest(self,event=None):
|
||||
wx.GetApp().Yield()
|
||||
"""
|
||||
This demo draws a few of everything
|
||||
|
||||
"""
|
||||
|
||||
wx.GetApp().Yield(True)
|
||||
|
||||
Range = (-10,10)
|
||||
colors = self.colors
|
||||
@@ -312,8 +297,12 @@ def BuildDrawFrame(): # this gets called when needed, rather than on import
|
||||
self.BindAllMouseEvents()
|
||||
Canvas = self.Canvas
|
||||
|
||||
Canvas.ClearAll()
|
||||
Canvas.SetProjectionFun(None)
|
||||
Canvas.InitAll()
|
||||
#
|
||||
## these set the limits for how much you can zoom in and out
|
||||
Canvas.MinScale = 14
|
||||
Canvas.MaxScale = 500
|
||||
|
||||
|
||||
############# Random tests of everything ##############
|
||||
|
||||
@@ -417,6 +406,18 @@ def BuildDrawFrame(): # this gets called when needed, rather than on import
|
||||
LineColor = colors[random.randint(0,len(colors)-1)],
|
||||
ArrowHeadAngle = random.uniform(20,90))
|
||||
|
||||
# ArrowLines
|
||||
for i in range(5):
|
||||
points = []
|
||||
for j in range(random.randint(2,10)):
|
||||
point = (random.randint(Range[0],Range[1]),random.randint(Range[0],Range[1]))
|
||||
points.append(point)
|
||||
lw = random.randint(1,10)
|
||||
cf = random.randint(0,len(colors)-1)
|
||||
cl = random.randint(0,len(colors)-1)
|
||||
Canvas.AddArrowLine(points, LineWidth = lw, LineColor = colors[cl], ArrowHeadSize= 16)
|
||||
|
||||
|
||||
Canvas.ZoomToBB()
|
||||
|
||||
def TestAnimation(self,event=None):
|
||||
@@ -429,15 +430,13 @@ def BuildDrawFrame(): # this gets called when needed, rather than on import
|
||||
having to re-draw the whole background.
|
||||
|
||||
"""
|
||||
wx.GetApp().Yield()
|
||||
wx.GetApp().Yield(True)
|
||||
Range = (-10,10)
|
||||
self.Range = Range
|
||||
|
||||
self.UnBindAllMouseEvents()
|
||||
Canvas = self.Canvas
|
||||
|
||||
Canvas.ClearAll()
|
||||
Canvas.SetProjectionFun(None)
|
||||
Canvas.InitAll()
|
||||
|
||||
## Random tests of everything:
|
||||
colors = self.colors
|
||||
@@ -543,14 +542,13 @@ def BuildDrawFrame(): # this gets called when needed, rather than on import
|
||||
self.Timer.Start(self.FrameDelay)
|
||||
#print "Did %i frames in %f seconds"%(N, (time.time() - start) )
|
||||
|
||||
def TestHitTest(self,event=None):
|
||||
wx.GetApp().Yield()
|
||||
def TestHitTest(self, event=None):
|
||||
wx.GetApp().Yield(True)
|
||||
|
||||
self.UnBindAllMouseEvents()
|
||||
Canvas = self.Canvas
|
||||
|
||||
Canvas.ClearAll()
|
||||
Canvas.SetProjectionFun(None)
|
||||
Canvas.InitAll()
|
||||
|
||||
#Add a Hit-able rectangle
|
||||
w, h = 60, 20
|
||||
@@ -558,7 +556,7 @@ def BuildDrawFrame(): # this gets called when needed, rather than on import
|
||||
dx = 80
|
||||
dy = 40
|
||||
x, y = 20, 20
|
||||
FontSize = 8
|
||||
FontSize = 10
|
||||
|
||||
#Add one that is not HitAble
|
||||
Canvas.AddRectangle((x,y), (w, h), LineWidth = 2)
|
||||
@@ -709,7 +707,7 @@ def BuildDrawFrame(): # this gets called when needed, rather than on import
|
||||
R.Name = color
|
||||
R.Bind(FloatCanvas.EVT_FC_ENTER_OBJECT, self.RectMouseOver)
|
||||
R.Bind(FloatCanvas.EVT_FC_LEAVE_OBJECT, self.RectMouseLeave)
|
||||
Canvas.AddText("Mouse ENter&Leave", (x, y), Size = FontSize, Position = "bl")
|
||||
Canvas.AddText("Mouse Enter&Leave", (x, y), Size = FontSize, Position = "bl")
|
||||
Canvas.AddText(R.Name, (x, y+h), Size = FontSize, Position = "tl")
|
||||
|
||||
x = 20
|
||||
@@ -722,7 +720,7 @@ def BuildDrawFrame(): # this gets called when needed, rather than on import
|
||||
|
||||
x += dx
|
||||
color = "SEA GREEN"
|
||||
Points = Numeric.array(( (x, y), (x, y+2.*h/3), (x+w, y+h), (x+w, y+h/2.), (x + 2.*w/3, y+h/2.), (x + 2.*w/3,y) ), Numeric.Float)
|
||||
Points = N.array(( (x, y), (x, y+2.*h/3), (x+w, y+h), (x+w, y+h/2.), (x + 2.*w/3, y+h/2.), (x + 2.*w/3,y) ), N.float_)
|
||||
R = Canvas.AddPolygon(Points, LineWidth = 2, FillColor = color)
|
||||
R.Name = color + " Polygon"
|
||||
R.Bind(FloatCanvas.EVT_FC_RIGHT_DOWN, self.RectGotHitRight)
|
||||
@@ -731,7 +729,7 @@ def BuildDrawFrame(): # this gets called when needed, rather than on import
|
||||
|
||||
x += dx
|
||||
color = "Red"
|
||||
Points = Numeric.array(( (x, y), (x, y+2.*h/3), (x+w, y+h), (x+w, y+h/2.), (x + 2.*w/3, y+h/2.), (x + 2.*w/3,y) ), Numeric.Float)
|
||||
Points = N.array(( (x, y), (x, y+2.*h/3), (x+w, y+h), (x+w, y+h/2.), (x + 2.*w/3, y+h/2.), (x + 2.*w/3,y) ), N.float_)
|
||||
R = Canvas.AddPointSet(Points, Diameter = 4, Color = color)
|
||||
R.Name = "PointSet"
|
||||
R.Bind(FloatCanvas.EVT_FC_LEFT_DOWN, self.PointSetGotHit)
|
||||
@@ -755,7 +753,7 @@ def BuildDrawFrame(): # this gets called when needed, rather than on import
|
||||
x += dx
|
||||
color = "Cyan"
|
||||
Point = (x + w/2, y)
|
||||
#Points = Numeric.array(( (x, y), (x, y+2.*h/3), (x+w, y+h), (x+w, y+h/2.), (x + 2.*w/3, y+h/2.), (x + 2.*w/3,y) ), Numeric.Float)
|
||||
#Points = N.array(( (x, y), (x, y+2.*h/3), (x+w, y+h), (x+w, y+h/2.), (x + 2.*w/3, y+h/2.), (x + 2.*w/3,y) ), N.float_)
|
||||
R = Canvas.AddSquarePoint(Point, Size = 8, Color = color)
|
||||
R.Name = "SquarePoint"
|
||||
R.Bind(FloatCanvas.EVT_FC_LEFT_DOWN, self.RectGotHit)
|
||||
@@ -766,13 +764,12 @@ def BuildDrawFrame(): # this gets called when needed, rather than on import
|
||||
self.Canvas.ZoomToBB()
|
||||
|
||||
def TestHitTestForeground(self,event=None):
|
||||
wx.GetApp().Yield()
|
||||
wx.GetApp().Yield(True)
|
||||
|
||||
self.UnBindAllMouseEvents()
|
||||
Canvas = self.Canvas
|
||||
|
||||
Canvas.ClearAll()
|
||||
Canvas.SetProjectionFun(None)
|
||||
Canvas.InitAll()
|
||||
|
||||
#Add a Hitable rectangle
|
||||
w, h = 60, 20
|
||||
@@ -871,13 +868,14 @@ def BuildDrawFrame(): # this gets called when needed, rather than on import
|
||||
|
||||
|
||||
def TestText(self, event= None):
|
||||
wx.GetApp().Yield()
|
||||
wx.GetApp().Yield(True)
|
||||
|
||||
self.BindAllMouseEvents()
|
||||
Canvas = self.Canvas
|
||||
Canvas.ClearAll()
|
||||
Canvas.SetProjectionFun(None)
|
||||
Canvas.InitAll()
|
||||
|
||||
|
||||
DefaultSize = 12
|
||||
Point = (3, 0)
|
||||
|
||||
## Add a non-visible rectangle, just to get a Bounding Box
|
||||
@@ -889,29 +887,29 @@ def BuildDrawFrame(): # this gets called when needed, rather than on import
|
||||
|
||||
# Text
|
||||
String = "Some text"
|
||||
self.Canvas.AddText("Top Left",Point,Size = 14,Color = "Yellow",BackgroundColor = "Blue", Position = "tl")
|
||||
self.Canvas.AddText("Bottom Left",Point,Size = 14,Color = "Cyan",BackgroundColor = "Black",Position = "bl")
|
||||
self.Canvas.AddText("Top Right",Point,Size = 14,Color = "Black",BackgroundColor = "Cyan",Position = "tr")
|
||||
self.Canvas.AddText("Bottom Right",Point,Size = 14,Color = "Blue",BackgroundColor = "Yellow",Position = "br")
|
||||
self.Canvas.AddText("Top Left",Point,Size = DefaultSize,Color = "Yellow",BackgroundColor = "Blue", Position = "tl")
|
||||
self.Canvas.AddText("Bottom Left",Point,Size = DefaultSize,Color = "Cyan",BackgroundColor = "Black",Position = "bl")
|
||||
self.Canvas.AddText("Top Right",Point,Size = DefaultSize,Color = "Black",BackgroundColor = "Cyan",Position = "tr")
|
||||
self.Canvas.AddText("Bottom Right",Point,Size = DefaultSize,Color = "Blue",BackgroundColor = "Yellow",Position = "br")
|
||||
Canvas.AddPointSet((Point), Color = "White", Diameter = 2)
|
||||
|
||||
Point = (3, 2)
|
||||
|
||||
Canvas.AddPointSet((Point), Color = "White", Diameter = 2)
|
||||
self.Canvas.AddText("Top Center",Point,Size = 14,Color = "Black",Position = "tc")
|
||||
self.Canvas.AddText("Bottom Center",Point,Size = 14,Color = "White",Position = "bc")
|
||||
self.Canvas.AddText("Top Center",Point,Size = DefaultSize,Color = "Black",Position = "tc")
|
||||
self.Canvas.AddText("Bottom Center",Point,Size = DefaultSize,Color = "White",Position = "bc")
|
||||
|
||||
Point = (3, 4)
|
||||
|
||||
Canvas.AddPointSet((Point), Color = "White", Diameter = 2)
|
||||
self.Canvas.AddText("Center Right",Point,Size = 14,Color = "Black",Position = "cr")
|
||||
self.Canvas.AddText("Center Left",Point,Size = 14,Color = "Black",Position = "cl")
|
||||
self.Canvas.AddText("Center Right",Point,Size = DefaultSize,Color = "Black",Position = "cr")
|
||||
self.Canvas.AddText("Center Left",Point,Size = DefaultSize,Color = "Black",Position = "cl")
|
||||
|
||||
Point = (3, -2)
|
||||
|
||||
Canvas.AddPointSet((Point), Color = "White", Diameter = 2)
|
||||
self.Canvas.AddText("Center Center",
|
||||
Point, Size = 14,
|
||||
Point, Size = DefaultSize,
|
||||
Color = "Black",
|
||||
Position = "cc")
|
||||
|
||||
@@ -927,18 +925,17 @@ def BuildDrawFrame(): # this gets called when needed, rather than on import
|
||||
self.Canvas.AddText("ROMAN ITALIC BOLD Font", (-10, -5), Family = wx.ROMAN, Weight=wx.BOLD, Style=wx.ITALIC)
|
||||
|
||||
# NOTE: this font exists on my Linux box..who knows were else you'll find it!
|
||||
Font = wx.Font(20, wx.DEFAULT, wx.ITALIC, wx.NORMAL, False, "zapf chancery")
|
||||
self.Canvas.AddText("zapf chancery Font", (-10, -6), Font = Font)
|
||||
Font = wx.Font(20, wx.DEFAULT, wx.ITALIC, wx.NORMAL, False, "helvetica")
|
||||
self.Canvas.AddText("Helvetica Italic", (-10, -6), Font = Font)
|
||||
|
||||
self.Canvas.ZoomToBB()
|
||||
|
||||
def TestScaledText(self, event= None):
|
||||
wx.GetApp().Yield()
|
||||
wx.GetApp().Yield(True)
|
||||
|
||||
self.BindAllMouseEvents()
|
||||
Canvas = self.Canvas
|
||||
Canvas.ClearAll()
|
||||
Canvas.SetProjectionFun(None)
|
||||
Canvas.InitAll()
|
||||
|
||||
Point = (0, 0)
|
||||
|
||||
@@ -977,24 +974,23 @@ def BuildDrawFrame(): # this gets called when needed, rather than on import
|
||||
Canvas.AddPointSet((x,0), Color = "White", Diameter = 4)
|
||||
|
||||
|
||||
# NOTE: this font exists on my Linux box..who knows were else you'll find it!
|
||||
# NOTE: this font exists on my OS-X.who knows were else you'll find it!
|
||||
Point = (-100, 50)
|
||||
Font = wx.Font(12, wx.DEFAULT, wx.ITALIC, wx.NORMAL, False, "zapf chancery")
|
||||
T = self.Canvas.AddScaledText("zapf chancery Font", Point, Size = 20, Font = Font, Position = 'bc')
|
||||
Font = wx.Font(12, wx.DEFAULT, wx.ITALIC, wx.NORMAL, False, "helvetica")
|
||||
T = self.Canvas.AddScaledText("Helvetica Italic", Point, Size = 20, Font = Font, Position = 'bc')
|
||||
|
||||
Point = (-50, -50)
|
||||
Font = wx.Font(12, wx.DEFAULT, wx.ITALIC, wx.NORMAL, False, "bookman")
|
||||
T = self.Canvas.AddScaledText("Bookman Font", Point, Size = 8, Font = Font)
|
||||
Font = wx.Font(12, wx.DEFAULT, wx.ITALIC, wx.NORMAL, False, "times")
|
||||
T = self.Canvas.AddScaledText("Times Font", Point, Size = 8, Font = Font)
|
||||
|
||||
self.Canvas.ZoomToBB()
|
||||
|
||||
def TestScaledTextBox(self, event= None):
|
||||
wx.GetApp().Yield()
|
||||
wx.GetApp().Yield(True)
|
||||
|
||||
self.UnBindAllMouseEvents()
|
||||
Canvas = self.Canvas
|
||||
Canvas.ClearAll()
|
||||
Canvas.SetProjectionFun(None)
|
||||
Canvas.InitAll()
|
||||
|
||||
Point = (45,40)
|
||||
Box = Canvas.AddScaledTextBox("A Two Line\nString",
|
||||
@@ -1010,7 +1006,7 @@ def BuildDrawFrame(): # this gets called when needed, rather than on import
|
||||
Family = wx.ROMAN,
|
||||
Style = wx.NORMAL,
|
||||
Weight = wx.NORMAL,
|
||||
Underline = False,
|
||||
Underlined = False,
|
||||
Position = 'br',
|
||||
Alignment = "left",
|
||||
InForeground = False)
|
||||
@@ -1058,7 +1054,7 @@ def BuildDrawFrame(): # this gets called when needed, rather than on import
|
||||
Family = wx.TELETYPE,
|
||||
Style = wx.NORMAL,
|
||||
Weight = wx.NORMAL,
|
||||
Underline = False,
|
||||
Underlined = False,
|
||||
Position = 'cr',
|
||||
Alignment = "left",
|
||||
InForeground = False)
|
||||
@@ -1076,7 +1072,7 @@ def BuildDrawFrame(): # this gets called when needed, rather than on import
|
||||
Family = wx.TELETYPE,
|
||||
Style = wx.NORMAL,
|
||||
Weight = wx.NORMAL,
|
||||
Underline = False,
|
||||
Underlined = False,
|
||||
Position = 'cl',
|
||||
Alignment = "left",
|
||||
InForeground = False)
|
||||
@@ -1097,7 +1093,7 @@ def BuildDrawFrame(): # this gets called when needed, rather than on import
|
||||
Family = wx.TELETYPE,
|
||||
Style = wx.NORMAL,
|
||||
Weight = wx.NORMAL,
|
||||
Underline = False,
|
||||
Underlined = False,
|
||||
Position = 'tc',
|
||||
Alignment = "left",
|
||||
InForeground = False)
|
||||
@@ -1115,7 +1111,7 @@ def BuildDrawFrame(): # this gets called when needed, rather than on import
|
||||
Family = wx.TELETYPE,
|
||||
Style = wx.NORMAL,
|
||||
Weight = wx.NORMAL,
|
||||
Underline = False,
|
||||
Underlined = False,
|
||||
Position = 'bc',
|
||||
Alignment = "left",
|
||||
InForeground = False)
|
||||
@@ -1143,7 +1139,7 @@ def BuildDrawFrame(): # this gets called when needed, rather than on import
|
||||
Family = wx.ROMAN,
|
||||
Alignment = "right"
|
||||
)
|
||||
Point = Numeric.array((100, -20), Numeric.Float)
|
||||
Point = N.array((100, -20), N.float_)
|
||||
Box = Canvas.AddScaledTextBox("Here is even more auto wrapped text. This time the line spacing is set to 0.8. \n\nThe Padding is set to 0.",
|
||||
Point,
|
||||
Size = 3,
|
||||
@@ -1157,8 +1153,8 @@ def BuildDrawFrame(): # this gets called when needed, rather than on import
|
||||
)
|
||||
Canvas.AddPoint(Point, "Red", 2)
|
||||
|
||||
Point = Numeric.array((0, -40), Numeric.Float)
|
||||
# Point = Numeric.array((0, 0), Numeric.Float)
|
||||
Point = N.array((0, -40), N.float_)
|
||||
# Point = N.array((0, 0), N.float_)
|
||||
for Position in ["tl", "bl", "tr", "br"]:
|
||||
# for Position in ["br"]:
|
||||
Box = Canvas.AddScaledTextBox("Here is a\nfour liner\nanother line\nPosition=%s"%Position,
|
||||
@@ -1176,7 +1172,7 @@ def BuildDrawFrame(): # this gets called when needed, rather than on import
|
||||
)
|
||||
Canvas.AddPoint(Point, "Red", 4)
|
||||
|
||||
Point = Numeric.array((-20, 60), Numeric.Float)
|
||||
Point = N.array((-20, 60), N.float_)
|
||||
Box = Canvas.AddScaledTextBox("Here is some\ncentered\ntext",
|
||||
Point,
|
||||
Size = 4,
|
||||
@@ -1192,7 +1188,7 @@ def BuildDrawFrame(): # this gets called when needed, rather than on import
|
||||
LineSpacing = 0.8
|
||||
)
|
||||
|
||||
Point = Numeric.array((-20, 20), Numeric.Float)
|
||||
Point = N.array((-20, 20), N.float_)
|
||||
Box = Canvas.AddScaledTextBox("Here is some\nright aligned\ntext",
|
||||
Point,
|
||||
Size = 4,
|
||||
@@ -1207,7 +1203,7 @@ def BuildDrawFrame(): # this gets called when needed, rather than on import
|
||||
LineSpacing = 0.8
|
||||
)
|
||||
|
||||
Point = Numeric.array((100, -60), Numeric.Float)
|
||||
Point = N.array((100, -60), N.float_)
|
||||
Box = Canvas.AddScaledTextBox("Here is some auto wrapped text. This time it is centered, rather than right aligned.\n\nThe Padding is set to 2.",
|
||||
Point,
|
||||
Size = 3,
|
||||
@@ -1230,13 +1226,12 @@ def BuildDrawFrame(): # this gets called when needed, rather than on import
|
||||
self.Log("I'm the TextBox")
|
||||
|
||||
def TestBitmap(self, event= None):
|
||||
wx.GetApp().Yield()
|
||||
wx.GetApp().Yield(True)
|
||||
|
||||
self.UnBindAllMouseEvents()
|
||||
Canvas = self.Canvas
|
||||
Canvas.ClearAll()
|
||||
Canvas.SetProjectionFun(None)
|
||||
|
||||
Canvas.InitAll()
|
||||
|
||||
Canvas.AddRectangle((10, 20),
|
||||
(400, 100),
|
||||
LineWidth = 3,
|
||||
@@ -1295,16 +1290,17 @@ def BuildDrawFrame(): # this gets called when needed, rather than on import
|
||||
self.Canvas.ZoomToBB()
|
||||
|
||||
def DrawMap(self,event = None):
|
||||
wx.GetApp().Yield()
|
||||
wx.GetApp().Yield(True)
|
||||
import os, time
|
||||
|
||||
self.Canvas.InitAll()
|
||||
self.Canvas.SetProjectionFun("FlatEarth")
|
||||
self.BindAllMouseEvents()
|
||||
|
||||
## Test of Actual Map Data
|
||||
self.Canvas.ClearAll()
|
||||
self.Canvas.SetProjectionFun("FlatEarth")
|
||||
#start = time.clock()
|
||||
self.Log("Loading Map from a File")
|
||||
wx.GetApp().Yield() # so log text will get displayed now.
|
||||
wx.GetApp().Yield(True) # so log text will get displayed now.
|
||||
Shorelines = self.Read_MapGen(os.path.join("data",'world.dat'),stats = 0)
|
||||
#print "It took %f seconds to load %i shorelines"%(time.clock() - start,len(Shorelines) )
|
||||
#start = time.clock()
|
||||
@@ -1316,17 +1312,17 @@ def BuildDrawFrame(): # this gets called when needed, rather than on import
|
||||
#print "It took %f seconds to draw %i shorelines"%(time.clock() - start,len(Shorelines) )
|
||||
|
||||
|
||||
|
||||
def LineTest(self,event = None):
|
||||
wx.GetApp().Yield()
|
||||
wx.GetApp().Yield(True)
|
||||
import os, time
|
||||
# import random
|
||||
colors = self.colors
|
||||
Range = (-10,10)
|
||||
## Test of drawing lots of lines
|
||||
Canvas = self.Canvas
|
||||
Canvas.ClearAll()
|
||||
Canvas.SetProjectionFun(None)
|
||||
#start = time.clock()
|
||||
Canvas.InitAll()
|
||||
#start = time.clock()
|
||||
linepoints = []
|
||||
linecolors = []
|
||||
linewidths = []
|
||||
@@ -1345,17 +1341,44 @@ def BuildDrawFrame(): # this gets called when needed, rather than on import
|
||||
Canvas.ZoomToBB()
|
||||
#print "It took %f seconds to draw %i lines"%(time.clock() - start,len(linepoints) )
|
||||
|
||||
def ArrowLineTest(self,event = None):
|
||||
wx.GetApp().Yield(True)
|
||||
Canvas = self.Canvas
|
||||
Canvas.InitAll()
|
||||
# import os, time
|
||||
## import random
|
||||
Range = (-100,100)
|
||||
colors = self.colors
|
||||
|
||||
# Lines
|
||||
for i in range(5):
|
||||
points = []
|
||||
for j in range(random.randint(2,10)):
|
||||
point = (random.randint(Range[0],Range[1]),random.randint(Range[0],Range[1]))
|
||||
points.append(point)
|
||||
lw = random.randint(1,4)
|
||||
cf = random.randint(0,len(colors)-1)
|
||||
cl = random.randint(0,len(colors)-1)
|
||||
al = random.randint(8,20)
|
||||
aa = random.randint(20,90)
|
||||
Canvas.AddArrowLine(points,
|
||||
LineWidth = lw,
|
||||
LineColor = colors[cl],
|
||||
ArrowHeadSize = al,
|
||||
ArrowHeadAngle = aa)
|
||||
|
||||
Canvas.ZoomToBB()
|
||||
|
||||
def SpeedTest(self,event=None):
|
||||
wx.GetApp().Yield()
|
||||
wx.GetApp().Yield(True)
|
||||
BigRange = (-1000,1000)
|
||||
colors = self.colors
|
||||
|
||||
self.UnBindAllMouseEvents()
|
||||
Canvas = self.Canvas
|
||||
|
||||
Canvas.ClearAll()
|
||||
Canvas.SetProjectionFun(None)
|
||||
|
||||
Canvas.InitAll()
|
||||
|
||||
# Pointset
|
||||
coords = []
|
||||
for i in range(1000):
|
||||
@@ -1369,7 +1392,7 @@ def BuildDrawFrame(): # this gets called when needed, rather than on import
|
||||
Canvas.ZoomToBB()
|
||||
|
||||
def PropertiesChangeTest(self,event=None):
|
||||
wx.GetApp().Yield()
|
||||
wx.GetApp().Yield(True)
|
||||
|
||||
Range = (-10,10)
|
||||
colors = self.colors
|
||||
@@ -1377,9 +1400,8 @@ def BuildDrawFrame(): # this gets called when needed, rather than on import
|
||||
self.UnBindAllMouseEvents()
|
||||
Canvas = self.Canvas
|
||||
|
||||
Canvas.ClearAll()
|
||||
Canvas.SetProjectionFun(None)
|
||||
|
||||
Canvas.InitAll()
|
||||
|
||||
self.ColorObjectsAll = []
|
||||
self.ColorObjectsLine = []
|
||||
self.ColorObjectsColor = []
|
||||
@@ -1512,13 +1534,14 @@ def BuildDrawFrame(): # this gets called when needed, rather than on import
|
||||
self.Canvas.Draw(Force = True)
|
||||
|
||||
def ArrowTest(self,event=None):
|
||||
wx.GetApp().Yield()
|
||||
wx.GetApp().Yield(True)
|
||||
self.UnBindAllMouseEvents()
|
||||
Canvas = self.Canvas
|
||||
|
||||
Canvas.ClearAll()
|
||||
Canvas.SetProjectionFun(None)
|
||||
|
||||
Canvas.InitAll()
|
||||
Canvas.MinScale = 15
|
||||
Canvas.MaxScale = 30
|
||||
|
||||
# put in a rectangle to get a bounding box
|
||||
Canvas.AddRectangle((0,0), (20,20), LineColor = None)
|
||||
|
||||
@@ -1534,16 +1557,18 @@ def BuildDrawFrame(): # this gets called when needed, rather than on import
|
||||
|
||||
Canvas.AddText("Clickable Arrow", (4,18), Position = "bc")
|
||||
Arrow = Canvas.AddArrow((4,18), 80, Direction = 90 ,LineWidth = 3, LineColor = "Red", ArrowHeadAngle = 30)
|
||||
Arrow.HitLineWidth = 6
|
||||
Arrow.Bind(FloatCanvas.EVT_FC_LEFT_DOWN, self.ArrowClicked)
|
||||
|
||||
Canvas.AddText("Changable Arrow", (16,4), Position = "cc")
|
||||
Canvas.AddText("Changable Arrow: try clicking it", (16,4), Position = "tc")
|
||||
self.RotArrow = Canvas.AddArrow((16,4), 80, Direction = 0 ,LineWidth = 3, LineColor = "Green", ArrowHeadAngle = 30)
|
||||
self.RotArrow.HitLineWidth = 6
|
||||
self.RotArrow.Bind(FloatCanvas.EVT_FC_LEFT_DOWN, self.RotateArrow)
|
||||
|
||||
Canvas.ZoomToBB()
|
||||
|
||||
def ArrowClicked(self,event):
|
||||
print "The Arrow was Clicked"
|
||||
self.Log("The Arrow was Clicked")
|
||||
|
||||
def RotateArrow(self,event):
|
||||
##print "The Changeable Arrow was Clicked"
|
||||
@@ -1557,13 +1582,12 @@ def BuildDrawFrame(): # this gets called when needed, rather than on import
|
||||
self.Canvas.Draw(Force = True)
|
||||
|
||||
def HideTest(self, event=None):
|
||||
wx.GetApp().Yield()
|
||||
wx.GetApp().Yield(True)
|
||||
|
||||
self.UnBindAllMouseEvents()
|
||||
Canvas = self.Canvas
|
||||
Canvas.ClearAll()
|
||||
Canvas.SetProjectionFun(None)
|
||||
|
||||
Canvas.InitAll()
|
||||
|
||||
Range = (-10,10)
|
||||
|
||||
# Create a couple random Polygons
|
||||
@@ -1616,22 +1640,32 @@ def BuildDrawFrame(): # this gets called when needed, rather than on import
|
||||
|
||||
def HidePoly(self, Button):
|
||||
Poly = Button.HidePoly
|
||||
|
||||
if Poly.Visible:
|
||||
Poly.Hide()
|
||||
Poly.Visible = False
|
||||
Button.SetText(Button.String.replace("Hide","Show"))
|
||||
else:
|
||||
Poly.Show()
|
||||
Poly.Visible = True
|
||||
Button.SetText(Button.String.replace("Show", "Hide"))
|
||||
self.Canvas.Draw(True)
|
||||
|
||||
|
||||
def TempTest(self, event= None):
|
||||
wx.GetApp().Yield()
|
||||
"""
|
||||
|
||||
This is the start of a poly editor test, but it's not complete
|
||||
so you can only run it through a command line flag:
|
||||
|
||||
python FloatCanvasDemo.py --temp
|
||||
|
||||
"""
|
||||
|
||||
wx.GetApp().Yield(True)
|
||||
|
||||
self.UnBindAllMouseEvents()
|
||||
Canvas = self.Canvas
|
||||
Canvas.ClearAll()
|
||||
Canvas.SetProjectionFun(None)
|
||||
|
||||
Canvas.InitAll()
|
||||
|
||||
Range = (-10,10)
|
||||
|
||||
# Create a random Polygon
|
||||
@@ -1654,7 +1688,6 @@ def BuildDrawFrame(): # this gets called when needed, rather than on import
|
||||
Canvas.ZoomToBB()
|
||||
|
||||
def SelectPoly(self, Object):
|
||||
print "In SelectPoly"
|
||||
Canvas = self.Canvas
|
||||
if Object is self.SelectedPoly:
|
||||
pass
|
||||
@@ -1673,7 +1706,7 @@ def BuildDrawFrame(): # this gets called when needed, rather than on import
|
||||
Canvas.Draw()
|
||||
|
||||
def SelectPointHit(self, Point):
|
||||
print "Point Num: %i Hit"%Point.VerticeNum
|
||||
self.Log("Point Num: %i Hit"%Point.VerticeNum)
|
||||
self.SelectedPoint = Point
|
||||
|
||||
def Read_MapGen(self, filename, stats = 0,AllLines=0):
|
||||
@@ -1697,11 +1730,11 @@ def BuildDrawFrame(): # this gets called when needed, rather than on import
|
||||
for line in data:
|
||||
if line:
|
||||
if line == "# -b": #New segment beginning
|
||||
if segment: Shorelines.append(Numeric.array(segment))
|
||||
if segment: Shorelines.append(N.array(segment))
|
||||
segment = []
|
||||
else:
|
||||
segment.append(map(float,string.split(line)))
|
||||
if segment: Shorelines.append(Numeric.array(segment))
|
||||
if segment: Shorelines.append(N.array(segment))
|
||||
|
||||
if stats:
|
||||
NumSegments = len(Shorelines)
|
||||
@@ -1728,13 +1761,16 @@ def BuildDrawFrame(): # this gets called when needed, rather than on import
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
# running stand alone, Use wxversion:
|
||||
# import wxversion
|
||||
# wxversion.select("2.6")
|
||||
# wxversion.select("2.8")
|
||||
import wx
|
||||
|
||||
|
||||
# check options:
|
||||
import sys, getopt
|
||||
optlist, args = getopt.getopt(sys.argv[1:],'l',["local",
|
||||
"all",
|
||||
optlist, args = getopt.getopt(sys.argv[1:],'l',["all",
|
||||
"text",
|
||||
"map",
|
||||
"stext",
|
||||
@@ -1747,40 +1783,15 @@ if __name__ == "__main__":
|
||||
"temp",
|
||||
"props",
|
||||
"arrow",
|
||||
"arrowline",
|
||||
"hide"])
|
||||
|
||||
if not haveNumeric:
|
||||
if not haveNumpy:
|
||||
raise ImportError(errorText)
|
||||
StartUpDemo = "all" # the default
|
||||
for opt in optlist:
|
||||
if opt[0] == "--all":
|
||||
StartUpDemo = "all"
|
||||
elif opt[0] == "--text":
|
||||
StartUpDemo = "text"
|
||||
elif opt[0] == "--map":
|
||||
StartUpDemo = "map"
|
||||
elif opt[0] == "--stext":
|
||||
StartUpDemo = "stext"
|
||||
elif opt[0] == "--stextbox":
|
||||
StartUpDemo = "stextbox"
|
||||
elif opt[0] == "--bitmap":
|
||||
StartUpDemo = "bitmap"
|
||||
elif opt[0] == "--hit":
|
||||
StartUpDemo = "hit"
|
||||
elif opt[0] == "--hitf":
|
||||
StartUpDemo = "hitf"
|
||||
elif opt[0] == "--animate":
|
||||
StartUpDemo = "animate"
|
||||
elif opt[0] == "--speed":
|
||||
StartUpDemo = "speed"
|
||||
elif opt[0] == "--temp":
|
||||
StartUpDemo = "temp"
|
||||
elif opt[0] == "--props":
|
||||
StartUpDemo = "props"
|
||||
elif opt[0] == "--arrow":
|
||||
StartUpDemo = "arrow"
|
||||
elif opt[0] == "--hide":
|
||||
StartUpDemo = "hide"
|
||||
if optlist:
|
||||
StartUpDemo = optlist[0][0][2:]
|
||||
|
||||
|
||||
class DemoApp(wx.App):
|
||||
"""
|
||||
@@ -1844,6 +1855,7 @@ if __name__ == "__main__":
|
||||
frame.Show()
|
||||
|
||||
## check to see if the demo is set to start in a particular mode.
|
||||
## fixme: should this be in a dict instead?
|
||||
if StartUpDemo == "text":
|
||||
frame.TestText()
|
||||
elif StartUpDemo == "stext":
|
||||
@@ -1859,25 +1871,20 @@ if __name__ == "__main__":
|
||||
elif StartUpDemo == "hit":
|
||||
frame.TestHitTest()
|
||||
elif StartUpDemo == "hitf":
|
||||
"starting TestHitTestForeground"
|
||||
frame.TestHitTestForeground()
|
||||
elif StartUpDemo == "animate":
|
||||
"starting TestAnimation"
|
||||
frame.TestAnimation()
|
||||
elif StartUpDemo == "speed":
|
||||
"starting SpeedTest"
|
||||
frame.SpeedTest()
|
||||
elif StartUpDemo == "temp":
|
||||
"starting temp Test"
|
||||
frame.TempTest()
|
||||
elif StartUpDemo == "props":
|
||||
"starting PropertiesChange Test"
|
||||
frame.PropertiesChangeTest()
|
||||
elif StartUpDemo == "arrow":
|
||||
"starting arrow Test"
|
||||
frame.ArrowTest()
|
||||
elif StartUpDemo == "arrowline":
|
||||
frame.ArrowLineTest()
|
||||
elif StartUpDemo == "hide":
|
||||
"starting Hide Test"
|
||||
frame.HideTest()
|
||||
|
||||
return True
|
||||
@@ -1889,14 +1896,14 @@ else:
|
||||
# It's not running stand-alone, set up for wxPython demo.
|
||||
# don't neeed wxversion here.
|
||||
import wx
|
||||
if not haveNumeric:
|
||||
if not haveNumpy:
|
||||
## TestPanel and runTest used for integration into wxPython Demo
|
||||
class TestPanel(wx.Panel):
|
||||
def __init__(self, parent, log):
|
||||
self.log = log
|
||||
wx.Panel.__init__(self, parent, -1)
|
||||
|
||||
import images
|
||||
from wx.lib.floatcanvas.ScreenShot import getScreenShotBitmap
|
||||
|
||||
note1 = wx.StaticText(self, -1, errorText)
|
||||
note2 = wx.StaticText(self, -1, "This is what the FloatCanvas can look like:")
|
||||
@@ -1904,7 +1911,7 @@ else:
|
||||
S.Add((10, 10), 1)
|
||||
S.Add(note1, 0, wx.ALIGN_CENTER)
|
||||
S.Add(note2, 0, wx.ALIGN_CENTER | wx.BOTTOM, 4)
|
||||
S.Add(wx.StaticBitmap(self,-1,images.getFloatCanvasBitmap()),0,wx.ALIGN_CENTER)
|
||||
S.Add(wx.StaticBitmap(self,-1,getScreenShotBitmap()),0,wx.ALIGN_CENTER)
|
||||
S.Add((10, 10), 1)
|
||||
self.SetSizer(S)
|
||||
self.Layout()
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -103,17 +103,17 @@ class CustomDataTable(gridlib.PyGridTableBase):
|
||||
|
||||
# Notify the grid
|
||||
grid.BeginBatch()
|
||||
msg = gridlib.GridTableMessage(
|
||||
self, gridlib.GRIDTABLE_NOTIFY_COLS_DELETED, frm, 1
|
||||
)
|
||||
|
||||
grid.ProcessTableMessage(msg)
|
||||
|
||||
|
||||
msg = gridlib.GridTableMessage(
|
||||
self, gridlib.GRIDTABLE_NOTIFY_COLS_INSERTED, to, 1
|
||||
)
|
||||
|
||||
grid.ProcessTableMessage(msg)
|
||||
|
||||
msg = gridlib.GridTableMessage(
|
||||
self, gridlib.GRIDTABLE_NOTIFY_COLS_DELETED, frm, 1
|
||||
)
|
||||
grid.ProcessTableMessage(msg)
|
||||
|
||||
grid.EndBatch()
|
||||
|
||||
# Move the row
|
||||
@@ -138,16 +138,15 @@ class CustomDataTable(gridlib.PyGridTableBase):
|
||||
grid.BeginBatch()
|
||||
|
||||
msg = gridlib.GridTableMessage(
|
||||
self, gridlib.GRIDTABLE_NOTIFY_ROWS_DELETED, frm, 1
|
||||
self, gridlib.GRIDTABLE_NOTIFY_ROWS_INSERTED, to, 1
|
||||
)
|
||||
|
||||
grid.ProcessTableMessage(msg)
|
||||
|
||||
msg = gridlib.GridTableMessage(
|
||||
self, gridlib.GRIDTABLE_NOTIFY_ROWS_INSERTED, to, 1
|
||||
self, gridlib.GRIDTABLE_NOTIFY_ROWS_DELETED, frm, 1
|
||||
)
|
||||
|
||||
grid.ProcessTableMessage(msg)
|
||||
|
||||
grid.EndBatch()
|
||||
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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()))
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
|
||||
@@ -54,6 +54,7 @@ The controls at the top reconfigure the resulting control at the bottom.
|
||||
|
||||
|
||||
self.limit_target = wx.CheckBox( panel, -1, "Limit control" )
|
||||
self.limit_on_field_change = wx.CheckBox( panel, -1, "Limit on field change" )
|
||||
self.allow_none = wx.CheckBox( panel, -1, "Allow empty control" )
|
||||
self.group_digits = wx.CheckBox( panel, -1, "Group digits" )
|
||||
self.group_digits.SetValue( True )
|
||||
@@ -102,21 +103,26 @@ value entry ctrl:""")
|
||||
|
||||
|
||||
grid1.Add( self.limit_target, 0, wx.ALIGN_LEFT|wx.ALL, 5 )
|
||||
grid1.Add( self.allow_none, 0, wx.ALIGN_LEFT|wx.ALL, 5 )
|
||||
grid1.Add( self.limit_on_field_change, 0, wx.ALIGN_LEFT|wx.ALL, 5 )
|
||||
|
||||
hbox1 = wx.BoxSizer( wx.HORIZONTAL )
|
||||
hbox1.Add( (17,5), 0, wx.ALIGN_LEFT|wx.ALL, 5)
|
||||
hbox1.Add( self.group_digits, 0, wx.ALIGN_LEFT|wx.LEFT, 5 )
|
||||
hbox1.Add( self.allow_none, 0, wx.ALIGN_LEFT|wx.ALL, 5 )
|
||||
grid1.Add( hbox1, 0, wx.ALIGN_LEFT|wx.ALL, 5)
|
||||
grid1.Add( (5,5), 0, wx.ALIGN_LEFT|wx.ALL, 5)
|
||||
|
||||
grid1.Add( self.allow_negative, 0, wx.ALIGN_LEFT|wx.ALL, 5 )
|
||||
grid1.Add( self.use_parens, 0, wx.ALIGN_LEFT|wx.ALL, 5 )
|
||||
grid1.Add( self.group_digits, 0, wx.ALIGN_LEFT|wx.LEFT, 5 )
|
||||
grid1.Add( self.allow_negative, 0, wx.ALIGN_LEFT|wx.ALL, 5 )
|
||||
hbox2 = wx.BoxSizer( wx.HORIZONTAL )
|
||||
hbox2.Add( (17,5), 0, wx.ALIGN_LEFT|wx.ALL, 5)
|
||||
hbox2.Add( self.select_on_entry, 0, wx.ALIGN_LEFT|wx.LEFT, 5 )
|
||||
hbox2.Add( self.use_parens, 0, wx.ALIGN_LEFT|wx.ALL, 5 )
|
||||
grid1.Add( hbox2, 0, wx.ALIGN_LEFT|wx.ALL, 5)
|
||||
grid1.Add( (5,5), 0, wx.ALIGN_LEFT|wx.ALL, 5)
|
||||
|
||||
|
||||
grid1.Add( self.select_on_entry, 0, wx.ALIGN_LEFT|wx.LEFT, 5 )
|
||||
grid1.Add( (5,5), 0, wx.ALIGN_LEFT|wx.ALL, 5)
|
||||
grid1.Add( (5,5), 0, wx.ALIGN_LEFT|wx.ALL, 5)
|
||||
grid1.Add( (5,5), 0, wx.ALIGN_LEFT|wx.ALL, 5)
|
||||
|
||||
grid2 = wx.FlexGridSizer( 0, 2, 0, 0 )
|
||||
grid2.Add( label, 0, wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
|
||||
@@ -151,7 +157,8 @@ value entry ctrl:""")
|
||||
self.Bind(masked.EVT_NUM, self.SetTargetMinMax, self.min )
|
||||
self.Bind(masked.EVT_NUM, self.SetTargetMinMax, self.max )
|
||||
|
||||
self.Bind(wx.EVT_CHECKBOX, self.SetTargetMinMax, self.limit_target )
|
||||
self.Bind(wx.EVT_CHECKBOX, self.OnSetLimited, self.limit_target )
|
||||
self.Bind(wx.EVT_CHECKBOX, self.OnSetLimitOnFieldChange, self.limit_on_field_change )
|
||||
self.Bind(wx.EVT_CHECKBOX, self.OnSetAllowNone, self.allow_none )
|
||||
self.Bind(wx.EVT_CHECKBOX, self.OnSetGroupDigits, self.group_digits )
|
||||
self.Bind(wx.EVT_CHECKBOX, self.OnSetAllowNegative, self.allow_negative )
|
||||
@@ -218,10 +225,26 @@ value entry ctrl:""")
|
||||
self.SetTargetMinMax()
|
||||
|
||||
|
||||
def OnSetLimited( self, event ):
|
||||
limited = self.limit_target.GetValue()
|
||||
self.target_ctl.SetLimited( limited )
|
||||
limit_on_field_change = self.limit_on_field_change.GetValue()
|
||||
if limited and limit_on_field_change:
|
||||
self.limit_on_field_change.SetValue(False)
|
||||
self.target_ctl.SetLimitOnFieldChange( False )
|
||||
self.SetTargetMinMax()
|
||||
|
||||
|
||||
def OnSetLimitOnFieldChange( self, event ):
|
||||
limit_on_field_change = self.limit_on_field_change.GetValue()
|
||||
self.target_ctl.SetLimitOnFieldChange( limit_on_field_change )
|
||||
limited = self.limit_target.GetValue()
|
||||
if limited and limit_on_field_change:
|
||||
self.limit_target.SetValue(False)
|
||||
self.target_ctl.SetLimited( False )
|
||||
|
||||
def SetTargetMinMax( self, event=None ):
|
||||
min = max = None
|
||||
self.target_ctl.SetLimited( self.limit_target.GetValue() )
|
||||
|
||||
if self.set_min.GetValue():
|
||||
min = self.min.GetValue()
|
||||
if self.set_max.GetValue():
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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() )
|
||||
|
||||
@@ -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:])
|
||||
|
||||
|
||||
@@ -75,8 +75,13 @@ class TestPanel(wx.Panel):
|
||||
self.tree.Expand(self.root)
|
||||
|
||||
self.tree.GetMainWindow().Bind(wx.EVT_RIGHT_UP, self.OnRightUp)
|
||||
self.tree.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.OnActivate)
|
||||
|
||||
|
||||
def OnActivate(self, evt):
|
||||
self.log.write('OnActivate: %s' % self.tree.GetItemText(evt.GetItem()))
|
||||
|
||||
|
||||
def OnRightUp(self, evt):
|
||||
pos = evt.GetPosition()
|
||||
item, flags, col = self.tree.HitTest(pos)
|
||||
|
||||
261
wxPython/demo/TreeMixin.py
Normal file
261
wxPython/demo/TreeMixin.py
Normal file
@@ -0,0 +1,261 @@
|
||||
import wx, wx.lib.customtreectrl, wx.gizmos
|
||||
import 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, itemToMoveIndex, newParentIndex):
|
||||
itemToMove = self.GetItem(itemToMoveIndex)
|
||||
newParentChildren = self.GetChildren(newParentIndex)
|
||||
newParentChildren.append(itemToMove)
|
||||
oldParentChildren = self.GetChildren(itemToMoveIndex[:-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):
|
||||
dropIndex = self.GetIndexOfItem(dropTarget)
|
||||
dropText = self.model.GetText(dropIndex)
|
||||
dragIndex = self.GetIndexOfItem(dragItem)
|
||||
dragText = self.model.GetText(dragIndex)
|
||||
self.log.write('drop %s %s on %s %s'%(dragText, dragIndex,
|
||||
dropText, dropIndex))
|
||||
self.model.MoveItem(dragIndex, dropIndex)
|
||||
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['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(indices, False)
|
||||
|
||||
def OnItemChecked(self, event):
|
||||
item = event.GetItem()
|
||||
itemIndex = self.GetIndexOfItem(item)
|
||||
if self.GetItemType(item) == 2:
|
||||
# It's a radio item; reset other items on the same level
|
||||
for nr in range(self.GetChildrenCount(self.GetItemParent(item))):
|
||||
self.checked[itemIndex[:-1]+(nr,)] = False
|
||||
self.checked[itemIndex] = 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.RefreshItems()
|
||||
newTree.SetExpansionState(oldTree.GetExpansionState())
|
||||
event.Skip()
|
||||
|
||||
def GetIndicesOfSelectedItems(self):
|
||||
tree = self.trees[self.GetSelection()]
|
||||
if tree.GetSelections():
|
||||
return [tree.GetIndexOfItem(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:])
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user