Merge pull request #2748 from PySimpleGUI/Dev-latest

Added Graph.DrawLines (draw_lines)
This commit is contained in:
PySimpleGUI 2020-03-31 09:16:43 -04:00 committed by GitHub
commit d282613147
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 28 additions and 2 deletions

View File

@ -1,6 +1,6 @@
#!/usr/bin/python3
version = __version__ = "4.18.0.6 Unreleased - Print and MLine.Print fixed sep char handling, popup_get_date, icon parm popup_animated, popup button size (6,1), NEW CALENDAR chooser integrated"
version = __version__ = "4.18.0.7 Unreleased - Print and MLine.Print fixed sep char handling, popup_get_date, icon parm popup_animated, popup button size (6,1), NEW CALENDAR chooser integrated, Graph.draw_lines"
port = 'PySimpleGUI'
@ -3743,6 +3743,31 @@ class Graph(Element):
id = None
return id
def DrawLines(self, points, color='black', width=1):
"""
Draw a series of lines given list of points
:param points: list of points that define the polygon
:type points: List[Union[Tuple[int, int], Tuple[float, float]]]
:param color: Color of the line
:type color: (str)
:param width: width of line in pixels
:type width: (int)
:return: id returned from tktiner or None if user closed the window. id is used when you
:rtype: Union[int, None]
"""
converted_points = [self._convert_xy_to_canvas_xy(point[0], point[1]) for point in points]
if self._TKCanvas2 is None:
print('*** WARNING - The Graph element has not been finalized and cannot be drawn upon ***')
print('Call Window.Finalize() prior to this operation')
return None
try: # in case window was closed with an X
id = self._TKCanvas2.create_line(*converted_points, width=width, fill=color)
except:
id = None
return id
def DrawPoint(self, point, size=2, color='black'):
"""
Draws a "dot" at the point you specify using the USER'S coordinate system
@ -3914,7 +3939,7 @@ class Graph(Element):
def DrawPolygon(self, points, fill_color=None, line_color=None, line_width=None):
"""
Draw a rectangle given 2 points. Can control the line and fill colors
Draw a polygon given list of points
:param points: list of points that define the polygon
:type points: List[Union[Tuple[int, int], Tuple[float, float]]]
@ -4269,6 +4294,7 @@ class Graph(Element):
draw_oval = DrawOval
draw_point = DrawPoint
draw_polygon = DrawPolygon
draw_lines = DrawLines
draw_rectangle = DrawRectangle
draw_text = DrawText
get_figures_at_location = GetFiguresAtLocation