Python tkinter.BitmapImage() Examples
The following are 30
code examples of tkinter.BitmapImage().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
tkinter
, or try the search function
.
Example #1
Source File: ImageTk.py From teleport with Apache License 2.0 | 6 votes |
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)
Example #2
Source File: ImageTk.py From lambda-text-extractor with Apache License 2.0 | 6 votes |
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()
Example #3
Source File: ImageTk.py From lambda-text-extractor with Apache License 2.0 | 6 votes |
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()
Example #4
Source File: ImageTk.py From lambda-text-extractor with Apache License 2.0 | 6 votes |
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)
Example #5
Source File: ImageTk.py From FODI with GNU General Public License v3.0 | 6 votes |
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()
Example #6
Source File: ImageTk.py From FODI with GNU General Public License v3.0 | 6 votes |
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)
Example #7
Source File: ImageTk.py From python3_ios with BSD 3-Clause "New" or "Revised" License | 6 votes |
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()
Example #8
Source File: ImageTk.py From python3_ios with BSD 3-Clause "New" or "Revised" License | 6 votes |
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)
Example #9
Source File: ImageTk.py From teleport with Apache License 2.0 | 6 votes |
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)
Example #10
Source File: ImageTk.py From teleport with Apache License 2.0 | 6 votes |
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()
Example #11
Source File: ImageTk.py From teleport with Apache License 2.0 | 6 votes |
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()
Example #12
Source File: ImageTk.py From lambda-text-extractor with Apache License 2.0 | 5 votes |
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
Example #13
Source File: test_images.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
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')))
Example #14
Source File: test_images.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
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))
Example #15
Source File: test_images.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
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')
Example #16
Source File: ImageTk.py From FODI with GNU General Public License v3.0 | 5 votes |
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
Example #17
Source File: ImageTk.py From teleport with Apache License 2.0 | 5 votes |
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)
Example #18
Source File: ImageTk.py From FODI with GNU General Public License v3.0 | 5 votes |
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)
Example #19
Source File: ImageTk.py From teleport with Apache License 2.0 | 5 votes |
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
Example #20
Source File: test_images.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
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())
Example #21
Source File: ImageTk.py From lambda-text-extractor with Apache License 2.0 | 5 votes |
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)
Example #22
Source File: ImageTk.py From teleport with Apache License 2.0 | 5 votes |
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)
Example #23
Source File: ImageTk.py From lambda-text-extractor with Apache License 2.0 | 5 votes |
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
Example #24
Source File: ImageTk.py From lambda-text-extractor with Apache License 2.0 | 5 votes |
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)
Example #25
Source File: ImageTk.py From teleport with Apache License 2.0 | 5 votes |
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
Example #26
Source File: test_images.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
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())
Example #27
Source File: test_images.py From ironpython3 with Apache License 2.0 | 5 votes |
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')
Example #28
Source File: test_images.py From ironpython3 with Apache License 2.0 | 5 votes |
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))
Example #29
Source File: test_images.py From ironpython3 with Apache License 2.0 | 5 votes |
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')))
Example #30
Source File: test_images.py From ironpython3 with Apache License 2.0 | 5 votes |
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())