当前位置: 首页>>代码示例>>Python>>正文


Python tkinter.BitmapImage方法代码示例

本文整理汇总了Python中tkinter.BitmapImage方法的典型用法代码示例。如果您正苦于以下问题:Python tkinter.BitmapImage方法的具体用法?Python tkinter.BitmapImage怎么用?Python tkinter.BitmapImage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tkinter的用法示例。


在下文中一共展示了tkinter.BitmapImage方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import BitmapImage [as 别名]
def __init__(self, image=None, **kw):

        # Tk compatibility: file or data
        if image is None:
            image = _get_image_from_kw(kw)

        self.__mode = image.mode
        self.__size = image.size

        if _pilbitmap_check():
            # fast way (requires the pilbitmap booster patch)
            image.load()
            kw["data"] = "PIL:%d" % image.im.id
            self.__im = image  # must keep a reference
        else:
            # slow but safe way
            kw["data"] = image.tobitmap()
        self.__photo = tkinter.BitmapImage(**kw) 
开发者ID:tp4a,项目名称:teleport,代码行数:20,代码来源:ImageTk.py

示例2: _show

# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import BitmapImage [as 别名]
def _show(image, title):
    """Helper for the Image.show method."""

    class UI(tkinter.Label):
        def __init__(self, master, im):
            if im.mode == "1":
                self.image = BitmapImage(im, foreground="white", master=master)
            else:
                self.image = PhotoImage(im, master=master)
            tkinter.Label.__init__(self, master, image=self.image,
                                   bg="black", bd=0)

    if not tkinter._default_root:
        raise IOError("tkinter not initialized")
    top = tkinter.Toplevel()
    if title:
        top.title(title)
    UI(top, image).pack() 
开发者ID:tp4a,项目名称:teleport,代码行数:20,代码来源:ImageTk.py

示例3: _show

# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import BitmapImage [as 别名]
def _show(image, title):
    """Helper for the Image.show method."""

    class UI(tkinter.Label):
        def __init__(self, master, im):
            if im.mode == "1":
                self.image = BitmapImage(im, foreground="white", master=master)
            else:
                self.image = PhotoImage(im, master=master)
            super().__init__(master, image=self.image, bg="black", bd=0)

    if not tkinter._default_root:
        raise OSError("tkinter not initialized")
    top = tkinter.Toplevel()
    if title:
        top.title(title)
    UI(top, image).pack() 
开发者ID:tp4a,项目名称:teleport,代码行数:19,代码来源:ImageTk.py

示例4: _pilbitmap_check

# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import BitmapImage [as 别名]
def _pilbitmap_check():
    global _pilbitmap_ok
    if _pilbitmap_ok is None:
        try:
            im = Image.new("1", (1, 1))
            tkinter.BitmapImage(data="PIL:%d" % im.im.id)
            _pilbitmap_ok = 1
        except tkinter.TclError:
            _pilbitmap_ok = 0
    return _pilbitmap_ok 
开发者ID:tp4a,项目名称:teleport,代码行数:12,代码来源:ImageTk.py

示例5: __str__

# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import BitmapImage [as 别名]
def __str__(self):
        """
        Get the Tkinter bitmap image identifier.  This method is automatically
        called by Tkinter whenever a BitmapImage object is passed to a Tkinter
        method.

        :return: A Tkinter bitmap image identifier (a string).
        """
        return str(self.__photo) 
开发者ID:tp4a,项目名称:teleport,代码行数:11,代码来源:ImageTk.py

示例6: test_create_from_file

# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import BitmapImage [as 别名]
def test_create_from_file(self):
        image = tkinter.BitmapImage('::img::test', master=self.root,
                                    foreground='yellow', background='blue',
                                    file=self.testfile)
        self.assertEqual(str(image), '::img::test')
        self.assertEqual(image.type(), 'bitmap')
        self.assertEqual(image.width(), 16)
        self.assertEqual(image.height(), 16)
        self.assertIn('::img::test', self.root.image_names())
        del image
        self.assertNotIn('::img::test', self.root.image_names()) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:13,代码来源:test_images.py

示例7: test_create_from_data

# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import BitmapImage [as 别名]
def test_create_from_data(self):
        with open(self.testfile, 'rb') as f:
            data = f.read()
        image = tkinter.BitmapImage('::img::test', master=self.root,
                                    foreground='yellow', background='blue',
                                    data=data)
        self.assertEqual(str(image), '::img::test')
        self.assertEqual(image.type(), 'bitmap')
        self.assertEqual(image.width(), 16)
        self.assertEqual(image.height(), 16)
        self.assertIn('::img::test', self.root.image_names())
        del image
        self.assertNotIn('::img::test', self.root.image_names()) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:15,代码来源:test_images.py

示例8: test_configure_data

# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import BitmapImage [as 别名]
def test_configure_data(self):
        image = tkinter.BitmapImage('::img::test', master=self.root)
        self.assertEqual(image['data'], '-data {} {} {} {}')
        with open(self.testfile, 'rb') as f:
            data = f.read()
        image.configure(data=data)
        self.assertEqualStrList(image['data'],
                                ('-data', '', '', '', data.decode('ascii')))
        self.assertEqual(image.width(), 16)
        self.assertEqual(image.height(), 16)

        self.assertEqual(image['maskdata'], '-maskdata {} {} {} {}')
        image.configure(maskdata=data)
        self.assertEqualStrList(image['maskdata'],
                                ('-maskdata', '', '', '', data.decode('ascii'))) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:17,代码来源:test_images.py

示例9: test_configure_file

# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import BitmapImage [as 别名]
def test_configure_file(self):
        image = tkinter.BitmapImage('::img::test', master=self.root)
        self.assertEqual(image['file'], '-file {} {} {} {}')
        image.configure(file=self.testfile)
        self.assertEqualStrList(image['file'],
                                ('-file', '', '', '',self.testfile))
        self.assertEqual(image.width(), 16)
        self.assertEqual(image.height(), 16)

        self.assertEqual(image['maskfile'], '-maskfile {} {} {} {}')
        image.configure(maskfile=self.testfile)
        self.assertEqualStrList(image['maskfile'],
                                ('-maskfile', '', '', '', self.testfile)) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:15,代码来源:test_images.py

示例10: test_configure_background

# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import BitmapImage [as 别名]
def test_configure_background(self):
        image = tkinter.BitmapImage('::img::test', master=self.root)
        self.assertEqual(image['background'], '-background {} {} {} {}')
        image.configure(background='blue')
        self.assertEqual(image['background'], '-background {} {} {} blue') 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:7,代码来源:test_images.py


注:本文中的tkinter.BitmapImage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。