コード例 #1
0
 def test_positionMath1(self):
     p1 = wx.Position(3, 4)
     p2 = wx.Position(1, 1)
     p1 -= p2
     self.assertTrue(p1 == (2, 3))
     p1 += p2
     self.assertTrue(p1 == (3, 4))
コード例 #2
0
 def test_positionMath2(self):
     p1 = wx.Position(3, 4)
     p2 = wx.Position(1, 1)
     p3 = p1 + p2
     self.assertTrue(p3 == (4, 5))
     p4 = p3 - p2
     self.assertTrue(p4 == (3, 4))
     self.assertTrue(p4 == p1)
コード例 #3
0
ファイル: test_position.py プロジェクト: jessjames541/Jessem
 def test_GetIM(self):
     # Test the immutable version returned by GetIM
     obj = wx.Position(1,2)
     im = obj.GetIM()
     assert isinstance(im, tuple)
     assert im.Row == obj.Row
     assert im.Col == obj.Col
     obj2 = wx.Position(im)
     assert obj == obj2
コード例 #4
0
ファイル: hello2.py プロジェクト: rfagen/pycars
class HelloFrame(wx.Frame):
    """
    A Frame that says Hello World
    """
    mpos=wx.Position(0,0)

    def __init__(self, *args, **kw):
        # ensure the parent's __init__ is called
        super(HelloFrame, self).__init__(*args, **kw)

        # create a menu bar
        self.makeMenuBar()

        # and a status bar
        self.CreateStatusBar()
        self.SetStatusText("Welcome to wxPython!")

        self.Bind(wx.EVT_MOTION, self.OnMove)

        self.Centre()


    def makeMenuBar(self):
        """
        A menu bar is composed of menus, which are composed of menu items.
        This method builds a set of menus and binds handlers to be called
        when the menu item is selected.
        """

        # Make a file menu with Hello and Exit items
        fileMenu = wx.Menu()
        # The "\t..." syntax defines an accelerator key that also triggers
        # the same event
        helloItem = fileMenu.Append(-1, "&Hello...\tCtrl-H",
                "Help string shown in status bar for this menu item")
        fileMenu.AppendSeparator()
        # When using a stock ID we don't need to specify the menu item's
        # label
        exitItem = fileMenu.Append(wx.ID_EXIT)

        # Now a help menu for the about item
        helpMenu = wx.Menu()
        aboutItem = helpMenu.Append(wx.ID_ABOUT)

        # Make the menu bar and add the two menus to it. The '&' defines
        # that the next letter is the "mnemonic" for the menu item. On the
        # platforms that support it those letters are underlined and can be
        # triggered from the keyboard.
        menuBar = wx.MenuBar()
        menuBar.Append(fileMenu, "&File")
        menuBar.Append(helpMenu, "&Help")

        # Give the menu bar to the frame
        self.SetMenuBar(menuBar)

        # Finally, associate a handler function with the EVT_MENU event for
        # each of the menu items. That means that when that menu item is
        # activated then the associated handler function will be called.
        self.Bind(wx.EVT_MENU, self.OnHello, helloItem)
        self.Bind(wx.EVT_MENU, self.OnExit,  exitItem)
        self.Bind(wx.EVT_MENU, self.OnAbout, aboutItem)


    def OnExit(self, event):
        """Close the frame, terminating the application."""
        self.Close(True)


    def OnHello(self, event):
        """Say hello to the user."""
        wx.MessageBox("Hello again from wxPython")


    def OnAbout(self, event):
        """Display an About Dialog"""
        wx.MessageBox("This is a wxPython Hello World sample",
                      "About Hello World 2",
                      wx.OK|wx.ICON_INFORMATION)

    def OnMove(self, e):
        dc=wx.BufferedDC(wx.ClientDC(self))
        width,height=self.GetSize().Get()
        dc.Clear()
        mx, my = e.GetLogicalPosition(dc).Get()
        self.SetStatusText("x:{}, y:{}".format(mx, my) )
        for x in range(0,9):
            for y in range(0,9):
                pen1=wx.Pen(wx.Colour(x*20,y*20,120), width=4, style=wx.PENSTYLE_USER_DASH)
                pen1.SetDashes([x+1])
                pen2=wx.Pen(wx.Colour(x*20,y*20,120), 4)
                x1=x*mx/10
                x2=x1+(x*mx/10)
                y1=y*my/5+5
                y2=y1+(y*my/5)+5
                dc.SetPen(pen2)
                dc.DrawLine(x1+width/2, y1, x2+width/2, y2)
                if x1 > width/2:
                    x1 = width/2
                if x2 > width/2:
                    x2 = width/2
                dc.SetPen(pen1)
                dc.DrawLine(x1, y1, x2, y2)
コード例 #5
0
 def test_positionCtors(self):
     p = wx.Position()
     self.assertTrue(p == (0, 0))
     self.assertTrue(p != (9, 9))
     p2 = wx.Position(2, 3)
     self.assertTrue(p2.Get() == (2, 3))
コード例 #6
0
 def test_positionProperties2(self):
     p = wx.Position()
     p.Row = 11
     p.Col = 12
     self.assertTrue(p.Get() == (11, 12))
コード例 #7
0
 def test_positionProperties1(self):
     p = wx.Position()
     p.Row
     p.Col
コード例 #8
0
 def test_positionCopyCtor(self):
     p1 = wx.Position(3, 4)
     p2 = wx.Position(p1)
     self.assertTrue(p1 is not p2)
     self.assertTrue(p1 == p2)