当前位置: 首页>>代码示例>>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;未经允许,请勿转载。