MCPcopy Index your code
hub / github.com/PySimpleGUI/PySimpleGUI / Graph

Class Graph

PySimpleGUI/PySimpleGUI.py:6140–6895  ·  view source on GitHub ↗

Creates an area for you to draw on. The MAGICAL property this Element has is that you interact with the element using your own coordinate system. This is an important point!! YOU define where the location is for (0,0). Want (0,0) to be in the middle of the graph like a math 4-quadra

Source from the content-addressed store, hash-verified

6138# Graph #
6139# ---------------------------------------------------------------------- #
6140class Graph(Element):
6141 """
6142 Creates an area for you to draw on. The MAGICAL property this Element has is that you interact
6143 with the element using your own coordinate system. This is an important point!! YOU define where the location
6144 is for (0,0). Want (0,0) to be in the middle of the graph like a math 4-quadrant graph? No problem! Set your
6145 lower left corner to be (-100,-100) and your upper right to be (100,100) and you've got yourself a graph with
6146 (0,0) at the center.
6147 One of THE coolest of the Elements.
6148 You can also use float values. To do so, be sure and set the float_values parameter.
6149 Mouse click and drag events are possible and return the (x,y) coordinates of the mouse
6150 Drawing primitives return an "id" that is referenced when you want to operation on that item (e.g. to erase it)
6151 """
6152
6153 def __init__(self, canvas_size, graph_bottom_left, graph_top_right, background_color=None, pad=None, p=None,
6154 change_submits=False, drag_submits=False, enable_events=False, motion_events=False, key=None, k=None, tooltip=None,
6155 right_click_menu=None, expand_x=False, expand_y=False, visible=True, float_values=False, border_width=0, metadata=None):
6156 """
6157 :param canvas_size: size of the canvas area in pixels
6158 :type canvas_size: (int, int)
6159 :param graph_bottom_left: (x,y) The bottoms left corner of your coordinate system
6160 :type graph_bottom_left: (int, int)
6161 :param graph_top_right: (x,y) The top right corner of your coordinate system
6162 :type graph_top_right: (int, int)
6163 :param background_color: background color of the drawing area
6164 :type background_color: (str)
6165 :param pad: Amount of padding to put around element in pixels (left/right, top/bottom) or ((left, right), (top, bottom)) or an int. If an int, then it's converted into a tuple (int, int)
6166 :type pad: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) | int
6167 :param p: Same as pad parameter. It's an alias. If EITHER of them are set, then the one that's set will be used. If BOTH are set, pad will be used
6168 :type p: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) | int
6169 :param change_submits: * DEPRICATED DO NOT USE. Use `enable_events` instead
6170 :type change_submits: (bool)
6171 :param drag_submits: if True and Events are enabled for the Graph, will report Events any time the mouse moves while button down. When the mouse button is released, you'll get an event = graph key + '+UP' (if key is a string.. if not a string, it'll be made into a tuple)
6172 :type drag_submits: (bool)
6173 :param enable_events: If True then clicks on the Graph are immediately reported as an event. Use this instead of change_submits
6174 :type enable_events: (bool)
6175 :param motion_events: If True then if no button is down and the mouse is moved, an event is generated with key = graph key + '+MOVE' (if key is a string, it not a string then a tuple is returned)
6176 :type motion_events: (bool)
6177 :param key: Value that uniquely identifies this element from all other elements. Used when Finding an element or in return values. Must be unique to the window
6178 :type key: str | int | tuple | object
6179 :param k: Same as the Key. You can use either k or key. Which ever is set will be used.
6180 :type k: str | int | tuple | object
6181 :param tooltip: text, that will appear when mouse hovers over the element
6182 :type tooltip: (str)
6183 :param right_click_menu: A list of lists of Menu items to show when this element is right clicked. See user docs for exact format.
6184 :type right_click_menu: List[List[ List[str] | str ]]
6185 :param expand_x: If True the element will automatically expand in the X direction to fill available space
6186 :type expand_x: (bool)
6187 :param expand_y: If True the element will automatically expand in the Y direction to fill available space
6188 :type expand_y: (bool)
6189 :param visible: set visibility state of the element (Default = True)
6190 :type visible: (bool)
6191 :param float_values: If True x,y coordinates are returned as floats, not ints
6192 :type float_values: (bool)
6193 :param border_width: width of border around element in pixels. Not normally used for Graph Elements
6194 :type border_width: (int)
6195 :param metadata: User metadata that can be set to ANYTHING
6196 :type metadata: (Any)
6197 """

Callers 2

notifyMethod · 0.85
_create_main_windowFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected