mirror of
https://github.com/wxWidgets/Phoenix.git
synced 2025-12-16 01:30:07 +01:00
Floatcanvas samples updates for Phoenix
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxPython/Phoenix/trunk@73882 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -9,6 +9,7 @@ this is very old-style code: don't imitate it!
|
||||
|
||||
from time import clock
|
||||
import wx
|
||||
print wx.VERSION_STRING
|
||||
from numpy import *
|
||||
|
||||
## import local version:
|
||||
@@ -37,16 +38,6 @@ ID_ZOOM_TO_FIT_BUTTON = 110
|
||||
ID_MOVE_MODE_BUTTON = 111
|
||||
ID_TEST_BUTTON = 112
|
||||
|
||||
ID_ABOUT_MENU = 200
|
||||
ID_EXIT_MENU = 201
|
||||
ID_ZOOM_IN_MENU = 202
|
||||
ID_ZOOM_OUT_MENU = 203
|
||||
ID_ZOOM_TO_FIT_MENU = 204
|
||||
ID_DRAWTEST_MENU = 205
|
||||
ID_DRAWMAP_MENU = 206
|
||||
ID_CLEAR_MENU = 207
|
||||
|
||||
|
||||
ID_TEST = 500
|
||||
|
||||
|
||||
@@ -59,29 +50,32 @@ class DrawFrame(wx.Frame):
|
||||
MenuBar = wx.MenuBar()
|
||||
|
||||
file_menu = wx.Menu()
|
||||
file_menu.Append(ID_EXIT_MENU, "E&xit","Terminate the program")
|
||||
wx.EVT_MENU(self, ID_EXIT_MENU, self.OnQuit)
|
||||
exit = file_menu.Append(wx.ID_EXIT, "", "Terminate the program")
|
||||
self.Bind(wx.EVT_MENU, self.OnQuit, exit)
|
||||
MenuBar.Append(file_menu, "&File")
|
||||
|
||||
draw_menu = wx.Menu()
|
||||
draw_menu.Append(ID_DRAWTEST_MENU, "&Draw Test","Run a test of drawing random components")
|
||||
wx.EVT_MENU(self, ID_DRAWTEST_MENU,self.DrawTest)
|
||||
draw_menu.Append(ID_DRAWMAP_MENU, "Draw &Movie","Run a test of drawing a map")
|
||||
wx.EVT_MENU(self, ID_DRAWMAP_MENU,self.RunMovie)
|
||||
draw_menu.Append(ID_CLEAR_MENU, "&Clear","Clear the Canvas")
|
||||
wx.EVT_MENU(self, ID_CLEAR_MENU,self.Clear)
|
||||
draw = draw_menu.Append(wx.ID_ANY,
|
||||
"&Draw Test",
|
||||
"Run a test of drawing random components")
|
||||
self.Bind(wx.EVT_MENU, self.DrawTest, draw)
|
||||
amap = draw_menu.Append(wx.ID_ANY,
|
||||
"Draw &Movie","Run a test of drawing a map")
|
||||
self.Bind(wx.EVT_MENU, self.RunMovie, amap)
|
||||
clear = draw_menu.Append(wx.ID_ANY, "&Clear","Clear the Canvas")
|
||||
self.Bind(wx.EVT_MENU, self.Clear, clear)
|
||||
MenuBar.Append(draw_menu, "&Draw")
|
||||
|
||||
|
||||
view_menu = wx.Menu()
|
||||
view_menu.Append(ID_ZOOM_TO_FIT_MENU, "Zoom to &Fit","Zoom to fit the window")
|
||||
wx.EVT_MENU(self, ID_ZOOM_TO_FIT_MENU,self.ZoomToFit)
|
||||
zoom = view_menu.Append(wx.ID_ANY, "Zoom to &Fit","Zoom to fit the window")
|
||||
self.Bind(wx.EVT_MENU, self.ZoomToFit, zoom)
|
||||
MenuBar.Append(view_menu, "&View")
|
||||
|
||||
help_menu = wx.Menu()
|
||||
help_menu.Append(ID_ABOUT_MENU, "&About",
|
||||
"More information About this program")
|
||||
wx.EVT_MENU(self, ID_ABOUT_MENU, self.OnAbout)
|
||||
about = help_menu.Append(wx.ID_ABOUT, "",
|
||||
"More information About this program")
|
||||
self.Bind(wx.EVT_MENU, self.OnAbout, about)
|
||||
MenuBar.Append(help_menu, "&Help")
|
||||
|
||||
self.SetMenuBar(MenuBar)
|
||||
@@ -89,10 +83,10 @@ class DrawFrame(wx.Frame):
|
||||
self.CreateStatusBar()
|
||||
self.SetStatusText("")
|
||||
|
||||
wx.EVT_CLOSE(self, self.OnCloseWindow)
|
||||
self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
|
||||
|
||||
# Other event handlers:
|
||||
wx.EVT_RIGHT_DOWN(self, self.RightButtonEvent)
|
||||
self.Bind(wx.EVT_RIGHT_DOWN, self.RightButtonEvent)
|
||||
|
||||
# Add the Canvas
|
||||
self.Canvas = NavCanvas.NavCanvas(self,-1,(500,500),
|
||||
|
||||
@@ -77,7 +77,7 @@ class DrawFrame(wx.Frame):
|
||||
|
||||
self.Canvas = Canvas
|
||||
|
||||
FloatCanvas.EVT_MOTION(self.Canvas, self.OnMove )
|
||||
self.Canvas.Bind(FloatCanvas.EVT_MOTION, self.OnMove)
|
||||
|
||||
Point = (45,40)
|
||||
Text = Canvas.AddScaledText("A String",
|
||||
|
||||
@@ -97,13 +97,13 @@ class DrawFrame(wx.Frame):
|
||||
|
||||
FileMenu = wx.Menu()
|
||||
|
||||
OpenMenu = FileMenu.Append(wx.ID_ANY, "&Open","Open BNA")
|
||||
OpenMenu = FileMenu.Append(wx.ID_ANY, "&Open", "Open BNA")
|
||||
self.Bind(wx.EVT_MENU, self.OpenBNA, OpenMenu)
|
||||
|
||||
SaveMenu = FileMenu.Append(wx.ID_ANY, "&Save","Save BNA")
|
||||
SaveMenu = FileMenu.Append(wx.ID_ANY, "&Save", "Save BNA")
|
||||
self.Bind(wx.EVT_MENU, self.SaveBNA, SaveMenu)
|
||||
|
||||
CloseMenu = FileMenu.Append(wx.ID_ANY, "&Close","Close Application")
|
||||
CloseMenu = FileMenu.Append(wx.ID_EXIT, "", "Close Application")
|
||||
self.Bind(wx.EVT_MENU, self.OnQuit, CloseMenu)
|
||||
|
||||
MenuBar.Append(FileMenu, "&File")
|
||||
@@ -114,7 +114,7 @@ class DrawFrame(wx.Frame):
|
||||
MenuBar.Append(view_menu, "&View")
|
||||
|
||||
help_menu = wx.Menu()
|
||||
AboutMenu = help_menu.Append(wx.ID_ANY, "&About",
|
||||
AboutMenu = help_menu.Append(wx.ID_ABOUT, "",
|
||||
"More information About this program")
|
||||
self.Bind(wx.EVT_MENU, self.OnAbout, AboutMenu)
|
||||
MenuBar.Append(help_menu, "&Help")
|
||||
@@ -135,7 +135,7 @@ class DrawFrame(wx.Frame):
|
||||
FloatCanvas.EVT_LEFT_DOWN(self.Canvas, self.OnLeftDown)
|
||||
|
||||
try:
|
||||
self.FileDialog = wx.FileDialog(self, "Pick a BNA file",".","","*", wx.OPEN)
|
||||
self.FileDialog = wx.FileDialog(self, "Pick a BNA file",".","","*", wx.FD_OPEN)
|
||||
except wx._core.PyAssertionError:
|
||||
self.FileDialog = None
|
||||
|
||||
@@ -178,7 +178,7 @@ class DrawFrame(wx.Frame):
|
||||
self.BNAFile.PointsData[i] = self.AllPolys[i].Points
|
||||
dlg = wx.FileDialog(self,
|
||||
message="Pick a BNA file",
|
||||
style=wx.SAVE)
|
||||
style=wx.FD_SAVE)
|
||||
if dlg.ShowModal() == wx.ID_OK:
|
||||
filename = dlg.GetPath()
|
||||
self.BNAFile.Save(filename)
|
||||
|
||||
@@ -67,7 +67,7 @@ class DrawFrame(wx.Frame):
|
||||
self.Canvas = Canvas = NC.Canvas
|
||||
#self.Canvas.ScaleWorldToPixel = ScaleWorldToPixel
|
||||
|
||||
FloatCanvas.EVT_MOTION(self.Canvas, self.OnMove )
|
||||
self.Canvas.Bind(FloatCanvas.EVT_MOTION, self.OnMove)
|
||||
|
||||
self.Values = random.randint(0, MaxValue, (NumChannels,))
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ class DrawFrame(wx.Frame):
|
||||
MenuBar = wx.MenuBar()
|
||||
|
||||
file_menu = wx.Menu()
|
||||
item = file_menu.Append(wx.ID_ANY, "E&xit","Terminate the program")
|
||||
item = file_menu.Append(wx.ID_EXIT, "","Terminate the program")
|
||||
self.Bind(wx.EVT_MENU, self.OnQuit, item)
|
||||
MenuBar.Append(file_menu, "&File")
|
||||
|
||||
@@ -73,7 +73,7 @@ class DrawFrame(wx.Frame):
|
||||
self.CreateStatusBar()
|
||||
self.SetStatusText("")
|
||||
|
||||
wx.EVT_CLOSE(self, self.OnCloseWindow)
|
||||
self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
|
||||
|
||||
# Add the buttons
|
||||
ResetButton = wx.Button(self, label="Reset")
|
||||
@@ -109,6 +109,7 @@ class DrawFrame(wx.Frame):
|
||||
self.Show(True)
|
||||
|
||||
def OnQuit(self,event):
|
||||
self.timer.Stop()
|
||||
self.Close(True)
|
||||
|
||||
def OnCloseWindow(self, event):
|
||||
|
||||
@@ -39,8 +39,8 @@ class DrawFrame(wx.Frame):
|
||||
|
||||
self.Canvas = Canvas
|
||||
|
||||
FloatCanvas.EVT_MOTION(self.Canvas, self.OnMove )
|
||||
FloatCanvas.EVT_LEFT_DOWN(self.Canvas, self.OnLeft)
|
||||
self.Canvas.Bind(FloatCanvas.EVT_MOTION, self.OnMove )
|
||||
self.Canvas.Bind(FloatCanvas.EVT_LEFT_DOWN, self.OnLeft)
|
||||
|
||||
|
||||
# Some default sizes:
|
||||
|
||||
@@ -43,7 +43,7 @@ class DrawFrame(wx.Frame):
|
||||
def __init__(self, *args, **kwargs):
|
||||
wx.Frame.__init__(self, *args, **kwargs)
|
||||
# Add the Canvas
|
||||
Canvas = FC.FloatCanvas(self,
|
||||
Canvas = FloatCanvas.FloatCanvas(self,
|
||||
size = (500,500),
|
||||
ProjectionFun = None,
|
||||
Debug = 0,
|
||||
@@ -67,9 +67,9 @@ class DrawFrame(wx.Frame):
|
||||
LineStyle=None)
|
||||
Rect.indexes = (i,j)
|
||||
Rect.outline = Outline
|
||||
Rect.Bind(FC.EVT_FC_LEFT_DOWN, self.SquareHitLeft)
|
||||
Rect.Bind(FC.EVT_FC_ENTER_OBJECT, self.SquareEnter)
|
||||
Rect.Bind(FC.EVT_FC_LEAVE_OBJECT, self.SquareLeave)
|
||||
Rect.Bind(FloatCanvas.EVT_FC_LEFT_DOWN, self.SquareHitLeft)
|
||||
Rect.Bind(FloatCanvas.EVT_FC_ENTER_OBJECT, self.SquareEnter)
|
||||
Rect.Bind(FloatCanvas.EVT_FC_LEAVE_OBJECT, self.SquareLeave)
|
||||
|
||||
self.Show()
|
||||
Canvas.ZoomToBB()
|
||||
|
||||
@@ -66,7 +66,7 @@ class DrawFrame(wx.Frame):
|
||||
)
|
||||
self.Canvas.ZoomToBB()
|
||||
|
||||
app = wx.PySimpleApp()
|
||||
app = wx.App()
|
||||
DrawFrame(None, -1, "FloatCanvas Demo App", wx.DefaultPosition, (700,700) )
|
||||
app.MainLoop()
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ import wx
|
||||
#from floatcanvas.Utilities import GUI
|
||||
|
||||
## import the installed version
|
||||
from wx.lib.floatcanvas import NavCanvas, FloatCanvas
|
||||
from wx.lib.floatcanvas import NavCanvas, FloatCanvas, GUIMode
|
||||
from wx.lib.floatcanvas.Utilities import GUI
|
||||
|
||||
import numpy as N
|
||||
@@ -43,7 +43,7 @@ class DrawFrame(wx.Frame):
|
||||
|
||||
self.Canvas = NC.Canvas
|
||||
|
||||
FloatCanvas.EVT_MOTION(self.Canvas, self.OnMove )
|
||||
self.Canvas.Bind(FloatCanvas.EVT_MOTION, self.OnMove)
|
||||
|
||||
# Add some buttons to the Toolbar
|
||||
tb = NC.ToolBar
|
||||
@@ -99,7 +99,7 @@ class DrawFrame(wx.Frame):
|
||||
self.SetStatusText("%.4f, %.4f"%tuple(event.Coords))
|
||||
event.Skip()
|
||||
|
||||
app = wx.PySimpleApp()
|
||||
app = wx.App()
|
||||
DrawFrame(None, -1, "FloatCanvas Rectangle Drawer", wx.DefaultPosition, (700,700) )
|
||||
app.MainLoop()
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ class DrawFrame(wx.Frame):
|
||||
Canvas.GridUnder = Grid
|
||||
#Canvas.GridOver = Grid
|
||||
|
||||
FloatCanvas.EVT_MOTION(Canvas, self.OnMove )
|
||||
Canvas.Bind(FloatCanvas.EVT_MOTION, self.OnMove )
|
||||
|
||||
self.Show()
|
||||
Canvas.ZoomToBB()
|
||||
|
||||
@@ -37,7 +37,7 @@ class DrawFrame(wx.Frame):
|
||||
Canvas = NC.Canvas
|
||||
self.Canvas = Canvas
|
||||
|
||||
FloatCanvas.EVT_MOTION(self.Canvas, self.OnMove )
|
||||
self.Canvas.Bind(FloatCanvas.EVT_MOTION, self.OnMove)
|
||||
|
||||
Point = (45,40)
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ class DrawFrame(wx.Frame):
|
||||
Canvas = NC.Canvas
|
||||
self.Canvas = Canvas
|
||||
|
||||
FloatCanvas.EVT_MOTION(self.Canvas, self.OnMove )
|
||||
self.Canvas.Bind(FloatCanvas.EVT_MOTION, self.OnMove )
|
||||
|
||||
Point = (45,40)
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
|
||||
TestFileName = "../data/TestMap.png"
|
||||
TestFileName = "data/TestMap.png"
|
||||
|
||||
|
||||
import wx
|
||||
@@ -36,7 +36,7 @@ class DrawFrame(wx.Frame):
|
||||
|
||||
self.LoadMap(TestFileName)
|
||||
|
||||
FloatCanvas.EVT_MOTION(self.Canvas, self.OnMove )
|
||||
self.Canvas.Bind(FloatCanvas.EVT_MOTION, self.OnMove )
|
||||
|
||||
self.Show()
|
||||
self.Canvas.ZoomToBB()
|
||||
|
||||
@@ -33,7 +33,7 @@ class DrawFrame(wx.Frame):
|
||||
|
||||
self.Canvas = Canvas
|
||||
|
||||
FloatCanvas.EVT_MOTION(self.Canvas, self.OnMove )
|
||||
self.Canvas.Bind(FloatCanvas.EVT_MOTION, self.OnMove )
|
||||
|
||||
Point = (45,40)
|
||||
Text = Canvas.AddScaledText("A String",
|
||||
|
||||
@@ -27,7 +27,7 @@ class DrawFrame(wx.Frame):
|
||||
MenuBar = wx.MenuBar()
|
||||
|
||||
file_menu = wx.Menu()
|
||||
item = file_menu.Append(wx.ID_ANY, "&Close","Close this frame")
|
||||
item = file_menu.Append(wx.ID_EXIT, "", "Close this frame")
|
||||
self.Bind(wx.EVT_MENU, self.OnQuit, item)
|
||||
MenuBar.Append(file_menu, "&File")
|
||||
|
||||
@@ -50,7 +50,7 @@ class DrawFrame(wx.Frame):
|
||||
MenuBar.Append(view_menu, "&View")
|
||||
|
||||
help_menu = wx.Menu()
|
||||
item = help_menu.Append(wx.ID_ANY, "&About",
|
||||
item = help_menu.Append(wx.ID_ABOUT, "",
|
||||
"More information About this program")
|
||||
self.Bind(wx.EVT_MENU, self.OnAbout, item)
|
||||
MenuBar.Append(help_menu, "&Help")
|
||||
@@ -60,7 +60,7 @@ class DrawFrame(wx.Frame):
|
||||
self.CreateStatusBar()
|
||||
self.SetStatusText("")
|
||||
|
||||
wx.EVT_CLOSE(self, self.OnCloseWindow)
|
||||
self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
|
||||
|
||||
# Add the Canvas
|
||||
self.Canvas = NavCanvas.NavCanvas(self,
|
||||
@@ -289,21 +289,24 @@ class DrawFrame(wx.Frame):
|
||||
|
||||
def UnBindAllMouseEvents(self):
|
||||
## Here is how you catch 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.Bind(FloatCanvas.EVT_LEFT_DOWN, self.dummyHandler)
|
||||
self.Canvas.Bind(FloatCanvas.EVT_LEFT_UP, self.dummyHandler)
|
||||
self.Canvas.Bind(FloatCanvas.EVT_LEFT_DCLICK, self.dummyHandler)
|
||||
|
||||
FloatCanvas.EVT_MIDDLE_DOWN(self.Canvas, None )
|
||||
FloatCanvas.EVT_MIDDLE_UP(self.Canvas, None )
|
||||
FloatCanvas.EVT_MIDDLE_DCLICK(self.Canvas, None )
|
||||
self.Canvas.Bind(FloatCanvas.EVT_MIDDLE_DOWN, self.dummyHandler)
|
||||
self.Canvas.Bind(FloatCanvas.EVT_MIDDLE_UP, self.dummyHandler)
|
||||
self.Canvas.Bind(FloatCanvas.EVT_MIDDLE_DCLICK, self.dummyHandler)
|
||||
|
||||
FloatCanvas.EVT_RIGHT_DOWN(self.Canvas, None )
|
||||
FloatCanvas.EVT_RIGHT_UP(self.Canvas, None )
|
||||
FloatCanvas.EVT_RIGHT_DCLICK(self.Canvas, None )
|
||||
self.Canvas.Bind(FloatCanvas.EVT_RIGHT_DOWN, self.dummyHandler)
|
||||
self.Canvas.Bind(FloatCanvas.EVT_RIGHT_UP, self.dummyHandler)
|
||||
self.Canvas.Bind(FloatCanvas.EVT_RIGHT_DCLICK, self.dummyHandler)
|
||||
|
||||
FloatCanvas.EVT_MOUSEWHEEL(self.Canvas, None )
|
||||
self.Canvas.Bind(FloatCanvas.EVT_MOUSEWHEEL, self.dummyHandler)
|
||||
|
||||
self.EventsAreBound = False
|
||||
|
||||
def dummyHandler(self, evt):
|
||||
evt.Skip()
|
||||
|
||||
class DemoApp(wx.App):
|
||||
"""
|
||||
|
||||
@@ -16,6 +16,7 @@ ver = 'installed'
|
||||
if ver == 'installed': ## import the installed version
|
||||
from wx.lib.floatcanvas import NavCanvas, Resources
|
||||
from wx.lib.floatcanvas import FloatCanvas as FC
|
||||
from wx.lib.floatcanvas.Utilities import BBox
|
||||
print "using installed version:", wx.lib.floatcanvas.__version__
|
||||
elif ver == 'local':
|
||||
## import a local version
|
||||
@@ -276,6 +277,6 @@ class DrawFrame(wx.Frame):
|
||||
self.Canvas.Draw(True)
|
||||
|
||||
if __name__ == "__main__":
|
||||
app = wx.PySimpleApp(0)
|
||||
app = wx.App(0)
|
||||
DrawFrame(None, -1, "FloatCanvas Moving Object App", wx.DefaultPosition, (700,700) )
|
||||
app.MainLoop()
|
||||
|
||||
@@ -27,20 +27,20 @@ class DrawFrame(wx.Frame):
|
||||
MenuBar = wx.MenuBar()
|
||||
|
||||
file_menu = wx.Menu()
|
||||
item = file_menu.Append(wx.ID_ANY, "E&xit","Terminate the program")
|
||||
item = file_menu.Append(wx.ID_EXIT, "", "Terminate the program")
|
||||
self.Bind(wx.EVT_MENU, self.OnQuit, item)
|
||||
MenuBar.Append(file_menu, "&File")
|
||||
|
||||
draw_menu = wx.Menu()
|
||||
item = draw_menu.Append(wx.ID_ANY, "&Run","Run the test")
|
||||
item = draw_menu.Append(wx.ID_ANY, "&Run", "Run the test")
|
||||
self.Bind(wx.EVT_MENU, self.RunTest, item)
|
||||
item = draw_menu.Append(wx.ID_ANY, "&Stop","Stop the test")
|
||||
item = draw_menu.Append(wx.ID_ANY, "&Stop", "Stop the test")
|
||||
self.Bind(wx.EVT_MENU, self.Stop, item)
|
||||
MenuBar.Append(draw_menu, "&Plot")
|
||||
|
||||
|
||||
help_menu = wx.Menu()
|
||||
item = help_menu.Append(wx.ID_ANY, "&About",
|
||||
item = help_menu.Append(wx.ID_ABOUT, "",
|
||||
"More information About this program")
|
||||
self.Bind(wx.EVT_MENU, self.OnAbout, item)
|
||||
MenuBar.Append(help_menu, "&Help")
|
||||
@@ -51,7 +51,7 @@ class DrawFrame(wx.Frame):
|
||||
self.CreateStatusBar()
|
||||
self.SetStatusText("")
|
||||
|
||||
wx.EVT_CLOSE(self, self.OnCloseWindow)
|
||||
self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
|
||||
|
||||
# Add the Canvas
|
||||
NC = NavCanvas.NavCanvas(self ,wx.ID_ANY ,(500,300),
|
||||
@@ -173,7 +173,7 @@ class DrawFrame(wx.Frame):
|
||||
self.timerID = wx.NewId()
|
||||
self.timer = wx.Timer(self,self.timerID)
|
||||
|
||||
wx.EVT_TIMER(self,self.timerID,self.OnTimer)
|
||||
self.Bind(wx.EVT_TIMER, self.OnTimer, id=self.timerID)
|
||||
|
||||
self.count = 0
|
||||
self.timer.Start(int(self.dT*1000))
|
||||
|
||||
@@ -124,8 +124,6 @@ class DrawFrame(wx.Frame):
|
||||
|
||||
self.Moving = False
|
||||
|
||||
return None
|
||||
|
||||
def TriHit(self, object):
|
||||
print "In TriHit"
|
||||
if not self.Moving:
|
||||
@@ -171,9 +169,11 @@ class DrawFrame(wx.Frame):
|
||||
self.MoveTri = None
|
||||
self.Canvas.Draw(True)
|
||||
|
||||
app = wx.PySimpleApp(0)
|
||||
DrawFrame(None, -1, "FloatCanvas TextBox Test App", wx.DefaultPosition, (700,700) )
|
||||
app.MainLoop()
|
||||
if __name__ == "__main__":
|
||||
app = wx.App(0)
|
||||
x = DrawFrame(None, -1, "FloatCanvas TextBox Test App", wx.DefaultPosition, (700,700) )
|
||||
x.Show()
|
||||
app.MainLoop()
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ class DrawFrame(wx.Frame):
|
||||
|
||||
self.Canvas = Canvas
|
||||
|
||||
FloatCanvas.EVT_MOTION(self.Canvas, self.OnMove )
|
||||
self.Canvas.Bind(FloatCanvas.EVT_MOTION, self.OnMove)
|
||||
|
||||
Point = (45,40)
|
||||
Box = Canvas.AddScaledTextBox("A Two Line\nString",
|
||||
|
||||
@@ -21,7 +21,7 @@ from wx.lib.floatcanvas import FloatCanvas
|
||||
#sys.path.append("../")
|
||||
#from floatcanvas import NavCanvas, FloatCanvas
|
||||
|
||||
app = wx.PySimpleApp()
|
||||
app = wx.App()
|
||||
|
||||
f = wx.Frame(None)
|
||||
Canvas = FloatCanvas.FloatCanvas(f,
|
||||
|
||||
@@ -72,7 +72,7 @@ class TextOverlay(FloatCanvas.Text):
|
||||
#if self.TextWidth is None or self.TextHeight is None:
|
||||
# (self.TextWidth, self.TextHeight) = dc.GetTextExtent(self.String)
|
||||
#XY = self.ShiftFun(XY[0], XY[1], self.TextWidth, self.TextHeight)
|
||||
dc.DrawTextPoint(self.String, self.XY)
|
||||
dc.DrawText(self.String, self.XY)
|
||||
|
||||
|
||||
class DrawFrame(wx.Frame):
|
||||
@@ -110,7 +110,7 @@ class DrawFrame(wx.Frame):
|
||||
BackgroundColor = 'Pink',
|
||||
)
|
||||
|
||||
FloatCanvas.EVT_MOTION(Canvas, self.OnMove )
|
||||
Canvas.Bind(FloatCanvas.EVT_MOTION, self.OnMove)
|
||||
|
||||
self.Show()
|
||||
Canvas.ZoomToBB()
|
||||
|
||||
@@ -68,7 +68,7 @@ class DrawFrame(wx.Frame):
|
||||
Pie1.Bind(FloatCanvas.EVT_FC_LEFT_DOWN, self.Pie1Hit)
|
||||
Pie2.Bind(FloatCanvas.EVT_FC_LEFT_DOWN, self.Pie2Hit)
|
||||
|
||||
FloatCanvas.EVT_MOTION(self.Canvas, self.OnMove )
|
||||
self.Canvas.Bind(FloatCanvas.EVT_MOTION, self.OnMove )
|
||||
|
||||
self.Show()
|
||||
Canvas.ZoomToBB()
|
||||
|
||||
@@ -42,9 +42,9 @@ class PixelBitmap:
|
||||
'cr the center right, etc.
|
||||
|
||||
"""
|
||||
if type(Bitmap) == wx._gdi.Bitmap:
|
||||
if type(Bitmap) == wx.Bitmap:
|
||||
self.Bitmap = Bitmap
|
||||
elif type(Bitmap) == wx._core.Image:
|
||||
elif type(Bitmap) == wx.Image:
|
||||
self.Bitmap = wx.BitmapFromImage(Bitmap)
|
||||
else:
|
||||
raise FC.FloatCanvasError("PixelBitmap takes only a wx.Bitmap or a wx.Image as input")
|
||||
@@ -68,7 +68,7 @@ class PixelBitmap:
|
||||
elif self.Position[1] == 'c':
|
||||
XY = (XY[0] + (w - self.Width)/2, XY[1])
|
||||
|
||||
dc.DrawBitmapPoint(self.Bitmap, XY, True)
|
||||
dc.DrawBitmap(self.Bitmap, XY, True)
|
||||
|
||||
class GridGroup:
|
||||
def __init__(self, grids=[]):
|
||||
|
||||
@@ -33,7 +33,7 @@ class DrawFrame(wx.Frame):
|
||||
|
||||
self.Canvas = Canvas
|
||||
|
||||
FloatCanvas.EVT_MOTION(self.Canvas, self.OnMove )
|
||||
self.Canvas.Bind(FloatCanvas.EVT_MOTION, self.OnMove)
|
||||
|
||||
Pts = ((45,40), (20, 15), (10, 40), (30,30))
|
||||
|
||||
|
||||
@@ -18,9 +18,6 @@ from wx.lib.floatcanvas import NavCanvas, FloatCanvas
|
||||
|
||||
import wx
|
||||
|
||||
ID_ABOUT_MENU = wx.ID_ABOUT
|
||||
ID_ZOOM_TO_FIT_MENU = wx.NewId()
|
||||
|
||||
class DrawFrame(wx.Frame):
|
||||
|
||||
"""
|
||||
@@ -35,20 +32,20 @@ class DrawFrame(wx.Frame):
|
||||
MenuBar = wx.MenuBar()
|
||||
|
||||
FileMenu = wx.Menu()
|
||||
FileMenu.Append(wx.NewId(), "&Close","Close Application")
|
||||
wx.EVT_MENU(self, FileMenu.FindItem("Close"), self.OnQuit)
|
||||
exit = FileMenu.Append(wx.ID_EXIT, "", "Close Application")
|
||||
self.Bind(wx.EVT_MENU, self.OnQuit, exit)
|
||||
|
||||
MenuBar.Append(FileMenu, "&File")
|
||||
|
||||
view_menu = wx.Menu()
|
||||
view_menu.Append(wx.NewId(), "Zoom to &Fit","Zoom to fit the window")
|
||||
wx.EVT_MENU(self, view_menu.FindItem("Zoom to &Fit"), self.ZoomToFit)
|
||||
zfit = view_menu.Append(wx.NewId(), "Zoom to &Fit", "Zoom to fit the window")
|
||||
self.Bind(wx.EVT_MENU, self.ZoomToFit, zfit)
|
||||
MenuBar.Append(view_menu, "&View")
|
||||
|
||||
help_menu = wx.Menu()
|
||||
help_menu.Append(ID_ABOUT_MENU, "&About",
|
||||
"More information About this program")
|
||||
wx.EVT_MENU(self, ID_ABOUT_MENU, self.OnAbout)
|
||||
about = help_menu.Append(wx.ID_ABOUT, "",
|
||||
"More information About this program")
|
||||
self.Bind(wx.EVT_MENU, self.OnAbout, about)
|
||||
MenuBar.Append(help_menu, "&Help")
|
||||
|
||||
self.SetMenuBar(MenuBar)
|
||||
@@ -60,11 +57,11 @@ class DrawFrame(wx.Frame):
|
||||
BackgroundColor = "DARK SLATE BLUE"
|
||||
).Canvas
|
||||
|
||||
wx.EVT_CLOSE(self, self.OnCloseWindow)
|
||||
self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
|
||||
|
||||
FloatCanvas.EVT_MOTION(self.Canvas, self.OnMove )
|
||||
FloatCanvas.EVT_LEFT_UP(self.Canvas, self.OnLeftUp )
|
||||
FloatCanvas.EVT_LEFT_DOWN(self.Canvas, self.OnLeftClick )
|
||||
self.Canvas.Bind(FloatCanvas.EVT_MOTION, self.OnMove)
|
||||
self.Canvas.Bind(FloatCanvas.EVT_LEFT_UP, self.OnLeftUp)
|
||||
self.Canvas.Bind(FloatCanvas.EVT_LEFT_DOWN, self.OnLeftClick)
|
||||
|
||||
self.ResetSelections()
|
||||
|
||||
|
||||
@@ -374,6 +374,6 @@ class DrawFrame(wx.Frame):
|
||||
self.MovingObject.Move(dxy)
|
||||
self.Canvas.Draw(True)
|
||||
|
||||
app = wx.PySimpleApp(0)
|
||||
app = wx.App(0)
|
||||
DrawFrame(None, -1, "FloatCanvas Tree Demo App", wx.DefaultPosition, (700,700) )
|
||||
app.MainLoop()
|
||||
|
||||
@@ -69,7 +69,7 @@ class DrawFrame(wx.Frame):
|
||||
Canvas.AddText("%s"%(Point,), Point, Position="cl")
|
||||
Canvas.AddPoint(Point, Diameter=3, Color = "red")
|
||||
|
||||
FloatCanvas.EVT_MOTION(self.Canvas, self.OnMove )
|
||||
self.Canvas.Bind(FloatCanvas.EVT_MOTION, self.OnMove)
|
||||
|
||||
|
||||
self.Show()
|
||||
|
||||
@@ -41,7 +41,7 @@ class DrawFrame(wx.Frame):
|
||||
Canvas.MaxScale=20 # sets the maximum zoom level
|
||||
self.Canvas = Canvas
|
||||
|
||||
FloatCanvas.EVT_MOTION(self.Canvas, self.OnMove )
|
||||
self.Canvas.Bind(FloatCanvas.EVT_MOTION, self.OnMove )
|
||||
|
||||
|
||||
# create the image:
|
||||
|
||||
@@ -54,7 +54,6 @@ class MyFrame(wx.Frame):
|
||||
# set up the Splitter
|
||||
sash_Position = 300
|
||||
splitter.SplitVertically(panel1, panel2, sash_Position)
|
||||
splitter.SetSashSize(10)
|
||||
min_Pan_size = 40
|
||||
splitter.SetMinimumPaneSize(min_Pan_size)
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ class NavPanel(NavCanvas.NavCanvas):
|
||||
)
|
||||
|
||||
self.parent_frame = parent
|
||||
FloatCanvas.EVT_MOTION(self.Canvas, self.OnMove )
|
||||
self.Canvas.Bind(FloatCanvas.EVT_MOTION, self.OnMove)
|
||||
|
||||
# create the image:
|
||||
self.Canvas.AddPolygon( ( (2,3),
|
||||
|
||||
@@ -65,7 +65,7 @@ class DrawFrame(wx.Frame):
|
||||
|
||||
self.Canvas.Bind(FC.EVT_MOTION, self.OnMove)
|
||||
|
||||
wx.EVT_CLOSE(self, self.OnCloseWindow)
|
||||
self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
|
||||
|
||||
self.DrawTest()
|
||||
self.Show()
|
||||
|
||||
@@ -36,7 +36,7 @@ class DrawFrame(wx.Frame):
|
||||
).Canvas
|
||||
|
||||
self.Canvas = Canvas
|
||||
FloatCanvas.EVT_MOTION(self.Canvas, self.OnMove )
|
||||
self.Canvas.Bind(FloatCanvas.EVT_MOTION, self.OnMove )
|
||||
|
||||
Point = (45,40)
|
||||
Box = Canvas.AddScaledTextBox("A Two Line\nString",
|
||||
@@ -284,7 +284,7 @@ class DrawFrame(wx.Frame):
|
||||
def binding2(self, event):
|
||||
print "I'm the TextBox"
|
||||
|
||||
app = wx.PySimpleApp()
|
||||
app = wx.App()
|
||||
DrawFrame(None, -1, "FloatCanvas Demo App", wx.DefaultPosition, (700,700) )
|
||||
app.MainLoop()
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ import wx
|
||||
|
||||
|
||||
## import the installed version
|
||||
from wx.lib.floatcanvas import NavCanvas, FloatCanvas
|
||||
from wx.lib.floatcanvas import NavCanvas, FloatCanvas, Resources
|
||||
|
||||
## import a local version
|
||||
#import sys
|
||||
@@ -58,9 +58,9 @@ class DrawFrame(wx.Frame):
|
||||
|
||||
self.Canvas = Canvas
|
||||
|
||||
FloatCanvas.EVT_MOTION(self.Canvas, self.OnMove )
|
||||
FloatCanvas.EVT_LEFT_UP(self.Canvas, self.OnLeftUp )
|
||||
FloatCanvas.EVT_LEFT_DOWN(self.Canvas, self.OnLeftDown)
|
||||
self.Canvas.Bind(FloatCanvas.EVT_MOTION, self.OnMove )
|
||||
self.Canvas.Bind(FloatCanvas.EVT_LEFT_UP, self.OnLeftUp )
|
||||
self.Canvas.Bind(FloatCanvas.EVT_LEFT_DOWN, self.OnLeftDown)
|
||||
|
||||
Point = N.array((0,0), N.float)
|
||||
|
||||
@@ -210,7 +210,7 @@ class DrawFrame(wx.Frame):
|
||||
self.Handle1.SetPoint(self.Box.XY)
|
||||
|
||||
|
||||
app = wx.PySimpleApp()
|
||||
app = wx.App()
|
||||
DrawFrame(None, -1, "FloatCanvas TextBox Test App", wx.DefaultPosition, (700,700) )
|
||||
app.MainLoop()
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ It demonstrates moving objects around, etc, etc.
|
||||
import wx
|
||||
|
||||
#ver = 'local'
|
||||
2ver = 'installed'
|
||||
ver = 'installed'
|
||||
|
||||
if ver == 'installed': ## import the installed version
|
||||
from wx.lib.floatcanvas import NavCanvas, Resources
|
||||
@@ -366,6 +366,6 @@ class DrawFrame(wx.Frame):
|
||||
self.MoveTri = None
|
||||
self.Canvas.Draw(True)
|
||||
|
||||
app = wx.PySimpleApp(0)
|
||||
app = wx.App(0)
|
||||
DrawFrame(None, -1, "FloatCanvas Tree Demo App", wx.DefaultPosition, (700,700) )
|
||||
app.MainLoop()
|
||||
|
||||
@@ -49,7 +49,7 @@ class DrawFrame(wx.Frame):
|
||||
self.CreateStatusBar()
|
||||
self.SetStatusText("")
|
||||
|
||||
wx.EVT_CLOSE(self, self.OnCloseWindow)
|
||||
self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
|
||||
|
||||
# Add the Canvas
|
||||
self.Canvas = NavCanvas.NavCanvas(self ,wx.ID_ANY ,(500,300),
|
||||
|
||||
@@ -64,7 +64,7 @@ class DrawFrame(wx.Frame):
|
||||
Canvas.AddText("%s"%(Point,), Point, Position="cr")
|
||||
Canvas.AddPoint(Point, Diameter=3, Color = "red")
|
||||
|
||||
FloatCanvas.EVT_MOTION(self.Canvas, self.OnMove )
|
||||
self.Canvas.Bind(FloatCanvas.EVT_MOTION, self.OnMove )
|
||||
|
||||
|
||||
self.Show()
|
||||
|
||||
Reference in New Issue
Block a user