-
Notifications
You must be signed in to change notification settings - Fork 0
/
aux_functions.py
40 lines (33 loc) · 1012 Bytes
/
aux_functions.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
def window_centre(position,size):
"""
Calculates a window's centre from it's position and size
Parameters
----------
position : tuple(x,y)
position of the window in pixels.
size : TYPE
size of the window in pixels.
Returns
-------
centre : tuple(x,y)
the coordinates of the window's centre.
"""
centre=[s/2+p for p,s in zip(position,size)]
return tuple(centre)
def TL_from_centre(parent_centre, child_size):
"""
Calculates the requires location of a windows top-left corner, so that its
centre and that of the parent window are aligned
Parameters
----------
parent_centre : tuple(x,y)
coordinates of the parent window's centre.
child_size : tuple(x,y)
dimensions of the child window.
Returns
-------
position : tuple(x,y)
coordinates of the child window's top-left corner.
"""
position=[c-s/2 for c,s in zip(parent_centre,child_size)]
return tuple(position)