Пример #1
0
    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
Пример #2
0
    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)

        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.EventsAreBound = False
Пример #3
0
    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
Пример #4
0
    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