Forward port recent changes on the 2.8 branch to HEAD
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@46083 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
@@ -395,7 +395,7 @@ class PyAUIFrame(wx.Frame):
|
||||
self.Bind(wx.EVT_MENU, self.OnChangeContentPane, id=ID_TextContent)
|
||||
self.Bind(wx.EVT_MENU, self.OnChangeContentPane, id=ID_SizeReportContent)
|
||||
self.Bind(wx.EVT_MENU, self.OnChangeContentPane, id=ID_HTMLContent)
|
||||
self.Bind(wx.EVT_MENU, self.OnClose, id=wx.ID_EXIT)
|
||||
self.Bind(wx.EVT_MENU, self.OnExit, id=wx.ID_EXIT)
|
||||
self.Bind(wx.EVT_MENU, self.OnAbout, id=ID_About)
|
||||
|
||||
self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateUI, id=ID_TransparentHint)
|
||||
@@ -431,12 +431,13 @@ class PyAUIFrame(wx.Frame):
|
||||
|
||||
|
||||
def OnClose(self, event):
|
||||
|
||||
self._mgr.UnInit()
|
||||
del self._mgr
|
||||
self.Destroy()
|
||||
|
||||
event.Skip()
|
||||
|
||||
def OnExit(self, event):
|
||||
self.Close()
|
||||
|
||||
def OnAbout(self, event):
|
||||
|
||||
|
@@ -19,7 +19,8 @@ class TestPanel(wx.Panel):
|
||||
title.SetFont(wx.Font(18, wx.SWISS, wx.NORMAL, wx.BOLD))
|
||||
title.SetForegroundColour("blue")
|
||||
|
||||
self.cp = cp = wx.CollapsiblePane(self, label=label1)
|
||||
self.cp = cp = wx.CollapsiblePane(self, label=label1,
|
||||
style=wx.CP_DEFAULT_STYLE|wx.CP_NO_TLW_RESIZE)
|
||||
self.Bind(wx.EVT_COLLAPSIBLEPANE_CHANGED, self.OnPaneChanged, cp)
|
||||
self.MakePaneContent(cp.GetPane())
|
||||
|
||||
|
@@ -136,19 +136,11 @@ class DragCanvas(wx.ScrolledWindow):
|
||||
return shape
|
||||
return None
|
||||
|
||||
# Remove a shape from the display
|
||||
def EraseShape(self, shape, dc):
|
||||
r = shape.GetRect()
|
||||
dc.SetClippingRect(r)
|
||||
self.TileBackground(dc)
|
||||
self.DrawShapes(dc)
|
||||
dc.DestroyClippingRegion()
|
||||
|
||||
# Clears the background, then redraws it. If the DC is passed, then
|
||||
# we only do so in the area so designated. Otherwise, it's the whole thing.
|
||||
def OnEraseBackground(self, evt):
|
||||
dc = evt.GetDC()
|
||||
|
||||
if not dc:
|
||||
dc = wx.ClientDC(self)
|
||||
rect = self.GetUpdateRegion().GetBox()
|
||||
@@ -231,11 +223,11 @@ class DragCanvas(wx.ScrolledWindow):
|
||||
if dx <= tolerance and dy <= tolerance:
|
||||
return
|
||||
|
||||
# erase the shape since it will be drawn independently now
|
||||
dc = wx.ClientDC(self)
|
||||
# refresh the area of the window where the shape was so it
|
||||
# will get erased.
|
||||
self.dragShape.shown = False
|
||||
self.EraseShape(self.dragShape, dc)
|
||||
|
||||
self.RefreshRect(self.dragShape.GetRect(), True)
|
||||
self.Update()
|
||||
|
||||
if self.dragShape.text:
|
||||
self.dragImage = wx.DragString(self.dragShape.text,
|
||||
|
@@ -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,9 +19,11 @@
|
||||
# * Annoying switching between tabs and resulting flicker
|
||||
# how to replace a page in the notebook without deleting/adding?
|
||||
# Where is SetPage!? tried freeze...tried reparent of dummy panel....
|
||||
# AG: It looks like this issue is fixed by Freeze()ing and Thaw()ing the
|
||||
# main frame and not the notebook
|
||||
|
||||
# TODO List:
|
||||
# * UI design more prefessional
|
||||
# * UI design more professional (is the new version more professional?)
|
||||
# * save file positions (new field in demoModules) (@ LoadDemoSource)
|
||||
# * Update main overview
|
||||
|
||||
@@ -30,6 +32,7 @@
|
||||
import sys, os, time, traceback, types
|
||||
|
||||
import wx # This module uses the new wx namespace
|
||||
import wx.aui
|
||||
import wx.html
|
||||
|
||||
import images
|
||||
@@ -43,6 +46,15 @@ import images
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
USE_CUSTOMTREECTRL = False
|
||||
ALLOW_AUI_FLOATING = False
|
||||
DEFAULT_PERSPECTIVE = "Default Perspective"
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
_demoPngs = ["overview", "recent", "frame", "dialog", "moredialog", "core",
|
||||
"book", "customcontrol", "morecontrols", "layout", "process", "clipboard",
|
||||
"images", "miscellaneous"]
|
||||
|
||||
_treeList = [
|
||||
# new stuff
|
||||
@@ -631,7 +643,9 @@ class DemoCodePanel(wx.Panel):
|
||||
def ActiveModuleChanged(self):
|
||||
self.LoadDemoSource(self.demoModules.GetSource())
|
||||
self.UpdateControlState()
|
||||
self.mainFrame.Freeze()
|
||||
self.ReloadDemo()
|
||||
self.mainFrame.Thaw()
|
||||
|
||||
|
||||
def LoadDemoSource(self, source):
|
||||
@@ -726,24 +740,37 @@ class DemoCodePanel(wx.Panel):
|
||||
self.demoModules.LoadFromFile(modModified, modifiedFilename)
|
||||
self.ActiveModuleChanged()
|
||||
|
||||
self.mainFrame.SetTreeModified(True)
|
||||
|
||||
|
||||
def OnRestore(self, event): # Handles the "Delete Modified" button
|
||||
modifiedFilename = GetModifiedFilename(self.demoModules.name)
|
||||
self.demoModules.Delete(modModified)
|
||||
os.unlink(modifiedFilename) # Delete the modified copy
|
||||
busy = wx.BusyInfo("Reloading demo module...")
|
||||
|
||||
self.ActiveModuleChanged()
|
||||
|
||||
self.mainFrame.SetTreeModified(False)
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
def opj(path):
|
||||
"""Convert paths to the platform-specific separator"""
|
||||
str = apply(os.path.join, tuple(path.split('/')))
|
||||
st = apply(os.path.join, tuple(path.split('/')))
|
||||
# HACK: on Linux, a leading / gets lost...
|
||||
if path.startswith('/'):
|
||||
str = '/' + str
|
||||
return str
|
||||
st = '/' + st
|
||||
return st
|
||||
|
||||
|
||||
def GetDataDir():
|
||||
"""
|
||||
Return the standard location on this platform for application data
|
||||
"""
|
||||
sp = wx.StandardPaths.Get()
|
||||
return sp.GetUserDataDir()
|
||||
|
||||
|
||||
def GetModifiedDirectory():
|
||||
@@ -751,7 +778,7 @@ def GetModifiedDirectory():
|
||||
Returns the directory where modified versions of the demo files
|
||||
are stored
|
||||
"""
|
||||
return opj(wx.GetHomeDir() + "/.wxPyDemo/modified/")
|
||||
return os.path.join(GetDataDir(), "modified")
|
||||
|
||||
|
||||
def GetModifiedFilename(name):
|
||||
@@ -760,7 +787,7 @@ def GetModifiedFilename(name):
|
||||
"""
|
||||
if not name.endswith(".py"):
|
||||
name = name + ".py"
|
||||
return GetModifiedDirectory() + name
|
||||
return os.path.join(GetModifiedDirectory(), name)
|
||||
|
||||
|
||||
def GetOriginalFilename(name):
|
||||
@@ -780,6 +807,25 @@ def DoesModifiedExist(name):
|
||||
return False
|
||||
|
||||
|
||||
def GetConfig():
|
||||
if not os.path.exists(GetDataDir()):
|
||||
os.makedirs(GetDataDir())
|
||||
|
||||
config = wx.FileConfig(
|
||||
localFilename=os.path.join(GetDataDir(), "options"))
|
||||
return config
|
||||
|
||||
|
||||
def SearchDemo(name, keyword):
|
||||
""" Returns whether a demo contains the search keyword or not. """
|
||||
fid = open(GetOriginalFilename(name), "rt")
|
||||
fullText = fid.read()
|
||||
fid.close()
|
||||
if fullText.find(keyword) >= 0:
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
class ModuleDictWrapper:
|
||||
@@ -1132,10 +1178,13 @@ class wxPythonDemo(wx.Frame):
|
||||
overviewText = "wxPython Overview"
|
||||
|
||||
def __init__(self, parent, title):
|
||||
wx.Frame.__init__(self, parent, -1, title, size = (950, 720),
|
||||
wx.Frame.__init__(self, parent, -1, title, size = (970, 720),
|
||||
style=wx.DEFAULT_FRAME_STYLE | wx.NO_FULL_REPAINT_ON_RESIZE)
|
||||
|
||||
self.SetMinSize((640,480))
|
||||
|
||||
self.mgr = wx.aui.AuiManager()
|
||||
self.mgr.SetManagedWindow(self)
|
||||
|
||||
self.loaded = False
|
||||
self.cwd = os.getcwd()
|
||||
@@ -1154,8 +1203,6 @@ class wxPythonDemo(wx.Frame):
|
||||
except:
|
||||
self.tbicon = None
|
||||
|
||||
wx.CallAfter(self.ShowTip)
|
||||
|
||||
self.otherWin = None
|
||||
self.Bind(wx.EVT_IDLE, self.OnIdle)
|
||||
self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
|
||||
@@ -1165,119 +1212,67 @@ class wxPythonDemo(wx.Frame):
|
||||
self.Centre(wx.BOTH)
|
||||
self.CreateStatusBar(1, wx.ST_SIZEGRIP)
|
||||
|
||||
splitter = wx.SplitterWindow(self, -1, style=wx.CLIP_CHILDREN | wx.SP_LIVE_UPDATE | wx.SP_3D)
|
||||
splitter2 = wx.SplitterWindow(splitter, -1, style=wx.CLIP_CHILDREN | wx.SP_LIVE_UPDATE | wx.SP_3D)
|
||||
|
||||
def EmptyHandler(evt): pass
|
||||
#splitter.Bind(wx.EVT_ERASE_BACKGROUND, EmptyHandler)
|
||||
#splitter2.Bind(wx.EVT_ERASE_BACKGROUND, EmptyHandler)
|
||||
|
||||
# Prevent TreeCtrl from displaying all items after destruction when True
|
||||
self.dying = False
|
||||
self.skipLoad = False
|
||||
|
||||
def EmptyHandler(evt): pass
|
||||
|
||||
self.ReadConfigurationFile()
|
||||
|
||||
# Create a Notebook
|
||||
self.nb = wx.Notebook(splitter2, -1, style=wx.CLIP_CHILDREN)
|
||||
|
||||
# Make a File menu
|
||||
self.mainmenu = wx.MenuBar()
|
||||
menu = wx.Menu()
|
||||
item = menu.Append(-1, '&Redirect Output',
|
||||
'Redirect print statements to a window',
|
||||
wx.ITEM_CHECK)
|
||||
self.Bind(wx.EVT_MENU, self.OnToggleRedirect, item)
|
||||
|
||||
exitItem = menu.Append(-1, 'E&xit\tCtrl-Q', 'Get the heck outta here!')
|
||||
self.Bind(wx.EVT_MENU, self.OnFileExit, exitItem)
|
||||
wx.App.SetMacExitMenuItemId(exitItem.GetId())
|
||||
self.mainmenu.Append(menu, '&File')
|
||||
|
||||
# Make a Demo menu
|
||||
menu = wx.Menu()
|
||||
for item in _treeList[:-1]:
|
||||
submenu = wx.Menu()
|
||||
for childItem in item[1]:
|
||||
mi = submenu.Append(-1, childItem)
|
||||
self.Bind(wx.EVT_MENU, self.OnDemoMenu, mi)
|
||||
menu.AppendMenu(wx.NewId(), item[0], submenu)
|
||||
self.mainmenu.Append(menu, '&Demo')
|
||||
|
||||
|
||||
# Make a Help menu
|
||||
menu = wx.Menu()
|
||||
findItem = menu.Append(-1, '&Find\tCtrl-F', 'Find in the Demo Code')
|
||||
findnextItem = menu.Append(-1, 'Find &Next\tF3', 'Find Next')
|
||||
menu.AppendSeparator()
|
||||
|
||||
shellItem = menu.Append(-1, 'Open Py&Shell Window\tF5',
|
||||
'An interactive interpreter window with the demo app and frame objects in the namesapce')
|
||||
inspToolItem = menu.Append(-1, 'Open &Widget Inspector\tF6',
|
||||
'A tool that lets you browse the live widgets and sizers in an application')
|
||||
menu.AppendSeparator()
|
||||
helpItem = menu.Append(-1, '&About wxPython Demo', 'wxPython RULES!!!')
|
||||
wx.App.SetMacAboutMenuItemId(helpItem.GetId())
|
||||
|
||||
self.Bind(wx.EVT_MENU, self.OnOpenShellWindow, shellItem)
|
||||
self.Bind(wx.EVT_MENU, self.OnOpenWidgetInspector, inspToolItem)
|
||||
self.Bind(wx.EVT_MENU, self.OnHelpAbout, helpItem)
|
||||
self.Bind(wx.EVT_MENU, self.OnHelpFind, findItem)
|
||||
self.Bind(wx.EVT_MENU, self.OnFindNext, findnextItem)
|
||||
self.Bind(wx.EVT_FIND, self.OnFind)
|
||||
self.Bind(wx.EVT_FIND_NEXT, self.OnFind)
|
||||
self.Bind(wx.EVT_FIND_CLOSE, self.OnFindClose)
|
||||
self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateFindItems, findItem)
|
||||
self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateFindItems, findnextItem)
|
||||
self.mainmenu.Append(menu, '&Help')
|
||||
self.SetMenuBar(self.mainmenu)
|
||||
self.nb = wx.Notebook(self, -1, style=wx.CLIP_CHILDREN)
|
||||
imgList = wx.ImageList(16, 16)
|
||||
for png in ["overview", "code", "demo"]:
|
||||
bmp = images.catalog[png].getBitmap()
|
||||
imgList.Add(bmp)
|
||||
self.nb.AssignImageList(imgList)
|
||||
|
||||
self.BuildMenuBar()
|
||||
|
||||
self.finddata = wx.FindReplaceData()
|
||||
self.finddata.SetFlags(wx.FR_DOWN)
|
||||
|
||||
if False:
|
||||
# This is another way to set Accelerators, in addition to
|
||||
# using the '\t<key>' syntax in the menu items.
|
||||
aTable = wx.AcceleratorTable([(wx.ACCEL_ALT, ord('X'), exitItem.GetId()),
|
||||
(wx.ACCEL_CTRL, ord('H'), helpItem.GetId()),
|
||||
(wx.ACCEL_CTRL, ord('F'), findItem.GetId()),
|
||||
(wx.ACCEL_NORMAL, wx.WXK_F3, findnextItem.GetId()),
|
||||
(wx.ACCEL_NORMAL, wx.WXK_F9, shellItem.GetId()),
|
||||
])
|
||||
self.SetAcceleratorTable(aTable)
|
||||
|
||||
|
||||
# Create a TreeCtrl
|
||||
tID = wx.NewId()
|
||||
leftPanel = wx.Panel(splitter)
|
||||
leftPanel = wx.Panel(self, style=wx.TAB_TRAVERSAL|wx.CLIP_CHILDREN)
|
||||
self.treeMap = {}
|
||||
self.searchItems = {}
|
||||
|
||||
self.filter = wx.SearchCtrl(leftPanel)
|
||||
self.tree = wxPythonDemoTree(leftPanel)
|
||||
|
||||
self.filter = wx.SearchCtrl(leftPanel, style=wx.TE_PROCESS_ENTER)
|
||||
self.filter.ShowCancelButton(True)
|
||||
self.filter.Bind(wx.EVT_TEXT, self.RecreateTree)
|
||||
self.filter.Bind(wx.EVT_SEARCHCTRL_CANCEL_BTN,
|
||||
lambda e: self.filter.SetValue(''))
|
||||
|
||||
self.treeMap = {}
|
||||
self.tree = wx.TreeCtrl(leftPanel, tID, style =
|
||||
wx.TR_DEFAULT_STYLE #| wx.TR_HAS_VARIABLE_ROW_HEIGHT
|
||||
)
|
||||
self.filter.Bind(wx.EVT_TEXT_ENTER, self.OnSearch)
|
||||
|
||||
searchMenu = wx.Menu()
|
||||
item = searchMenu.AppendRadioItem(-1, "Sample Name")
|
||||
self.Bind(wx.EVT_MENU, self.OnSearchMenu, item)
|
||||
item = searchMenu.AppendRadioItem(-1, "Sample Content")
|
||||
self.Bind(wx.EVT_MENU, self.OnSearchMenu, item)
|
||||
self.filter.SetMenu(searchMenu)
|
||||
|
||||
self.root = self.tree.AddRoot("wxPython Overview")
|
||||
self.RecreateTree()
|
||||
self.tree.Bind(wx.EVT_TREE_ITEM_EXPANDED, self.OnItemExpanded, id=tID)
|
||||
self.tree.Bind(wx.EVT_TREE_ITEM_COLLAPSED, self.OnItemCollapsed, id=tID)
|
||||
self.tree.Bind(wx.EVT_TREE_SEL_CHANGED, self.OnSelChanged, id=tID)
|
||||
self.tree.SetExpansionState(self.expansionState)
|
||||
self.tree.Bind(wx.EVT_TREE_ITEM_EXPANDED, self.OnItemExpanded)
|
||||
self.tree.Bind(wx.EVT_TREE_ITEM_COLLAPSED, self.OnItemCollapsed)
|
||||
self.tree.Bind(wx.EVT_TREE_SEL_CHANGED, self.OnSelChanged)
|
||||
self.tree.Bind(wx.EVT_LEFT_DOWN, self.OnTreeLeftDown)
|
||||
|
||||
# Set up a wx.html.HtmlWindow on the Overview Notebook page
|
||||
# we put it in a panel first because there seems to be a
|
||||
# refresh bug of some sort (wxGTK) when it is directly in
|
||||
# the notebook...
|
||||
|
||||
if 0: # the old way
|
||||
self.ovr = wx.html.HtmlWindow(self.nb, -1, size=(400, 400))
|
||||
self.nb.AddPage(self.ovr, self.overviewText)
|
||||
self.nb.AddPage(self.ovr, self.overviewText, imageId=0)
|
||||
|
||||
else: # hopefully I can remove this hacky code soon, see SF bug #216861
|
||||
panel = wx.Panel(self.nb, -1, style=wx.CLIP_CHILDREN)
|
||||
self.ovr = wx.html.HtmlWindow(panel, -1, size=(400, 400))
|
||||
self.nb.AddPage(panel, self.overviewText)
|
||||
self.nb.AddPage(panel, self.overviewText, imageId=0)
|
||||
|
||||
def OnOvrSize(evt, ovr=self.ovr):
|
||||
ovr.SetSize(evt.GetSize())
|
||||
@@ -1290,7 +1285,7 @@ class wxPythonDemo(wx.Frame):
|
||||
|
||||
|
||||
# Set up a log window
|
||||
self.log = wx.TextCtrl(splitter2, -1,
|
||||
self.log = wx.TextCtrl(self, -1,
|
||||
style = wx.TE_MULTILINE|wx.TE_READONLY|wx.HSCROLL)
|
||||
if wx.Platform == "__WXMAC__":
|
||||
self.log.MacCheckSpelling(False)
|
||||
@@ -1305,30 +1300,15 @@ class wxPythonDemo(wx.Frame):
|
||||
#wx.Log_SetActiveTarget(wx.LogStderr())
|
||||
#wx.Log_SetTraceMask(wx.TraceMessages)
|
||||
|
||||
|
||||
self.Bind(wx.EVT_ACTIVATE, self.OnActivate)
|
||||
wx.GetApp().Bind(wx.EVT_ACTIVATE_APP, self.OnAppActivate)
|
||||
|
||||
# add the windows to the splitter and split it.
|
||||
splitter2.SplitHorizontally(self.nb, self.log, -160)
|
||||
leftBox = wx.BoxSizer(wx.VERTICAL)
|
||||
leftBox.Add(self.tree, 1, wx.EXPAND)
|
||||
leftBox.Add(wx.StaticText(leftPanel, label = "Filter Demos:"), 0, wx.TOP|wx.LEFT, 5)
|
||||
leftBox.Add(self.filter, 0, wx.EXPAND|wx.ALL, 5)
|
||||
leftPanel.SetSizer(leftBox)
|
||||
splitter.SplitVertically(leftPanel, splitter2, 220)
|
||||
|
||||
splitter.SetMinimumPaneSize(120)
|
||||
splitter2.SetMinimumPaneSize(60)
|
||||
|
||||
# Make the splitter on the right expand the top window when resized
|
||||
def SplitterOnSize(evt):
|
||||
splitter = evt.GetEventObject()
|
||||
sz = splitter.GetSize()
|
||||
splitter.SetSashPosition(sz.height - 160, False)
|
||||
evt.Skip()
|
||||
|
||||
splitter2.Bind(wx.EVT_SIZE, SplitterOnSize)
|
||||
|
||||
# select initial items
|
||||
self.nb.SetSelection(0)
|
||||
@@ -1348,32 +1328,289 @@ class wxPythonDemo(wx.Frame):
|
||||
self.tree.SelectItem(selectedDemo)
|
||||
self.tree.EnsureVisible(selectedDemo)
|
||||
|
||||
# Use the aui manager to set up everything
|
||||
self.mgr.AddPane(self.nb, wx.aui.AuiPaneInfo().CenterPane().Name("Notebook"))
|
||||
self.mgr.AddPane(leftPanel,
|
||||
wx.aui.AuiPaneInfo().
|
||||
Left().Layer(2).BestSize((240, -1)).
|
||||
MinSize((160, -1)).
|
||||
Floatable(ALLOW_AUI_FLOATING).FloatingSize((240, 700)).
|
||||
Caption("wxPython Demos").
|
||||
CloseButton(False).
|
||||
Name("DemoTree"))
|
||||
self.mgr.AddPane(self.log,
|
||||
wx.aui.AuiPaneInfo().
|
||||
Bottom().BestSize((-1, 150)).
|
||||
MinSize((-1, 60)).
|
||||
Floatable(ALLOW_AUI_FLOATING).FloatingSize((500, 160)).
|
||||
Caption("Demo Log Messages").
|
||||
CloseButton(False).
|
||||
Name("LogWindow"))
|
||||
|
||||
#---------------------------------------------
|
||||
|
||||
self.auiConfigurations[DEFAULT_PERSPECTIVE] = self.mgr.SavePerspective()
|
||||
self.mgr.Update()
|
||||
|
||||
self.mgr.SetFlags(self.mgr.GetFlags() ^ wx.aui.AUI_MGR_TRANSPARENT_DRAG)
|
||||
|
||||
|
||||
|
||||
def ReadConfigurationFile(self):
|
||||
|
||||
self.auiConfigurations = {}
|
||||
self.expansionState = [0, 1]
|
||||
|
||||
config = GetConfig()
|
||||
val = config.Read('ExpansionState')
|
||||
if val:
|
||||
self.expansionState = eval(val)
|
||||
|
||||
val = config.Read('AUIPerspectives')
|
||||
if val:
|
||||
self.auiConfigurations = eval(val)
|
||||
|
||||
|
||||
def BuildMenuBar(self):
|
||||
|
||||
# Make a File menu
|
||||
self.mainmenu = wx.MenuBar()
|
||||
menu = wx.Menu()
|
||||
item = menu.Append(-1, '&Redirect Output',
|
||||
'Redirect print statements to a window',
|
||||
wx.ITEM_CHECK)
|
||||
self.Bind(wx.EVT_MENU, self.OnToggleRedirect, item)
|
||||
|
||||
exitItem = wx.MenuItem(menu, -1, 'E&xit\tCtrl-Q', 'Get the heck outta here!')
|
||||
exitItem.SetBitmap(images.catalog['exit'].getBitmap())
|
||||
menu.AppendItem(exitItem)
|
||||
self.Bind(wx.EVT_MENU, self.OnFileExit, exitItem)
|
||||
wx.App.SetMacExitMenuItemId(exitItem.GetId())
|
||||
self.mainmenu.Append(menu, '&File')
|
||||
|
||||
# Make a Demo menu
|
||||
menu = wx.Menu()
|
||||
for indx, item in enumerate(_treeList[:-1]):
|
||||
menuItem = wx.MenuItem(menu, -1, item[0])
|
||||
submenu = wx.Menu()
|
||||
for childItem in item[1]:
|
||||
mi = submenu.Append(-1, childItem)
|
||||
self.Bind(wx.EVT_MENU, self.OnDemoMenu, mi)
|
||||
menuItem.SetBitmap(images.catalog[_demoPngs[indx+1]].getBitmap())
|
||||
menuItem.SetSubMenu(submenu)
|
||||
menu.AppendItem(menuItem)
|
||||
self.mainmenu.Append(menu, '&Demo')
|
||||
|
||||
# Make an Option menu
|
||||
# If we've turned off floatable panels then this menu is not needed
|
||||
if ALLOW_AUI_FLOATING:
|
||||
menu = wx.Menu()
|
||||
auiPerspectives = self.auiConfigurations.keys()
|
||||
auiPerspectives.sort()
|
||||
perspectivesMenu = wx.Menu()
|
||||
item = wx.MenuItem(perspectivesMenu, -1, DEFAULT_PERSPECTIVE, "Load startup default perspective", wx.ITEM_RADIO)
|
||||
self.Bind(wx.EVT_MENU, self.OnAUIPerspectives, item)
|
||||
perspectivesMenu.AppendItem(item)
|
||||
for indx, key in enumerate(auiPerspectives):
|
||||
if key == DEFAULT_PERSPECTIVE:
|
||||
continue
|
||||
item = wx.MenuItem(perspectivesMenu, -1, key, "Load user perspective %d"%indx, wx.ITEM_RADIO)
|
||||
perspectivesMenu.AppendItem(item)
|
||||
self.Bind(wx.EVT_MENU, self.OnAUIPerspectives, item)
|
||||
|
||||
menu.AppendMenu(wx.ID_ANY, "&AUI Perspectives", perspectivesMenu)
|
||||
self.perspectives_menu = perspectivesMenu
|
||||
|
||||
item = wx.MenuItem(menu, -1, 'Save Perspective', 'Save AUI perspective')
|
||||
item.SetBitmap(images.catalog['saveperspective'].getBitmap())
|
||||
menu.AppendItem(item)
|
||||
self.Bind(wx.EVT_MENU, self.OnSavePerspective, item)
|
||||
|
||||
item = wx.MenuItem(menu, -1, 'Delete Perspective', 'Delete AUI perspective')
|
||||
item.SetBitmap(images.catalog['deleteperspective'].getBitmap())
|
||||
menu.AppendItem(item)
|
||||
self.Bind(wx.EVT_MENU, self.OnDeletePerspective, item)
|
||||
|
||||
menu.AppendSeparator()
|
||||
|
||||
item = wx.MenuItem(menu, -1, 'Restore Tree Expansion', 'Restore the initial tree expansion state')
|
||||
item.SetBitmap(images.catalog['expansion'].getBitmap())
|
||||
menu.AppendItem(item)
|
||||
self.Bind(wx.EVT_MENU, self.OnTreeExpansion, item)
|
||||
|
||||
self.mainmenu.Append(menu, '&Options')
|
||||
|
||||
# Make a Help menu
|
||||
menu = wx.Menu()
|
||||
findItem = wx.MenuItem(menu, -1, '&Find\tCtrl-F', 'Find in the Demo Code')
|
||||
findItem.SetBitmap(images.catalog['find'].getBitmap())
|
||||
findNextItem = wx.MenuItem(menu, -1, 'Find &Next\tF3', 'Find Next')
|
||||
findNextItem.SetBitmap(images.catalog['findnext'].getBitmap())
|
||||
menu.AppendItem(findItem)
|
||||
menu.AppendItem(findNextItem)
|
||||
menu.AppendSeparator()
|
||||
|
||||
shellItem = wx.MenuItem(menu, -1, 'Open Py&Shell Window\tF5',
|
||||
'An interactive interpreter window with the demo app and frame objects in the namesapce')
|
||||
shellItem.SetBitmap(images.catalog['pyshell'].getBitmap())
|
||||
menu.AppendItem(shellItem)
|
||||
inspToolItem = wx.MenuItem(menu, -1, 'Open &Widget Inspector\tF6',
|
||||
'A tool that lets you browse the live widgets and sizers in an application')
|
||||
inspToolItem.SetBitmap(images.catalog['inspect'].getBitmap())
|
||||
menu.AppendItem(inspToolItem)
|
||||
menu.AppendSeparator()
|
||||
helpItem = menu.Append(-1, '&About wxPython Demo', 'wxPython RULES!!!')
|
||||
wx.App.SetMacAboutMenuItemId(helpItem.GetId())
|
||||
|
||||
self.Bind(wx.EVT_MENU, self.OnOpenShellWindow, shellItem)
|
||||
self.Bind(wx.EVT_MENU, self.OnOpenWidgetInspector, inspToolItem)
|
||||
self.Bind(wx.EVT_MENU, self.OnHelpAbout, helpItem)
|
||||
self.Bind(wx.EVT_MENU, self.OnHelpFind, findItem)
|
||||
self.Bind(wx.EVT_MENU, self.OnFindNext, findNextItem)
|
||||
self.Bind(wx.EVT_FIND, self.OnFind)
|
||||
self.Bind(wx.EVT_FIND_NEXT, self.OnFind)
|
||||
self.Bind(wx.EVT_FIND_CLOSE, self.OnFindClose)
|
||||
self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateFindItems, findItem)
|
||||
self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateFindItems, findNextItem)
|
||||
self.mainmenu.Append(menu, '&Help')
|
||||
self.SetMenuBar(self.mainmenu)
|
||||
|
||||
if False:
|
||||
# This is another way to set Accelerators, in addition to
|
||||
# using the '\t<key>' syntax in the menu items.
|
||||
aTable = wx.AcceleratorTable([(wx.ACCEL_ALT, ord('X'), exitItem.GetId()),
|
||||
(wx.ACCEL_CTRL, ord('H'), helpItem.GetId()),
|
||||
(wx.ACCEL_CTRL, ord('F'), findItem.GetId()),
|
||||
(wx.ACCEL_NORMAL, wx.WXK_F3, findnextItem.GetId()),
|
||||
(wx.ACCEL_NORMAL, wx.WXK_F9, shellItem.GetId()),
|
||||
])
|
||||
self.SetAcceleratorTable(aTable)
|
||||
|
||||
|
||||
#---------------------------------------------
|
||||
def RecreateTree(self, evt=None):
|
||||
# Catch the search type (name or content)
|
||||
searchMenu = self.filter.GetMenu().GetMenuItems()
|
||||
fullSearch = searchMenu[1].IsChecked()
|
||||
|
||||
if evt:
|
||||
if fullSearch:
|
||||
# Do not`scan all the demo files for every char
|
||||
# the user input, use wx.EVT_TEXT_ENTER instead
|
||||
return
|
||||
|
||||
expansionState = self.tree.GetExpansionState()
|
||||
|
||||
current = None
|
||||
item = self.tree.GetSelection()
|
||||
if item:
|
||||
prnt = self.tree.GetItemParent(item)
|
||||
if prnt:
|
||||
current = (self.tree.GetItemText(item),
|
||||
self.tree.GetItemText(prnt))
|
||||
|
||||
self.tree.Freeze()
|
||||
self.tree.DeleteAllItems()
|
||||
self.root = self.tree.AddRoot("wxPython Overview")
|
||||
self.tree.SetItemImage(self.root, 0)
|
||||
self.tree.SetItemPyData(self.root, 0)
|
||||
|
||||
treeFont = self.tree.GetFont()
|
||||
catFont = self.tree.GetFont()
|
||||
|
||||
# The old native treectrl on MSW has a bug where it doesn't
|
||||
# draw all of the text for an item if the font is larger than
|
||||
# the default. It seems to be clipping the item's label as if
|
||||
# it was the size of the same label in the default font.
|
||||
if 'wxMSW' not in wx.PlatformInfo or wx.GetApp().GetComCtl32Version() >= 600:
|
||||
treeFont.SetPointSize(treeFont.GetPointSize()+2)
|
||||
treeFont.SetWeight(wx.BOLD)
|
||||
catFont.SetWeight(wx.BOLD)
|
||||
|
||||
self.tree.SetItemFont(self.root, treeFont)
|
||||
|
||||
firstChild = None
|
||||
selectItem = None
|
||||
filter = self.filter.GetValue()
|
||||
count = 0
|
||||
|
||||
for category, items in _treeList:
|
||||
count += 1
|
||||
if filter:
|
||||
items = [item for item in items if filter.lower() in item.lower()]
|
||||
if fullSearch:
|
||||
items = self.searchItems[category]
|
||||
else:
|
||||
items = [item for item in items if filter.lower() in item.lower()]
|
||||
if items:
|
||||
child = self.tree.AppendItem(self.root, category)
|
||||
child = self.tree.AppendItem(self.root, category, image=count)
|
||||
self.tree.SetItemFont(child, catFont)
|
||||
self.tree.SetItemPyData(child, count)
|
||||
if not firstChild: firstChild = child
|
||||
for childItem in items:
|
||||
theDemo = self.tree.AppendItem(child, childItem)
|
||||
image = count
|
||||
if DoesModifiedExist(childItem):
|
||||
image = len(_demoPngs)
|
||||
theDemo = self.tree.AppendItem(child, childItem, image=image)
|
||||
self.tree.SetItemPyData(theDemo, count)
|
||||
self.treeMap[childItem] = theDemo
|
||||
|
||||
if current and (childItem, category) == current:
|
||||
selectItem = theDemo
|
||||
|
||||
|
||||
self.tree.Expand(self.root)
|
||||
if firstChild:
|
||||
self.tree.Expand(firstChild)
|
||||
if filter:
|
||||
self.tree.ExpandAll()
|
||||
elif expansionState:
|
||||
self.tree.SetExpansionState(expansionState)
|
||||
if selectItem:
|
||||
self.skipLoad = True
|
||||
self.tree.SelectItem(selectItem)
|
||||
self.skipLoad = False
|
||||
|
||||
self.tree.Thaw()
|
||||
|
||||
self.searchItems = {}
|
||||
|
||||
|
||||
def OnSearchMenu(self, event):
|
||||
|
||||
# Catch the search type (name or content)
|
||||
searchMenu = self.filter.GetMenu().GetMenuItems()
|
||||
fullSearch = searchMenu[1].IsChecked()
|
||||
|
||||
if fullSearch:
|
||||
self.OnSearch()
|
||||
else:
|
||||
self.RecreateTree()
|
||||
|
||||
|
||||
def OnSearch(self, event=None):
|
||||
|
||||
value = self.filter.GetValue()
|
||||
if not value:
|
||||
self.RecreateTree()
|
||||
return
|
||||
|
||||
wx.BeginBusyCursor()
|
||||
|
||||
for category, items in _treeList:
|
||||
self.searchItems[category] = []
|
||||
for childItem in items:
|
||||
if SearchDemo(childItem, value):
|
||||
self.searchItems[category].append(childItem)
|
||||
|
||||
wx.EndBusyCursor()
|
||||
self.RecreateTree()
|
||||
|
||||
|
||||
def SetTreeModified(self, modified):
|
||||
item = self.tree.GetSelection()
|
||||
if modified:
|
||||
image = len(_demoPngs)
|
||||
else:
|
||||
image = self.tree.GetItemPyData(item)
|
||||
self.tree.SetItemImage(item, image)
|
||||
|
||||
|
||||
def WriteText(self, text):
|
||||
if text[-1:] == '\n':
|
||||
text = text[:-1]
|
||||
@@ -1405,7 +1642,7 @@ class wxPythonDemo(wx.Frame):
|
||||
|
||||
#---------------------------------------------
|
||||
def OnSelChanged(self, event):
|
||||
if self.dying or not self.loaded:
|
||||
if self.dying or not self.loaded or self.skipLoad:
|
||||
return
|
||||
|
||||
item = event.GetItem()
|
||||
@@ -1416,6 +1653,7 @@ class wxPythonDemo(wx.Frame):
|
||||
def LoadDemo(self, demoName):
|
||||
try:
|
||||
wx.BeginBusyCursor()
|
||||
self.Freeze()
|
||||
|
||||
os.chdir(self.cwd)
|
||||
self.ShutdownDemoModule()
|
||||
@@ -1433,13 +1671,13 @@ class wxPythonDemo(wx.Frame):
|
||||
wx.LogMessage("Loading demo %s.py..." % demoName)
|
||||
self.demoModules = DemoModules(demoName)
|
||||
self.LoadDemoSource()
|
||||
self.tree.Refresh()
|
||||
else:
|
||||
self.SetOverview("wxPython", mainOverview)
|
||||
self.codePage = None
|
||||
self.UpdateNotebook(0)
|
||||
finally:
|
||||
wx.EndBusyCursor()
|
||||
self.Thaw()
|
||||
|
||||
#---------------------------------------------
|
||||
def LoadDemoSource(self):
|
||||
@@ -1470,6 +1708,10 @@ class wxPythonDemo(wx.Frame):
|
||||
self.demoPage = DemoErrorPanel(self.nb, self.codePage,
|
||||
DemoError(sys.exc_info()), self)
|
||||
|
||||
bg = self.nb.GetThemeBackgroundColour()
|
||||
if bg:
|
||||
self.demoPage.SetBackgroundColour(bg)
|
||||
|
||||
assert self.demoPage is not None, "runTest must return a window!"
|
||||
|
||||
else:
|
||||
@@ -1480,7 +1722,7 @@ class wxPythonDemo(wx.Frame):
|
||||
self.SetOverview(self.demoModules.name + " Overview", overviewText)
|
||||
|
||||
if self.firstTime:
|
||||
# cahnge to the demo page the first time a module is run
|
||||
# change to the demo page the first time a module is run
|
||||
self.UpdateNotebook(2)
|
||||
self.firstTime = False
|
||||
else:
|
||||
@@ -1500,6 +1742,7 @@ class wxPythonDemo(wx.Frame):
|
||||
def UpdateNotebook(self, select = -1):
|
||||
nb = self.nb
|
||||
debug = False
|
||||
self.Freeze()
|
||||
|
||||
def UpdatePage(page, pageText):
|
||||
pageExists = False
|
||||
@@ -1513,15 +1756,13 @@ class wxPythonDemo(wx.Frame):
|
||||
if page:
|
||||
if not pageExists:
|
||||
# Add a new page
|
||||
nb.AddPage(page, pageText)
|
||||
nb.AddPage(page, pageText, imageId=nb.GetPageCount())
|
||||
if debug: wx.LogMessage("DBG: ADDED %s" % pageText)
|
||||
else:
|
||||
if nb.GetPage(pagePos) != page:
|
||||
# Reload an existing page
|
||||
nb.Freeze()
|
||||
nb.DeletePage(pagePos)
|
||||
nb.InsertPage(pagePos, page, pageText)
|
||||
nb.Thaw()
|
||||
nb.InsertPage(pagePos, page, pageText, imageId=pagePos)
|
||||
if debug: wx.LogMessage("DBG: RELOADED %s" % pageText)
|
||||
else:
|
||||
# Excellent! No redraw/flicker
|
||||
@@ -1541,7 +1782,9 @@ class wxPythonDemo(wx.Frame):
|
||||
|
||||
if select >= 0 and select < nb.GetPageCount():
|
||||
nb.SetSelection(select)
|
||||
|
||||
|
||||
self.Thaw()
|
||||
|
||||
#---------------------------------------------
|
||||
def SetOverview(self, name, text):
|
||||
self.curOverview = text
|
||||
@@ -1566,6 +1809,70 @@ class wxPythonDemo(wx.Frame):
|
||||
else:
|
||||
app.RestoreStdio()
|
||||
print "Print statements and other standard output will now be sent to the usual location."
|
||||
|
||||
|
||||
def OnAUIPerspectives(self, event):
|
||||
perspective = self.perspectives_menu.GetLabel(event.GetId())
|
||||
self.mgr.LoadPerspective(self.auiConfigurations[perspective])
|
||||
self.mgr.Update()
|
||||
|
||||
|
||||
def OnSavePerspective(self, event):
|
||||
dlg = wx.TextEntryDialog(self, "Enter a name for the new perspective:", "AUI Configuration")
|
||||
|
||||
dlg.SetValue(("Perspective %d")%(len(self.auiConfigurations)+1))
|
||||
if dlg.ShowModal() != wx.ID_OK:
|
||||
return
|
||||
|
||||
perspectiveName = dlg.GetValue()
|
||||
menuItems = self.perspectives_menu.GetMenuItems()
|
||||
for item in menuItems:
|
||||
if item.GetLabel() == perspectiveName:
|
||||
wx.MessageBox("The selected perspective name:\n\n%s\n\nAlready exists."%perspectiveName,
|
||||
"Error", style=wx.ICON_ERROR)
|
||||
return
|
||||
|
||||
item = wx.MenuItem(self.perspectives_menu, -1, dlg.GetValue(),
|
||||
"Load user perspective %d"%(len(self.auiConfigurations)+1),
|
||||
wx.ITEM_RADIO)
|
||||
self.Bind(wx.EVT_MENU, self.OnAUIPerspectives, item)
|
||||
self.perspectives_menu.AppendItem(item)
|
||||
item.Check(True)
|
||||
self.auiConfigurations.update({dlg.GetValue(): self.mgr.SavePerspective()})
|
||||
|
||||
|
||||
def OnDeletePerspective(self, event):
|
||||
menuItems = self.perspectives_menu.GetMenuItems()[1:]
|
||||
lst = []
|
||||
loadDefault = False
|
||||
|
||||
for item in menuItems:
|
||||
lst.append(item.GetLabel())
|
||||
|
||||
dlg = wx.MultiChoiceDialog(self,
|
||||
"Please select the perspectives\nyou would like to delete:",
|
||||
"Delete AUI Perspectives", lst)
|
||||
|
||||
if dlg.ShowModal() == wx.ID_OK:
|
||||
selections = dlg.GetSelections()
|
||||
strings = [lst[x] for x in selections]
|
||||
for sel in strings:
|
||||
self.auiConfigurations.pop(sel)
|
||||
item = menuItems[lst.index(sel)]
|
||||
if item.IsChecked():
|
||||
loadDefault = True
|
||||
self.perspectives_menu.GetMenuItems()[0].Check(True)
|
||||
self.perspectives_menu.DeleteItem(item)
|
||||
lst.remove(sel)
|
||||
|
||||
if loadDefault:
|
||||
self.mgr.LoadPerspective(self.auiConfigurations[DEFAULT_PERSPECTIVE])
|
||||
self.mgr.Update()
|
||||
|
||||
|
||||
def OnTreeExpansion(self, event):
|
||||
self.tree.SetExpansionState(self.expansionState)
|
||||
|
||||
|
||||
def OnHelpAbout(self, event):
|
||||
from About import MyAboutBox
|
||||
@@ -1686,6 +1993,12 @@ class wxPythonDemo(wx.Frame):
|
||||
self.mainmenu = None
|
||||
if self.tbicon is not None:
|
||||
self.tbicon.Destroy()
|
||||
|
||||
config = GetConfig()
|
||||
config.Write('ExpansionState', str(self.tree.GetExpansionState()))
|
||||
config.Write('AUIPerspectives', str(self.auiConfigurations))
|
||||
config.Flush()
|
||||
|
||||
self.Destroy()
|
||||
|
||||
|
||||
@@ -1699,18 +2012,20 @@ class wxPythonDemo(wx.Frame):
|
||||
|
||||
#---------------------------------------------
|
||||
def ShowTip(self):
|
||||
try:
|
||||
showTipText = open(opj("data/showTips")).read()
|
||||
config = GetConfig()
|
||||
showTipText = config.Read("tips")
|
||||
if showTipText:
|
||||
showTip, index = eval(showTipText)
|
||||
except IOError:
|
||||
else:
|
||||
showTip, index = (1, 0)
|
||||
|
||||
if showTip:
|
||||
tp = wx.CreateFileTipProvider(opj("data/tips.txt"), index)
|
||||
##tp = MyTP(0)
|
||||
showTip = wx.ShowTip(self, tp)
|
||||
index = tp.GetCurrentTip()
|
||||
open(opj("data/showTips"), "w").write(str( (showTip, index) ))
|
||||
|
||||
config.Write("tips", str( (showTip, index) ))
|
||||
config.Flush()
|
||||
|
||||
#---------------------------------------------
|
||||
def OnDemoMenu(self, event):
|
||||
@@ -1775,8 +2090,54 @@ class MySplashScreen(wx.SplashScreen):
|
||||
frame.Show()
|
||||
if self.fc.IsRunning():
|
||||
self.Raise()
|
||||
wx.CallAfter(frame.ShowTip)
|
||||
|
||||
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
from wx.lib.mixins.treemixin import ExpansionState
|
||||
if USE_CUSTOMTREECTRL:
|
||||
import wx.lib.customtreectrl as CT
|
||||
TreeBaseClass = CT.CustomTreeCtrl
|
||||
else:
|
||||
TreeBaseClass = wx.TreeCtrl
|
||||
|
||||
|
||||
class wxPythonDemoTree(ExpansionState, TreeBaseClass):
|
||||
def __init__(self, parent):
|
||||
TreeBaseClass.__init__(self, parent, style=wx.TR_DEFAULT_STYLE|
|
||||
wx.TR_HAS_VARIABLE_ROW_HEIGHT)
|
||||
self.BuildTreeImageList()
|
||||
if USE_CUSTOMTREECTRL:
|
||||
self.SetSpacing(10)
|
||||
self.SetWindowStyle(self.GetWindowStyle() & ~wx.TR_LINES_AT_ROOT)
|
||||
|
||||
def AppendItem(self, parent, text, image=-1, wnd=None):
|
||||
if USE_CUSTOMTREECTRL:
|
||||
item = TreeBaseClass.AppendItem(self, parent, text, image=image, wnd=wnd)
|
||||
else:
|
||||
item = TreeBaseClass.AppendItem(self, parent, text, image=image)
|
||||
return item
|
||||
|
||||
def BuildTreeImageList(self):
|
||||
imgList = wx.ImageList(16, 16)
|
||||
for png in _demoPngs:
|
||||
imgList.Add(images.catalog[png].getBitmap())
|
||||
|
||||
# add the image for modified demos.
|
||||
imgList.Add(images.catalog["custom"].getBitmap())
|
||||
|
||||
self.AssignImageList(imgList)
|
||||
|
||||
|
||||
def GetItemIdentity(self, item):
|
||||
return self.GetPyData(item)
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
class MyApp(wx.App):
|
||||
def OnInit(self):
|
||||
"""
|
||||
@@ -1785,7 +2146,8 @@ class MyApp(wx.App):
|
||||
"""
|
||||
|
||||
wx.SystemOptions.SetOptionInt("mac.window-plain-transition", 1)
|
||||
|
||||
self.SetAppName("wxPyDemo")
|
||||
|
||||
# For debugging
|
||||
#self.SetAssertMode(wx.PYAPP_ASSERT_DIALOG)
|
||||
|
||||
|
@@ -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():
|
||||
|
@@ -211,7 +211,8 @@ class MyEvtHandler(ogl.ShapeEvtHandler):
|
||||
|
||||
if shape.Selected():
|
||||
shape.Select(False, dc)
|
||||
canvas.Redraw(dc)
|
||||
#canvas.Redraw(dc)
|
||||
canvas.Refresh(False)
|
||||
else:
|
||||
redraw = False
|
||||
shapeList = canvas.GetDiagram().GetShapeList()
|
||||
@@ -230,7 +231,8 @@ class MyEvtHandler(ogl.ShapeEvtHandler):
|
||||
for s in toUnselect:
|
||||
s.Select(False, dc)
|
||||
|
||||
canvas.Redraw(dc)
|
||||
##canvas.Redraw(dc)
|
||||
canvas.Refresh(False)
|
||||
|
||||
self.UpdateStatusBar(shape)
|
||||
|
||||
@@ -251,9 +253,11 @@ class MyEvtHandler(ogl.ShapeEvtHandler):
|
||||
|
||||
|
||||
def OnMovePost(self, dc, x, y, oldX, oldY, display):
|
||||
shape = self.GetShape()
|
||||
ogl.ShapeEvtHandler.OnMovePost(self, dc, x, y, oldX, oldY, display)
|
||||
self.UpdateStatusBar(self.GetShape())
|
||||
|
||||
self.UpdateStatusBar(shape)
|
||||
if "wxMac" in wx.PlatformInfo:
|
||||
shape.GetCanvas().Refresh(False)
|
||||
|
||||
def OnRightClick(self, *dontcare):
|
||||
self.log.WriteText("%s\n" % self.GetShape())
|
||||
@@ -334,8 +338,8 @@ class TestWindow(ogl.ShapeCanvas):
|
||||
s.SetBitmap(bmp)
|
||||
self.MyAddShape(s, 225, 130, None, None, "Bitmap")
|
||||
|
||||
dc = wx.ClientDC(self)
|
||||
self.PrepareDC(dc)
|
||||
#dc = wx.ClientDC(self)
|
||||
#self.PrepareDC(dc)
|
||||
|
||||
for x in range(len(self.shapes)):
|
||||
fromShape = self.shapes[x]
|
||||
|
@@ -1,6 +1,10 @@
|
||||
import wx, wx.lib.customtreectrl, wx.gizmos
|
||||
import treemixin
|
||||
try:
|
||||
import treemixin
|
||||
except ImportError:
|
||||
from wx.lib.mixins import treemixin
|
||||
|
||||
overview = treemixin.__doc__
|
||||
|
||||
class TreeModel(object):
|
||||
''' TreeModel holds the domain objects that are shown in the different
|
||||
|
BIN
wxPython/demo/bmp_source/book.png
Normal file
After Width: | Height: | Size: 622 B |
BIN
wxPython/demo/bmp_source/clipboard.png
Normal file
After Width: | Height: | Size: 693 B |
BIN
wxPython/demo/bmp_source/code.png
Normal file
After Width: | Height: | Size: 868 B |
BIN
wxPython/demo/bmp_source/core.png
Normal file
After Width: | Height: | Size: 807 B |
BIN
wxPython/demo/bmp_source/custom.png
Normal file
After Width: | Height: | Size: 833 B |
BIN
wxPython/demo/bmp_source/deleteperspective.png
Normal file
After Width: | Height: | Size: 892 B |
BIN
wxPython/demo/bmp_source/demo.png
Normal file
After Width: | Height: | Size: 817 B |
BIN
wxPython/demo/bmp_source/dialog.png
Normal file
After Width: | Height: | Size: 237 B |
BIN
wxPython/demo/bmp_source/exit.png
Normal file
After Width: | Height: | Size: 995 B |
BIN
wxPython/demo/bmp_source/expansion.png
Normal file
After Width: | Height: | Size: 894 B |
BIN
wxPython/demo/bmp_source/find.png
Normal file
After Width: | Height: | Size: 985 B |
BIN
wxPython/demo/bmp_source/findnext.png
Normal file
After Width: | Height: | Size: 811 B |
BIN
wxPython/demo/bmp_source/frame.png
Normal file
After Width: | Height: | Size: 199 B |
BIN
wxPython/demo/bmp_source/images.png
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
wxPython/demo/bmp_source/inspect.png
Normal file
After Width: | Height: | Size: 766 B |
BIN
wxPython/demo/bmp_source/layout.png
Normal file
After Width: | Height: | Size: 519 B |
BIN
wxPython/demo/bmp_source/miscellaneous.png
Normal file
After Width: | Height: | Size: 716 B |
BIN
wxPython/demo/bmp_source/modifiedexists.png
Normal file
After Width: | Height: | Size: 440 B |
BIN
wxPython/demo/bmp_source/morecontrols.png
Normal file
After Width: | Height: | Size: 740 B |
BIN
wxPython/demo/bmp_source/moredialog.png
Normal file
After Width: | Height: | Size: 495 B |
BIN
wxPython/demo/bmp_source/overview.png
Normal file
After Width: | Height: | Size: 655 B |
BIN
wxPython/demo/bmp_source/process.png
Normal file
After Width: | Height: | Size: 1.0 KiB |
BIN
wxPython/demo/bmp_source/pyshell.png
Normal file
After Width: | Height: | Size: 664 B |
BIN
wxPython/demo/bmp_source/recent.png
Normal file
After Width: | Height: | Size: 378 B |
BIN
wxPython/demo/bmp_source/saveperspective.png
Normal file
After Width: | Height: | Size: 1.1 KiB |
@@ -100,6 +100,34 @@ command_lines = [
|
||||
"-a -u -n _book_green bmp_source/book_green.png images.py",
|
||||
"-a -u -n _book_blue bmp_source/book_blue.png images.py",
|
||||
|
||||
"-a -u -c bmp_source/book.png images.py",
|
||||
"-a -u -c bmp_source/clipboard.png images.py",
|
||||
"-a -u -c bmp_source/code.png images.py",
|
||||
"-a -u -c bmp_source/core.png images.py",
|
||||
"-a -u -c bmp_source/custom.png images.py",
|
||||
"-a -u -c bmp_source/deleteperspective.png images.py",
|
||||
"-a -u -c bmp_source/demo.png images.py",
|
||||
"-a -u -c bmp_source/dialog.png images.py",
|
||||
"-a -u -c bmp_source/exit.png images.py",
|
||||
"-a -u -c bmp_source/expansion.png images.py",
|
||||
"-a -u -c bmp_source/find.png images.py",
|
||||
"-a -u -c bmp_source/findnext.png images.py",
|
||||
"-a -u -c bmp_source/frame.png images.py",
|
||||
"-a -u -c bmp_source/images.png images.py",
|
||||
"-a -u -c bmp_source/inspect.png images.py",
|
||||
"-a -u -c bmp_source/layout.png images.py",
|
||||
"-a -u -c bmp_source/miscellaneous.png images.py",
|
||||
"-a -u -c bmp_source/modifiedexists.png images.py",
|
||||
"-a -u -c bmp_source/morecontrols.png images.py",
|
||||
"-a -u -c bmp_source/moredialog.png images.py",
|
||||
"-a -u -c bmp_source/overview.png images.py",
|
||||
"-a -u -c bmp_source/process.png images.py",
|
||||
"-a -u -c bmp_source/pyshell.png images.py",
|
||||
"-a -u -c bmp_source/recent.png images.py",
|
||||
"-a -u -c bmp_source/saveperspective.png images.py",
|
||||
"-a -u -c bmp_source/customcontrol.png images.py",
|
||||
|
||||
|
||||
" -u -c bmp_source/001.png throbImages.py",
|
||||
"-a -u -c bmp_source/002.png throbImages.py",
|
||||
"-a -u -c bmp_source/003.png throbImages.py",
|
||||
|