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


Python Tkinter.BitmapImage方法代码示例

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


在下文中一共展示了Tkinter.BitmapImage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: _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

# --------------------------------------------------------------------
# PhotoImage

##
# Creates a Tkinter-compatible photo image.  This can be used
# everywhere Tkinter expects an image object.  If the image is an RGBA
# image, pixels having alpha 0 are treated as transparent. 
开发者ID:cineuse,项目名称:CNCGToolKit,代码行数:20,代码来源:ImageTk.py

示例4: __init__

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

        # Tk compatibility: file or data
        if image is None:
            if kw.has_key("file"):
                image = Image.open(kw["file"])
                del kw["file"]
            elif kw.has_key("data"):
                from StringIO import StringIO
                image = Image.open(StringIO(kw["data"]))
                del kw["data"]

        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 = apply(Tkinter.BitmapImage, (), kw) 
开发者ID:cineuse,项目名称:CNCGToolKit,代码行数:26,代码来源:ImageTk.py

示例5: _show

# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import BitmapImage [as 别名]
def _show(image, title):

    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:cineuse,项目名称:CNCGToolKit,代码行数:19,代码来源:ImageTk.py

示例6: update

# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import BitmapImage [as 别名]
def update(self, widget):
        assert isinstance(widget, tk.Widget) or isinstance(widget, tk.BitmapImage), widget
        if not self.current:
            return	# No need to call this for widgets created in plugin_app()
        self.register(widget)
        self._update_widget(widget)
        if isinstance(widget, tk.Frame) or isinstance(widget, ttk.Frame):
            for child in widget.winfo_children():
                self._update_widget(child)

    # Apply current theme to a single widget 
开发者ID:EDCD,项目名称:EDMarketConnector,代码行数:13,代码来源:theme.py

示例7: 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:aliyun,项目名称:oss-ftp,代码行数:13,代码来源:test_images.py

示例8: 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:aliyun,项目名称:oss-ftp,代码行数:15,代码来源:test_images.py

示例9: 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))
        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)) 
开发者ID:aliyun,项目名称:oss-ftp,代码行数:17,代码来源:test_images.py

示例10: 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:aliyun,项目名称:oss-ftp,代码行数:15,代码来源:test_images.py

示例11: 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:aliyun,项目名称:oss-ftp,代码行数:7,代码来源:test_images.py

示例12: _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

示例13: __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

示例14: paste

# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import BitmapImage [as 别名]
def paste(self, im, box=None):

        # convert to blittable
        im.load()
        image = im.im
        if image.isblock() and im.mode == self.__mode:
            block = image
        else:
            block = image.new_block(self.__mode, im.size)
            image.convert2(block, image) # convert directly between buffers

        tk = self.__photo.tk

        try:
            tk.call("PyImagingPhoto", self.__photo, block.id)
        except Tkinter.TclError, v:
            # activate Tkinter hook
            try:
                import _imagingtk
                try:
                    _imagingtk.tkinit(tk.interpaddr(), 1)
                except AttributeError:
                    _imagingtk.tkinit(id(tk), 0)
                tk.call("PyImagingPhoto", self.__photo, block.id)
            except (ImportError, AttributeError, Tkinter.TclError):
                raise # configuration problem; cannot attach to Tkinter

# --------------------------------------------------------------------
# BitmapImage

##
# Create a Tkinter-compatible bitmap image.  This can be used
# everywhere Tkinter expects an image object. 
开发者ID:cineuse,项目名称:CNCGToolKit,代码行数:35,代码来源:ImageTk.py

示例15: height

# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import BitmapImage [as 别名]
def height(self):
        return self.__size[1]

    ##
    # 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). 
开发者ID:cineuse,项目名称:CNCGToolKit,代码行数:11,代码来源:ImageTk.py


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