Places an image onto your canvas. It's a really important method for this element as it enables so much :param filename: if image is in a file, path and filename for the image. (GIF and PNG only!) :type filename: (str) :param data: if image is in Base64 format
(self, filename=None, data=None, location=(None, None))
| 6552 | return id |
| 6553 | |
| 6554 | def draw_image(self, filename=None, data=None, location=(None, None)): |
| 6555 | """ |
| 6556 | Places an image onto your canvas. It's a really important method for this element as it enables so much |
| 6557 | |
| 6558 | :param filename: if image is in a file, path and filename for the image. (GIF and PNG only!) |
| 6559 | :type filename: (str) |
| 6560 | :param data: if image is in Base64 format or raw? format then use instead of filename |
| 6561 | :type data: str | bytes |
| 6562 | :param location: the (x,y) location to place image's top left corner |
| 6563 | :type location: (int, int) | Tuple[float, float] |
| 6564 | :return: id returned from tkinter that you'll need if you want to manipulate the image |
| 6565 | :rtype: int | None |
| 6566 | """ |
| 6567 | if location == (None, None): |
| 6568 | return |
| 6569 | if filename is not None: |
| 6570 | image = tk.PhotoImage(file=filename) |
| 6571 | elif data is not None: |
| 6572 | # if type(data) is bytes: |
| 6573 | try: |
| 6574 | image = tk.PhotoImage(data=data) |
| 6575 | except: |
| 6576 | return None # an error likely means the window has closed so exit |
| 6577 | converted_point = self._convert_xy_to_canvas_xy(location[0], location[1]) |
| 6578 | if self._TKCanvas2 is None: |
| 6579 | print('*** WARNING - The Graph element has not been finalized and cannot be drawn upon ***') |
| 6580 | print('Call Window.Finalize() prior to this operation') |
| 6581 | return None |
| 6582 | try: # in case closed with X |
| 6583 | id = self._TKCanvas2.create_image(converted_point, image=image, anchor=tk.NW) |
| 6584 | self.Images[id] = image |
| 6585 | except: |
| 6586 | id = None |
| 6587 | return id |
| 6588 | |
| 6589 | def erase(self): |
| 6590 | """ |
no test coverage detected