代码拉取完成,页面将自动刷新
同步操作将从 openKylin/pillow 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
import unittest
from PIL import Image
from .helper import PillowTestCase, hopper
try:
from PIL import ImageTk
import tkinter as tk
dir(ImageTk)
HAS_TK = True
except (OSError, ImportError):
# Skipped via setUp()
HAS_TK = False
TK_MODES = ("1", "L", "P", "RGB", "RGBA")
@unittest.skipUnless(HAS_TK, "Tk not installed")
class TestImageTk(PillowTestCase):
def setUp(self):
try:
# setup tk
tk.Frame()
# root = tk.Tk()
except tk.TclError as v:
self.skipTest("TCL Error: %s" % v)
def test_kw(self):
TEST_JPG = "Tests/images/hopper.jpg"
TEST_PNG = "Tests/images/hopper.png"
with Image.open(TEST_JPG) as im1:
with Image.open(TEST_PNG) as im2:
with open(TEST_PNG, "rb") as fp:
data = fp.read()
kw = {"file": TEST_JPG, "data": data}
# Test "file"
im = ImageTk._get_image_from_kw(kw)
self.assert_image_equal(im, im1)
# Test "data"
im = ImageTk._get_image_from_kw(kw)
self.assert_image_equal(im, im2)
# Test no relevant entry
im = ImageTk._get_image_from_kw(kw)
self.assertIsNone(im)
def test_photoimage(self):
for mode in TK_MODES:
# test as image:
im = hopper(mode)
# this should not crash
im_tk = ImageTk.PhotoImage(im)
self.assertEqual(im_tk.width(), im.width)
self.assertEqual(im_tk.height(), im.height)
reloaded = ImageTk.getimage(im_tk)
self.assert_image_equal(reloaded, im.convert("RGBA"))
def test_photoimage_blank(self):
# test a image using mode/size:
for mode in TK_MODES:
im_tk = ImageTk.PhotoImage(mode, (100, 100))
self.assertEqual(im_tk.width(), 100)
self.assertEqual(im_tk.height(), 100)
# reloaded = ImageTk.getimage(im_tk)
# self.assert_image_equal(reloaded, im)
def test_bitmapimage(self):
im = hopper("1")
# this should not crash
im_tk = ImageTk.BitmapImage(im)
self.assertEqual(im_tk.width(), im.width)
self.assertEqual(im_tk.height(), im.height)
# reloaded = ImageTk.getimage(im_tk)
# self.assert_image_equal(reloaded, im)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。