MCPcopy
hub / github.com/PySimpleGUI/PySimpleGUI / _convert_xy_to_canvas_xy

Method _convert_xy_to_canvas_xy

PySimpleGUI/PySimpleGUI.py:6222–6242  ·  view source on GitHub ↗

Not user callable. Used to convert user's coordinates into the ones used by tkinter :param x_in: The x coordinate to convert :type x_in: int | float :param y_in: The y coordinate to convert :type y_in: int | float :return: (int, int) The conver

(self, x_in, y_in)

Source from the content-addressed store, hash-verified

6220 return
6221
6222 def _convert_xy_to_canvas_xy(self, x_in, y_in):
6223 """
6224 Not user callable. Used to convert user's coordinates into the ones used by tkinter
6225 :param x_in: The x coordinate to convert
6226 :type x_in: int | float
6227 :param y_in: The y coordinate to convert
6228 :type y_in: int | float
6229 :return: (int, int) The converted canvas coordinates
6230 :rtype: (int, int)
6231 """
6232 if None in (x_in, y_in):
6233 return None, None
6234 try:
6235 scale_x = (self.CanvasSize[0] - 0) / (self.TopRight[0] - self.BottomLeft[0])
6236 scale_y = (0 - self.CanvasSize[1]) / (self.TopRight[1] - self.BottomLeft[1])
6237 except:
6238 scale_x = scale_y = 0
6239
6240 new_x = 0 + scale_x * (x_in - self.BottomLeft[0])
6241 new_y = self.CanvasSize[1] + scale_y * (y_in - self.BottomLeft[1])
6242 return new_x, new_y
6243
6244 def _convert_canvas_xy_to_xy(self, x_in, y_in):
6245 """

Callers 14

draw_lineMethod · 0.95
draw_linesMethod · 0.95
draw_pointMethod · 0.95
draw_circleMethod · 0.95
draw_ovalMethod · 0.95
draw_arcMethod · 0.95
draw_rectangleMethod · 0.95
draw_polygonMethod · 0.95
draw_textMethod · 0.95
draw_imageMethod · 0.95
moveMethod · 0.95
move_figureMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected