def InitPreviewPanel(self, pnl): pnl.SetBackgroundColour('#FFFFFF') pvSiz = wx.GridBagSizer(0, 0) pvSiz.AddGrowableCol(0) gRow = 0 pnl.pvLabel = wx.StaticText(pnl, -1, "Red is Masked data") pvSiz.Add(pnl.pvLabel, pos=(gRow, 0), span=(1, 1), flag=wx.TOP | wx.LEFT | wx.BOTTOM | wx.EXPAND, border=5) gRow += 1 # Add the FloatCanvas canvas pnl.NC = NavCanvas.NavCanvas(pnl, ProjectionFun=None, Debug=0, BackgroundColor="WHITE") pnl.Canvas = pnl.NC.Canvas # reference the contained FloatCanvas pvSiz.Add(pnl.NC, pos=(gRow, 0), span=(1, 1), flag=wx.EXPAND, border=0) pvSiz.AddGrowableRow(gRow) pnl.SetSizer(pvSiz) pnl.SetAutoLayout(1)
def __init__(self, *args, **kwargs): wx.Frame.__init__(self, *args, **kwargs) self.CreateStatusBar() # Add the Canvas Canvas = NavCanvas.NavCanvas( self, -1, size=(500, 500), ProjectionFun=None, Debug=0, BackgroundColor="DARK SLATE BLUE", ).Canvas Point = (45, 40) Box = Canvas.AddCircle(Point, Diameter=10, FillColor="Cyan", LineColor="Red", LineWidth=6) Canvas.GridOver = TextOverlay( "Some Text", (20, 20), Size=48, Color="Black", BackgroundColor='Pink', ) Canvas.Bind(FloatCanvas.EVT_MOTION, self.OnMove) self.Show() Canvas.ZoomToBB()
def __init__(self, *args, **kwargs): wx.Frame.__init__(self, *args, **kwargs) self.CreateStatusBar() # Add the Canvas Canvas = NavCanvas.NavCanvas(self,-1, size = (500,500), ProjectionFun = None, Debug = 0, BackgroundColor = "DARK SLATE BLUE", ).Canvas self.Canvas = Canvas FloatCanvas.EVT_MOTION(self.Canvas, self.OnMove ) Pts = ((45,40), (20, 15), (10, 40), (30,30)) Points = Canvas.AddPointSet(Pts, Diameter=3, Color="Red") Points.HitLineWidth = 10 Points.Bind(FloatCanvas.EVT_FC_ENTER_OBJECT, self.OnOverPoints) Points.Bind(FloatCanvas.EVT_FC_LEAVE_OBJECT, self.OnLeavePoints) Points.Bind(FloatCanvas.EVT_FC_LEFT_DOWN, self.OnLeftDown) self.Show() Canvas.ZoomToBB()
def __init__(self, *args, **kwargs): wx.Frame.__init__(self, *args, **kwargs) self.CreateStatusBar() # Add the Canvas Canvas = NavCanvas.NavCanvas( self, -1, size=(500, 500), ProjectionFun=YScaleFun, Debug=0, BackgroundColor="DARK SLATE BLUE", ).Canvas self.Canvas = Canvas Point = N.array((50e-6, 0)) Size = N.array(((2000e-6 - 5e-6), 50000)) Box = Canvas.AddRectangle(Point, Size, FillColor="blue") Canvas.AddText("%s" % (Point, ), Point, Position="cr") Canvas.AddPoint(Point, Diameter=3, Color="red") Point = Point + Size Canvas.AddText("%s" % (Point, ), Point, Position="cl") Canvas.AddPoint(Point, Diameter=3, Color="red") FloatCanvas.EVT_MOTION(self.Canvas, self.OnMove) self.Show() Canvas.ZoomToBB()
def __init__(self, *args, **kwargs): wx.Frame.__init__(self, *args, **kwargs) self.CreateStatusBar() # Add the Canvas Canvas = NavCanvas.NavCanvas(self,-1, size = (500,500), ProjectionFun = YDownProjection, Debug = 0, BackgroundColor = "DARK SLATE BLUE", ).Canvas self.Canvas = Canvas Point = (0,0) Box = Canvas.AddRectangle(Point, (80,100), FillColor = "blue" ) Canvas.AddText("%s"%(Point,), Point, Position="cr") Canvas.AddPoint(Point, Diameter=3, Color = "red") Point = (0,100) Canvas.AddText("%s"%(Point,), Point, Position="cr") Canvas.AddPoint(Point, Diameter=3, Color = "red") FloatCanvas.EVT_MOTION(self.Canvas, self.OnMove ) self.Show() Canvas.ZoomToBB()
def __init__(self, *args, **kwargs): wx.Frame.__init__(self, *args, **kwargs) self.CreateStatusBar() # Add the Canvas Canvas = NavCanvas.NavCanvas(self,-1, size = (500,500), ProjectionFun = None, Debug = 0, BackgroundColor = "DARK SLATE BLUE", ).Canvas Point = (45,40) Box = Canvas.AddCircle(Point, Diameter = 10, FillColor = "Black", LineColor = "Red", LineWidth = 6) # Crosses: Grid = FloatCanvas.DotGrid( Spacing=(1, .5), Size=2, Color="Cyan", Cross=True, CrossThickness=2) #Dots: #Grid = FloatCanvas.DotGrid( (0.5, 1), Size=3, Color="Red") Canvas.GridUnder = Grid #Canvas.GridOver = Grid FloatCanvas.EVT_MOTION(Canvas, self.OnMove ) self.Show() Canvas.ZoomToBB()
def __init__(self, *args, **kwargs): wx.Frame.__init__(self, *args, **kwargs) self.CreateStatusBar() # Add the Canvas Canvas = NavCanvas.NavCanvas(self, ProjectionFun = None, BackgroundColor = "DARK SLATE BLUE", ).Canvas Canvas.MaxScale=4 self.Canvas = Canvas FloatCanvas.EVT_MOTION(self.Canvas, self.OnMove ) # create the image: image = wx.Image(ImageFile) img = Canvas.AddScaledBitmap( image, (0,0), Height=image.GetHeight(), Position = 'tl', Quality = 'normal', ) img.Bind(FloatCanvas.EVT_FC_LEFT_DOWN, self.OnLeftDown) img.Bind(FloatCanvas.EVT_FC_MOTION, self.OnMotion) self.Show() Canvas.ZoomToBB() self.move_count = 0
def __init__(self, *args, **kwargs): wx.Frame.__init__(self, *args, **kwargs) ## Set up the MenuBar MenuBar = wx.MenuBar() file_menu = wx.Menu() item = file_menu.Append(-1, "&Close", "Close this frame") self.Bind(wx.EVT_MENU, self.OnQuit, item) MenuBar.Append(file_menu, "&File") help_menu = wx.Menu() item = help_menu.Append(-1, "&About", "More information About this program") self.Bind(wx.EVT_MENU, self.OnAbout, item) MenuBar.Append(help_menu, "&Help") self.SetMenuBar(MenuBar) self.CreateStatusBar() # Add the Canvas self.Canvas = NavCanvas.NavCanvas( self, BackgroundColor="White", ).Canvas self.Canvas.Bind(FC.EVT_MOTION, self.OnMove) wx.EVT_CLOSE(self, self.OnCloseWindow) self.DrawTest() self.Show() self.Canvas.ZoomToBB()
def __init__(self, *args, **kwargs): wx.Frame.__init__(self, *args, **kwargs) self.CreateStatusBar() # Add the Canvas Canvas = NavCanvas.NavCanvas( self, ProjectionFun=None, BackgroundColor="DARK SLATE BLUE", ).Canvas Canvas.MaxScale = 20 # sets the maximum zoom level self.Canvas = Canvas FloatCanvas.EVT_MOTION(self.Canvas, self.OnMove) # create the image: image = wx.Image(ImageFile) self.width, self.height = image.GetSize() img = FloatCanvas.ScaledBitmap2(image, (0, 0), Height=image.GetHeight(), Position='tl', Quality='high') Canvas.AddObject(img) img.Bind(FloatCanvas.EVT_FC_LEFT_DOWN, self.OnLeftDown) self.Canvas.Bind(wx.EVT_SIZE, self.OnSize) self.Show() Canvas.ZoomToBB(margin_adjust=1.0)
def __init__(self, *args, **kwargs): wx.Frame.__init__(self, *args, **kwargs) self.CreateStatusBar() # Add the Canvas FloatCanvas.FloatCanvas.ScaleWorldToPixel = ScaleWorldToPixel NC = NavCanvas.NavCanvas( self, -1, size=(500, 500), BackgroundColor="DARK SLATE BLUE", ProjectionFun=YScaleFun, ) self.Canvas = Canvas = NC.Canvas #self.Canvas.ScaleWorldToPixel = ScaleWorldToPixel FloatCanvas.EVT_MOTION(self.Canvas, self.OnMove) self.Values = random.randint(0, MaxValue, (NumChannels, )) self.Bars = [] self.BarWidth = 0.75 # add an X axis Canvas.AddLine(((0, 0), (NumChannels, 0)), ) for x in N.linspace(1, NumChannels, 11): Canvas.AddText("%i" % x, (x - 1 + self.BarWidth / 2, 0), Position="tc") for i, Value in enumerate(self.Values): bar = Canvas.AddRectangle( XY=(i, 0), WH=(self.BarWidth, Value), LineColor=None, LineStyle="Solid", LineWidth=1, FillColor="Red", FillStyle="Solid", ) self.Bars.append(bar) # Add a couple a button the Toolbar tb = NC.ToolBar tb.AddSeparator() ResetButton = wx.Button(tb, label="Reset") tb.AddControl(ResetButton) ResetButton.Bind(wx.EVT_BUTTON, self.ResetData) # PlayButton = wx.Button(tb, wx.ID_ANY, "Run") # tb.AddControl(PlayButton) # PlayButton.Bind(wx.EVT_BUTTON, self.RunTest) tb.Realize() self.Show() Canvas.ZoomToBB() Canvas.Draw(True)
def __init__(self, parent, id, title, position, size): wx.Frame.__init__(self, parent, id, title, position, size) ## Set up the MenuBar MenuBar = wx.MenuBar() FileMenu = wx.Menu() 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") self.Bind(wx.EVT_MENU, self.SaveBNA, SaveMenu) CloseMenu = FileMenu.Append(wx.ID_ANY, "&Close", "Close Application") self.Bind(wx.EVT_MENU, self.OnQuit, CloseMenu) MenuBar.Append(FileMenu, "&File") view_menu = wx.Menu() ZoomMenu = view_menu.Append(wx.ID_ANY, "Zoom to &Fit", "Zoom to fit the window") self.Bind(wx.EVT_MENU, self.ZoomToFit, ZoomMenu) MenuBar.Append(view_menu, "&View") help_menu = wx.Menu() AboutMenu = help_menu.Append(wx.ID_ANY, "&About", "More information About this program") self.Bind(wx.EVT_MENU, self.OnAbout, AboutMenu) MenuBar.Append(help_menu, "&Help") self.SetMenuBar(MenuBar) self.CreateStatusBar() # Add the Canvas self.Canvas = NavCanvas.NavCanvas( self, -1, (500, 500), Debug=0, BackgroundColor="DARK SLATE BLUE").Canvas wx.EVT_CLOSE(self, self.OnCloseWindow) FloatCanvas.EVT_MOTION(self.Canvas, self.OnMove) FloatCanvas.EVT_LEFT_UP(self.Canvas, self.OnLeftUp) FloatCanvas.EVT_LEFT_DOWN(self.Canvas, self.OnLeftDown) try: self.FileDialog = wx.FileDialog(self, "Pick a BNA file", ".", "", "*", wx.OPEN) except wx._core.PyAssertionError: self.FileDialog = None self.ResetSelections() return None
def __init__(self, *args, **kwargs): wx.Frame.__init__(self, *args, **kwargs) #Adding the SplitterWindow splitter = wx.SplitterWindow(self, style=wx.SP_LIVE_UPDATE | wx.SP_3D, size=(800, 400)) # add the left Panel panel1 = wx.Panel(splitter) panel1.SetBackgroundColour(wx.RED) # add the Canvas panel2 = NavCanvas.NavCanvas( splitter, ProjectionFun=None, Debug=0, BackgroundColor="DARK SLATE BLUE", ) Canvas = panel2.Canvas # put something on the Canvas Point = (15, 10) Canvas.AddScaledTextBox("A Two Line\nString", Point, 2, Color="Black", BackgroundColor=None, LineColor="Red", LineStyle="Solid", LineWidth=1, Width=None, PadSize=5, Family=wx.ROMAN, Style=wx.NORMAL, Weight=wx.NORMAL, Underlined=False, Position='br', Alignment="left", InForeground=False) wx.CallAfter(Canvas.ZoomToBB) # 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) self.Fit()
def __init__(self, *args, **kwargs): wx.Frame.__init__(self, *args, **kwargs) self.CreateStatusBar() # Add the Canvas Canvas = NavCanvas.NavCanvas(self,-1, size = (500,500), Debug = 0, BackgroundColor = "DARK SLATE BLUE", ).Canvas self.Canvas = Canvas Values = (10,10,10) Colors = ('Red', 'Blue', 'Green') Pie1 = PieChart(N.array((0, 0)), 10, Values, Colors, Scaled=False) Canvas.AddObject(Pie1) Values = (10, 5, 5) Pie2 = PieChart(N.array((40, 0)), 10, Values, Colors) Canvas.AddObject(Pie2) # test default colors Values = (10, 15, 12, 24, 6, 10, 13, 11, 9, 13, 15, 12) Pie3 = PieChart(N.array((20, 20)), 10, Values, LineColor="Black") Canvas.AddObject(Pie3) # missng slice! Values = (10, 15, 12, 24) Colors = ('Red', 'Blue', 'Green', None) Pie4 = PieChart(N.array((0, -15)), 10, Values, Colors, LineColor="Black") Canvas.AddObject(Pie4) # Test the styles Values = (10, 12, 14) Styles = ("Solid", "CrossDiagHatch","CrossHatch") Colors = ('Red', 'Blue', 'Green') Pie4 = PieChart(N.array((20, -20)), 10, Values, Colors, Styles) Canvas.AddObject(Pie2) 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.Show() Canvas.ZoomToBB()
def __init__(self,parent, id,title,position,size): wx.Frame.__init__(self,parent, id,title,position, size) # Add the Canvas self.Canvas = NavCanvas.NavCanvas(self,-1,(500,500), ProjectionFun = None, Debug = 0, BackgroundColor = "White", ).Canvas self.Show(True) self.MakePic() return None
def __init__(self, *args, **kwargs): kwargs['size'] = (700, 300) kwargs['pos'] = (50, 50) wx.Frame.__init__(self, *args, **kwargs) NC = NavCanvas.NavCanvas(self, wx.ID_ANY, (500, 500), ProjectionFun=None, BackgroundColor="WHITE") self.Canvas = NC.Canvas self.DrawLine() self.DrawCurve() return None
def __init__(self, *args, **kwargs): wx.Frame.__init__(self, *args, **kwargs) self.CreateStatusBar() # Add the Canvas Canvas = NavCanvas.NavCanvas( self, -1, size=(500, 500), ProjectionFun=None, Debug=0, BackgroundColor="DARK SLATE BLUE", ).Canvas self.Canvas = Canvas FloatCanvas.EVT_MOTION(self.Canvas, self.OnMove) Point = (45, 40) Text = Canvas.AddScaledText("A String", Point, 20, Color="Black", BackgroundColor=None, Family=wx.ROMAN, Style=wx.NORMAL, Weight=wx.NORMAL, Underlined=False, Position='bl', InForeground=False) Text.MinFontSize = 4 # the default is 1 Text.DisappearWhenSmall = False #the default is True Rect1 = Canvas.AddRectangle((50, 20), (40, 15), FillColor="Red", LineStyle=None) Rect1.Bind(FC.EVT_FC_LEFT_DOWN, self.OnLeft) Rect1.Name = "red" Rect2 = Canvas.AddRectangle((70, 30), (40, 15), FillColor="Blue", LineStyle=None) Rect2.Bind(FC.EVT_FC_LEFT_DOWN, self.OnLeft) Rect2.Name = 'blue' self.Show() Canvas.ZoomToBB()
def __init__(self, parent, id, title, position, size): wx.Frame.__init__(self, parent, id, title, position, size) ## Set up the MenuBar MenuBar = wx.MenuBar() file_menu = wx.Menu() item = file_menu.Append(wx.ID_ANY, "E&xit", "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, "&Plot", "Re-do Plot") self.Bind(wx.EVT_MENU, self.Plot, item) MenuBar.Append(draw_menu, "&Plot") help_menu = wx.Menu() item = help_menu.Append(wx.ID_ANY, "&About", "More information About this program") self.Bind(wx.EVT_MENU, self.OnAbout, item) MenuBar.Append(help_menu, "&Help") self.SetMenuBar(MenuBar) self.CreateStatusBar() self.SetStatusText("") wx.EVT_CLOSE(self, self.OnCloseWindow) # Add the Canvas self.Canvas = NavCanvas.NavCanvas(self, wx.ID_ANY, (500, 300), ProjectionFun=None, Debug=0, BackgroundColor="WHITE").Canvas self.Canvas.NumBetweenBlits = 1000 self.Show(True) self.Plot() return None
def __init__(self, *args, **kwargs): wx.Frame.__init__(self, *args, **kwargs) self.CreateStatusBar() # Add the Canvas Canvas = NavCanvas.NavCanvas( self, -1, size=(500, 500), ProjectionFun=None, Debug=0, BackgroundColor="DARK SLATE BLUE", ).Canvas self.Canvas = Canvas FloatCanvas.EVT_MOTION(self.Canvas, self.OnMove) Point = (45, 40) Box = Canvas.AddScaledTextBox("A Two Line\nString", Point, 2, Color="Black", BackgroundColor=None, LineColor="Red", LineStyle="Solid", LineWidth=1, Width=None, PadSize=5, Family=wx.ROMAN, Style=wx.NORMAL, Weight=wx.NORMAL, Underlined=False, Position='br', Alignment="left", InForeground=False) Box.Bind(FloatCanvas.EVT_FC_LEFT_DOWN, self.Binding) self.Show() Canvas.ZoomToBB() self.GUIRightMove = GUIRightMove(Canvas) Canvas.SetMode(self.GUIRightMove)
def __init__(self, *args, **kwargs): wx.Frame.__init__(self, *args, **kwargs) # Add the Canvas self.Canvas = NavCanvas.NavCanvas( self, -1, (500, 500), ProjectionFun=None, Debug=1, BackgroundColor="DARK SLATE BLUE", ).Canvas self.MakeHexagons() self.Show(True) print "Drawing the Hexagons" self.Canvas.ZoomToBB() return None
def __init__(self, parent, id, title, position, size): wx.Frame.__init__(self, parent, id, title, position, size) self.CreateStatusBar() # Add the Canvas NC = NavCanvas.NavCanvas( self, size=(500, 500), ProjectionFun=None, Debug=0, BackgroundColor="DARK SLATE BLUE", ) self.Canvas = NC.Canvas FloatCanvas.EVT_MOTION(self.Canvas, self.OnMove) # Add some buttons to the Toolbar tb = NC.ToolBar tb.AddSeparator() ClearButton = wx.Button(tb, wx.ID_ANY, "Clear") tb.AddControl(ClearButton) ClearButton.Bind(wx.EVT_BUTTON, self.Clear) DrawButton = wx.Button(tb, wx.ID_ANY, "StopDrawing") tb.AddControl(DrawButton) DrawButton.Bind(wx.EVT_BUTTON, self.SetDraw) self.DrawButton = DrawButton tb.Realize() # Initialize a few values self.Rects = [] self.RBBox = GUI.RubberBandBox(self.Canvas, self.NewRect) self.RBBox.Enable() self.Canvas.ZoomToBB() self.Show(True) return None
def __init__(self, *args, **kwargs): wx.Frame.__init__(self, *args, **kwargs) self.CreateStatusBar() # Add the Canvas NC = NavCanvas.NavCanvas(self,-1, size = (500,500), ProjectionFun = None, Debug = 0, BackgroundColor = "White", ) self.Canvas = NC.Canvas self.LoadMap(TestFileName) FloatCanvas.EVT_MOTION(self.Canvas, self.OnMove ) self.Show() self.Canvas.ZoomToBB()
def __init__(self, parent, id, title, position, size): wx.Frame.__init__(self, parent, id, title, position, size) ## Set up the MenuBar MenuBar = wx.MenuBar() FileMenu = wx.Menu() FileMenu.Append(wx.NewId(), "&Close", "Close Application") wx.EVT_MENU(self, FileMenu.FindItem("Close"), self.OnQuit) 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) 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) MenuBar.Append(help_menu, "&Help") self.SetMenuBar(MenuBar) self.CreateStatusBar() # Add the Canvas self.Canvas = NavCanvas.NavCanvas( self, -1, (500, 500), Debug=0, BackgroundColor="DARK SLATE BLUE").Canvas wx.EVT_CLOSE(self, 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.ResetSelections() return None
def __init__(self, *args, **kwargs): wx.Frame.__init__(self, *args, **kwargs) self.CreateStatusBar() # Add the Canvas Canvas = NavCanvas.NavCanvas( self, -1, size=(500, 500), ProjectionFun=None, Debug=0, BackgroundColor="DARK SLATE BLUE", ).Canvas Point = (45, 40) Box = Canvas.AddCircle(Point, Diameter=10, FillColor="Black", LineColor="Red", LineWidth=6) bmp = wx.Bitmap('NOAA.png') grids = GridGroup([ PixelBitmap(bmp, (10, 10), Position='tl'), PixelBitmap(bmp, (10, 10), Position='br'), PixelBitmap(bmp, (10, 10), Position='tr'), PixelBitmap(bmp, (10, 10), Position='bl'), PixelBitmap(bmp, (10, 10), Position='cl'), PixelBitmap(bmp, (10, 10), Position='cr'), PixelBitmap(bmp, (10, 10), Position='cc'), PixelBitmap(bmp, (10, 10), Position='tc'), PixelBitmap(bmp, (10, 10), Position='bc'), ]) Canvas.GridOver = grids FloatCanvas.EVT_MOTION(Canvas, self.OnMove) self.Show() Canvas.ZoomToBB()
def __init__(self, *args, **kwargs): wx.Frame.__init__(self, *args, **kwargs) self.CreateStatusBar() # Add the Canvas Canvas = NavCanvas.NavCanvas( self, -1, size=(500, 500), ProjectionFun=None, Debug=0, BackgroundColor="DARK SLATE BLUE", ).Canvas self.Canvas = Canvas FC.EVT_MOTION(self.Canvas, self.OnMove) # create a few test rectangles: self.rects = [] x = 0 for i in range(2): x += 50 y = 0 for j in range(4): y += 20 rect = Canvas.AddRectangle((x, y), (40, 10), FillColor="Red") rect.rectid = (i, j) rect.Bind(FC.EVT_FC_LEFT_DOWN, self.OnDown) rect.Bind(FC.EVT_FC_ENTER_OBJECT, self.OnEnter) # bind the events to the Canvas FC.EVT_LEFT_UP(Canvas, self.OnUp) self.Show() Canvas.ZoomToBB() self.InSelectMode = False
def __init__(self, *args, **kwargs): wx.Frame.__init__(self, *args, **kwargs) self.CreateStatusBar() # Add the Canvas Canvas = NavCanvas.NavCanvas( self, -1, size=(500, 500), ProjectionFun=None, Debug=0, BackgroundColor="White", ).Canvas # Canvas = FloatCanvas.FloatCanvas(self,-1, # size = (500,500), # ProjectionFun = None, # Debug = 0, # BackgroundColor = "White", # ) self.Canvas = Canvas FloatCanvas.EVT_MOTION(self.Canvas, self.OnMove) FloatCanvas.EVT_LEFT_DOWN(self.Canvas, self.OnLeft) # Some default sizes: self.LineHeight = 1 self.TextWidth = 8 self.SpaceWidth = 1 self.Labels = ["SW Tasks", "Set RX Rf"] + ["A Row Label"] * 16 self.NumRows = len(self.Labels) self.BuildChartBackground() self.AddLabels() self.Show() Canvas.MinScale = 28 Canvas.MaxScale = 28 Canvas.ZoomToBB()
def __init__(self, *args, **kwargs): wx.Frame.__init__(self, *args, **kwargs) self.CreateStatusBar() # Add the Canvas Canvas = NavCanvas.NavCanvas( self, -1, size=(500, 500), ProjectionFun=None, Debug=0, BackgroundColor="DARK SLATE BLUE", ).Canvas self.Canvas = Canvas FloatCanvas.EVT_MOTION(self.Canvas, self.OnMove) Point = (0.0, 0.0) Circle = Canvas.AddCircle( Point, Diameter=50, LineWidth=4, ) Text = Canvas.AddScaledTextBox( "Some text that will need to be wrapped. Here is another sentence.", Point, Size=Circle.WH[0] / 10., #Width = 40, Width=Circle.WH[0] * 1.6, Position='cc', Color="Black", LineStyle=None, ) self.Show() Canvas.ZoomToBB()
def __init__(self, *args, **kwargs): wx.Frame.__init__(self, *args, **kwargs) self.CreateStatusBar() # Add the Canvas Canvas = NavCanvas.NavCanvas(self,-1, size = (500,500), ProjectionFun = None, Debug = 0, BackgroundColor = "DARK SLATE BLUE", ).Canvas self.Canvas = Canvas FloatCanvas.EVT_MOTION(self.Canvas, self.OnMove ) Points = (( 0,30), ( 0, 0), (30, 0), (30,30), ( 0,30), (10,20), (10,10), (20,10), (20,20), (10,20), ) Poly = Canvas.AddPolygon(Points, FillColor = "blue", LineColor = None, ) self.Show() Canvas.ZoomToBB()
def __init__(self, *args, **kwargs): wx.Frame.__init__(self, *args, **kwargs) self.CreateStatusBar() # Add the Canvas NC = NavCanvas.NavCanvas( self, -1, size=(500, 500), ProjectionFun=None, Debug=0, BackgroundColor="DARK SLATE BLUE", ) Canvas = NC.Canvas self.Canvas = Canvas FloatCanvas.EVT_MOTION(self.Canvas, self.OnMove) Point = (45, 40) ## create a few Objects: C = FloatCanvas.Circle((0, 0), 10, FillColor="Red") R = FloatCanvas.Rectangle((5, 5), (15, 8), FillColor="Blue") E = FloatCanvas.Ellipse((1.5, 1.5), (12, 8), FillColor="Purple") C2 = FloatCanvas.Circle((0, 5), 10, FillColor="cyan") T = FloatCanvas.Text("Group A", (5.5, 5.5), Position="cc", Size=16, Weight=wx.BOLD, Family=wx.SWISS) self.GroupA = FloatCanvas.Group((R, C, E)) self.GroupA.AddObjects((C2, T)) Canvas.AddObject(self.GroupA) ## create another Groups of objects R = FloatCanvas.Rectangle((15, 15), (10, 18), FillColor="orange") E = FloatCanvas.Ellipse((22, 28), (12, 8), FillColor="yellow") C = FloatCanvas.Circle((25, 20), 15, FillColor="Green") C2 = FloatCanvas.Circle((12, 22), 10, FillColor="cyan") T = FloatCanvas.Text("Group B", (19, 24), Position="cc", Size=16, Weight=wx.BOLD, Family=wx.SWISS) self.GroupB = FloatCanvas.Group((R, E, C, C2, T)) Canvas.AddObject(self.GroupB) self.Groups = {"A": self.GroupA, "B": self.GroupB} # Add a couple of tools to the Canvas Toolbar tb = NC.ToolBar # tb.AddSeparator() for Group in self.Groups.keys(): Button = wx.Button(tb, wx.ID_ANY, "Remove %s" % Group) tb.AddControl(Button) Button.Bind(wx.EVT_BUTTON, lambda evt, group=Group: self.RemoveGroup(evt, group)) Button = wx.Button(tb, wx.ID_ANY, "Replace%s" % Group) tb.AddControl(Button) Button.Bind(wx.EVT_BUTTON, lambda evt, group=Group: self.ReplaceGroup(evt, group)) tb.Realize() self.Show() Canvas.ZoomToBB()
def __init__(self, parent, id, title, position, size): wx.Frame.__init__(self, parent, id, title, position, size) self.CreateStatusBar() # Add the Canvas Canvas = NavCanvas.NavCanvas( self, -1, (500, 500), ProjectionFun=None, Debug=0, BackgroundColor="DARK SLATE BLUE", ).Canvas 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) Point = N.array((0, 0), N.float) Canvas.AddCircle( Point, Diameter=40, FillColor="Red", LineStyle=None, ) Width = 300 self.Box = Canvas.AddScaledTextBox( LongString, Point, 10, Color="Black", BackgroundColor='White', LineStyle="Solid", LineWidth=2, Width=Width, PadSize=10.0, Family=wx.ROMAN, #Family = wx.TELETYPE, Style=wx.NORMAL, Weight=wx.NORMAL, Underlined=False, Position='tl', LineSpacing=0.8, Alignment="left", #Alignment = "center", #Alignment = "right", InForeground=False) self.Handle1 = Canvas.AddBitmap(Resources.getMoveCursorBitmap(), Point, Position='cc') self.Handle2a = Canvas.AddBitmap(Resources.getMoveRLCursorBitmap(), Point, Position='cc') self.Handle2b = Canvas.AddBitmap(Resources.getMoveRLCursorBitmap(), Point, Position='cc') self.SetHandles() self.Handle1.Bind(FloatCanvas.EVT_FC_LEFT_DOWN, self.Handle1Hit) self.Handle2a.Bind(FloatCanvas.EVT_FC_LEFT_DOWN, self.Handle2Hit) self.Handle2b.Bind(FloatCanvas.EVT_FC_LEFT_DOWN, self.Handle2Hit) self.Show(True) self.Canvas.ZoomToBB() self.Resizing = False self.ResizeRect = None self.Moving = False return None
def __init__(self, *args, **kwargs): wx.Frame.__init__(self, *args, **kwargs) ## Set up the MenuBar MenuBar = wx.MenuBar() file_menu = wx.Menu() item = file_menu.Append(wx.ID_ANY, "&Close", "Close this frame") self.Bind(wx.EVT_MENU, self.OnQuit, item) MenuBar.Append(file_menu, "&File") draw_menu = wx.Menu() item = draw_menu.Append(wx.ID_ANY, "&Draw Test", "Run a test of drawing random components") self.Bind(wx.EVT_MENU, self.DrawTest, item) item = draw_menu.Append( wx.ID_ANY, "&Move Test", "Run a test of moving stuff in the background") self.Bind(wx.EVT_MENU, self.MoveTest, item) item = draw_menu.Append(wx.ID_ANY, "&Clear", "Clear the Canvas") self.Bind(wx.EVT_MENU, self.Clear, item) MenuBar.Append(draw_menu, "&Draw") view_menu = wx.Menu() item = view_menu.Append(wx.ID_ANY, "Zoom to &Fit", "Zoom to fit the window") self.Bind(wx.EVT_MENU, self.ZoomToFit, item) MenuBar.Append(view_menu, "&View") help_menu = wx.Menu() item = help_menu.Append(wx.ID_ANY, "&About", "More information About this program") self.Bind(wx.EVT_MENU, self.OnAbout, item) MenuBar.Append(help_menu, "&Help") self.SetMenuBar(MenuBar) self.CreateStatusBar() self.SetStatusText("") wx.EVT_CLOSE(self, self.OnCloseWindow) # Add the Canvas self.Canvas = NavCanvas.NavCanvas( self, ProjectionFun=None, Debug=0, BackgroundColor="DARK SLATE BLUE", ).Canvas self.Show(True) # get a list of colors for random colors wx.lib.colourdb.updateColourDB() self.colors = wx.lib.colourdb.getColourList() self.LineStyles = FloatCanvas.DrawObject.LineStyleList.keys() return None