當前位置: 首頁>>代碼示例>>Python>>正文


Python System.Drawing方法代碼示例

本文整理匯總了Python中System.Drawing方法的典型用法代碼示例。如果您正苦於以下問題:Python System.Drawing方法的具體用法?Python System.Drawing怎麽用?Python System.Drawing使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System的用法示例。


在下文中一共展示了System.Drawing方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_indexing_value_types_cp20370

# 需要導入模塊: import System [as 別名]
# 或者: from System import Drawing [as 別名]
def test_indexing_value_types_cp20370(self):
        import clr
        if is_netcoreapp:
            clr.AddReference("System.Drawing.Primitives")
        else:
            clr.AddReference("System.Drawing")
        from System.Drawing import Point

        p = Point(1,2)
        l = [None]
        l[0] = p
        self.assertEqual(id(l[0]), id(p))
        self.assertEqual(id(l[0]), id(p))

        x = {}
        x[p] = p
        self.assertEqual(id(list(x.iterkeys())[0]), id(p))
        self.assertEqual(id(list(x.itervalues())[0]), id(p))

        self.load_iron_python_test()

        from IronPythonTest import StructIndexable
        a = StructIndexable()
        a[0] = 1
        self.assertEqual(a[0], 1) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:27,代碼來源:test_regressions.py

示例2: test_indexing_value_types_cp20370

# 需要導入模塊: import System [as 別名]
# 或者: from System import Drawing [as 別名]
def test_indexing_value_types_cp20370(self):
        import clr
        if is_netcoreapp:
            clr.AddReference("System.Drawing.Primitives")
        else:
            clr.AddReference("System.Drawing")
        from System.Drawing import Point

        p = Point(1,2)
        l = [None]
        l[0] = p
        self.assertEqual(id(l[0]), id(p))
        self.assertEqual(id(l[0]), id(p))

        x = {}
        x[p] = p
        self.assertEqual(id(list(x.keys())[0]), id(p))
        self.assertEqual(id(list(x.values())[0]), id(p))

        self.load_iron_python_test()

        from IronPythonTest import StructIndexable
        a = StructIndexable()
        a[0] = 1
        self.assertEqual(a[0], 1) 
開發者ID:IronLanguages,項目名稱:ironpython3,代碼行數:27,代碼來源:test_regressions.py

示例3: test_system_drawing

# 需要導入模塊: import System [as 別名]
# 或者: from System import Drawing [as 別名]
def test_system_drawing(self):
        import clr
        if is_netcoreapp:
            clr.AddReference("System.Drawing.Primitives")
        else:
            clr.AddReference("System.Drawing")
        from System.Drawing import Rectangle
        r = Rectangle(0, 0, 3, 7)
        s = Rectangle(3, 0, 8, 14)
        
        # calling the static method
        i = Rectangle.Intersect(r, s)
        self.assertEqual(i, Rectangle(3, 0, 0, 7))
        self.assertEqual(r, Rectangle(0, 0, 3, 7))
        self.assertEqual(s, Rectangle(3, 0, 8, 14))
        
        # calling the instance
        i = r.Intersect(s)
        self.assertEqual(i, None)
        self.assertEqual(r, Rectangle(3, 0, 0, 7))
        self.assertEqual(s, Rectangle(3, 0, 8, 14))
        
        # calling instance w/ StrongBox
        r = Rectangle(0, 0, 3, 7)
        box = clr.StrongBox[Rectangle](r)
        i = box.Intersect(s)
        self.assertEqual(i, None)
        self.assertEqual(box.Value, Rectangle(3, 0, 0, 7))
        self.assertEqual(s, Rectangle(3, 0, 8, 14))
        
        # should be able to access properties through the box
        self.assertEqual(box.X, 3)
        
        # multiple sites should produce the same function
        i = box.Intersect
        j = box.Intersect 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:38,代碼來源:test_methoddispatch.py

示例4: setUp

# 需要導入模塊: import System [as 別名]
# 或者: from System import Drawing [as 別名]
def setUp(self):
        super(OperaterTest, self).setUp()

        if is_cli:
            import clr
            self.load_iron_python_test()
            if is_netcoreapp:
                clr.AddReference("System.Drawing.Primitives")
            else:
                clr.AddReference("System.Drawing") 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:12,代碼來源:test_operator.py

示例5: test_cp3982

# 需要導入模塊: import System [as 別名]
# 或者: from System import Drawing [as 別名]
def test_cp3982(self):
        from System.Drawing import Color
        test_funcs = [  lambda x: x,
                        lambda x: [x],
                        lambda x: (x),
                        lambda x: [[x]],
                        lambda x: [(x)],
                        lambda x: ((x)),
                        lambda x: ([x]),
                        lambda x: [[[x]]],
                        lambda x: (((x))),
                        lambda x: [x, x],
                        lambda x: (x, x),
                        lambda x: [(x), [x, x]],
                        lambda x: ([x, x], (x)),
                    ]

        for test_func in test_funcs:
            self.assertTrue(test_func(Color.Red)==test_func(Color.Red))
            self.assertTrue(test_func(Color.Red)!=test_func(Color.Green))
            self.assertTrue(test_func(Color.Green)!=test_func(Color.Red))

        self.assertTrue( [Color.Green, Color.Red]  == [Color.Green, Color.Red])
        self.assertTrue([(Color.Green, Color.Red)] == [(Color.Green, Color.Red)])
        self.assertTrue( [Color.Green, Color.Red]  != (Color.Green, Color.Red))
        self.assertTrue( [Color.Green, Color.Red]  != [Color.Green, Color.Black]) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:28,代碼來源:test_operator.py

示例6: test_cp24802

# 需要導入模塊: import System [as 別名]
# 或者: from System import Drawing [as 別名]
def test_cp24802(self):
        import clr
        clr.AddReference('System.Drawing')
        import System
        p = System.Drawing.Pen(System.Drawing.Color.Blue)
        p.Width = System.Single(3.14)
        self.assertEqual(p.Width, System.Single(3.14))
        p.Width = 4.0
        self.assertEqual(p.Width, 4.0) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:11,代碼來源:test_regressions.py

示例7: test_repr

# 需要導入模塊: import System [as 別名]
# 或者: from System import Drawing [as 別名]
def test_repr(self):
        from IronPythonTest import UnaryClass, BaseClass, BaseClassStaticConstructor
        if is_netcoreapp:
            clr.AddReference('System.Drawing.Primitives')
        else:
            clr.AddReference('System.Drawing')

        from System.Drawing import Point

        self.assertEqual(repr(Point(1,2)).startswith('<System.Drawing.Point object'), True)
        self.assertEqual(repr(Point(1,2)).endswith('[{X=1,Y=2}]>'),True)
        
        # these 3 classes define the same repr w/ different \r, \r\n, \n versions
        a = UnaryClass(3)
        b = BaseClass()
        c = BaseClassStaticConstructor()
        
        ra = repr(a)
        rb = repr(b)
        rc = repr(c)
        
        sa = ra.find('HelloWorld')
        sb = rb.find('HelloWorld')
        sc = rc.find('HelloWorld')
        
        self.assertEqual(ra[sa:sa+13], rb[sb:sb+13])
        self.assertEqual(rb[sb:sb+13], rc[sc:sc+13])
        self.assertEqual(ra[sa:sa+13], 'HelloWorld...') # \r\n should be removed, replaced with ... 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:30,代碼來源:test_cliclass.py

示例8: test_property_get_set

# 需要導入模塊: import System [as 別名]
# 或者: from System import Drawing [as 別名]
def test_property_get_set(self):
        if is_netcoreapp:
            clr.AddReference("System.Drawing.Primitives")
        else:
            clr.AddReference("System.Drawing")
        from System.Drawing import Size
        
        temp = Size()
        self.assertEqual(temp.Width, 0)
        temp.Width = 5
        self.assertEqual(temp.Width, 5)
            
        for i in xrange(5):
            temp.Width = i
            self.assertEqual(temp.Width, i) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:17,代碼來源:test_cliclass.py

示例9: test_property_get_set

# 需要導入模塊: import System [as 別名]
# 或者: from System import Drawing [as 別名]
def test_property_get_set(self):
        if is_netcoreapp:
            clr.AddReference("System.Drawing.Primitives")
        else:
            clr.AddReference("System.Drawing")
        from System.Drawing import Size
        
        temp = Size()
        self.assertEqual(temp.Width, 0)
        temp.Width = 5
        self.assertEqual(temp.Width, 5)
            
        for i in range(5):
            temp.Width = i
            self.assertEqual(temp.Width, i) 
開發者ID:IronLanguages,項目名稱:ironpython3,代碼行數:17,代碼來源:test_cliclass.py


注:本文中的System.Drawing方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。