Merge pull request #1416 from PySimpleGUI/Dev-latest
Fix from user musteresel - uses dictionary to save images in so no mo…
This commit is contained in:
commit
2284be6ee2
|
@ -2032,7 +2032,7 @@ class Graph(Element):
|
|||
self.DragSubmits = drag_submits
|
||||
self.ClickPosition = (None, None)
|
||||
self.MouseButtonDown = False
|
||||
self.Images = []
|
||||
self.Images = {}
|
||||
self.RightClickMenu = right_click_menu
|
||||
|
||||
super().__init__(ELEM_TYPE_GRAPH, background_color=background_color, size=canvas_size, pad=pad, key=key,
|
||||
|
@ -2190,6 +2190,7 @@ class Graph(Element):
|
|||
self.Images.append(image)
|
||||
try: # in case closed with X
|
||||
id = self._TKCanvas2.create_image(converted_point, image=image, anchor=tk.NW)
|
||||
self.Images[id] = image
|
||||
except:
|
||||
id = None
|
||||
return id
|
||||
|
@ -2201,6 +2202,7 @@ class Graph(Element):
|
|||
print('*** WARNING - The Graph element has not been finalized and cannot be drawn upon ***')
|
||||
print('Call Window.Finalize() prior to this operation')
|
||||
return None
|
||||
self.Images = {}
|
||||
try: # in case window was closed with X
|
||||
self._TKCanvas2.delete('all')
|
||||
except:
|
||||
|
@ -2209,6 +2211,7 @@ class Graph(Element):
|
|||
|
||||
def DeleteFigure(self, id):
|
||||
try:
|
||||
del self.Images[id]
|
||||
self._TKCanvas2.delete(id)
|
||||
except:
|
||||
print('DeleteFigure - bad ID {}'.format(id))
|
||||
|
|
Loading…
Reference in New Issue