MCPcopy
hub / github.com/PySimpleGUI/PySimpleGUI / draw_rectangle

Method draw_rectangle

PySimpleGUI/PySimpleGUI.py:6460–6492  ·  view source on GitHub ↗

Draw a rectangle given 2 points. Can control the line and fill colors :param top_left: the top left point of rectangle :type top_left: (int, int) | Tuple[float, float] :param bottom_right: the bottom right point of rectangle :type bottom_right: (in

(self, top_left, bottom_right, fill_color=None, line_color=None, line_width=None)

Source from the content-addressed store, hash-verified

6458 return id
6459
6460 def draw_rectangle(self, top_left, bottom_right, fill_color=None, line_color=None, line_width=None):
6461 """
6462 Draw a rectangle given 2 points. Can control the line and fill colors
6463
6464 :param top_left: the top left point of rectangle
6465 :type top_left: (int, int) | Tuple[float, float]
6466 :param bottom_right: the bottom right point of rectangle
6467 :type bottom_right: (int, int) | Tuple[float, float]
6468 :param fill_color: color of the interior
6469 :type fill_color: (str)
6470 :param line_color: color of outline
6471 :type line_color: (str)
6472 :param line_width: width of the line in pixels
6473 :type line_width: (int)
6474 :return: int | None id returned from tkinter that you'll need if you want to manipulate the rectangle
6475 :rtype: int | None
6476 """
6477
6478 converted_top_left = self._convert_xy_to_canvas_xy(top_left[0], top_left[1])
6479 converted_bottom_right = self._convert_xy_to_canvas_xy(bottom_right[0], bottom_right[1])
6480 if self._TKCanvas2 is None:
6481 print('*** WARNING - The Graph element has not been finalized and cannot be drawn upon ***')
6482 print('Call Window.Finalize() prior to this operation')
6483 return None
6484 if line_width is None:
6485 line_width = 1
6486 try: # in case closed with X
6487 id = self._TKCanvas2.create_rectangle(converted_top_left[0], converted_top_left[1],
6488 converted_bottom_right[0],
6489 converted_bottom_right[1], fill=fill_color, outline=line_color, width=line_width)
6490 except:
6491 id = None
6492 return id
6493
6494 def draw_polygon(self, points, fill_color=None, line_color=None, line_width=None):
6495 """

Callers 15

mainFunction · 0.95
mainFunction · 0.95
__init__Method · 0.80
Demo_Bar_Chart.pyFile · 0.80
_display_notificationFunction · 0.80
display_notificationFunction · 0.80
mainFunction · 0.80
draw_barsFunction · 0.80

Calls 1

Tested by

no test coverage detected