Fix for grab anywhere window movement and control+left_mouse_drag. Window move smoother, including the Move-All-Windows feature. Thank you JASON for the help!
This commit is contained in:
parent
2470d10afc
commit
5f8735d1f3
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/bin/python3
|
#!/usr/bin/python3
|
||||||
|
|
||||||
version = __version__ = "4.61.0.199 Unreleased"
|
version = __version__ = "4.61.0.200 Unreleased"
|
||||||
|
|
||||||
_change_log = """
|
_change_log = """
|
||||||
Changelog since 4.60.0 released to PyPI on 8-May-2022
|
Changelog since 4.60.0 released to PyPI on 8-May-2022
|
||||||
|
@ -470,6 +470,8 @@ _change_log = """
|
||||||
Added no_buffering option to popup_animated
|
Added no_buffering option to popup_animated
|
||||||
4.61.0.199
|
4.61.0.199
|
||||||
Updated Udemy coupon code
|
Updated Udemy coupon code
|
||||||
|
4.61.0.200
|
||||||
|
Fix for grab anywhere window movement and control+left_mouse_drag. Window move smoother, including the Move-All-Windows feature. Thank you JASON for the help!
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -11745,8 +11747,8 @@ class Window:
|
||||||
:param event: event information passed in by tkinter. Contains x,y position of mouse
|
:param event: event information passed in by tkinter. Contains x,y position of mouse
|
||||||
:type event: (event)
|
:type event: (event)
|
||||||
"""
|
"""
|
||||||
|
self._start_move_save_offset(event)
|
||||||
self._StartMove(event)
|
return
|
||||||
|
|
||||||
|
|
||||||
def _StartMoveGrabAnywhere(self, event):
|
def _StartMoveGrabAnywhere(self, event):
|
||||||
|
@ -11760,31 +11762,11 @@ class Window:
|
||||||
if (isinstance(event.widget, GRAB_ANYWHERE_IGNORE_THESE_WIDGETS) or event.widget in self._grab_anywhere_ignore_these_list) and event.widget not in self._grab_anywhere_include_these_list:
|
if (isinstance(event.widget, GRAB_ANYWHERE_IGNORE_THESE_WIDGETS) or event.widget in self._grab_anywhere_ignore_these_list) and event.widget not in self._grab_anywhere_include_these_list:
|
||||||
# print('Found widget to ignore in grab anywhere...')
|
# print('Found widget to ignore in grab anywhere...')
|
||||||
return
|
return
|
||||||
|
self._start_move_save_offset(event)
|
||||||
self._StartMove(event)
|
|
||||||
|
|
||||||
|
|
||||||
def _StartMove(self, event):
|
def _StartMove(self, event):
|
||||||
try:
|
self._start_move_save_offset(event)
|
||||||
geometry = self.TKroot.geometry()
|
return
|
||||||
location = geometry[geometry.find('+')+1:].split('+')
|
|
||||||
self._startx = int(location[0])
|
|
||||||
self._starty = int(location[1])
|
|
||||||
self._mousex = event.x + event.widget.winfo_rootx()
|
|
||||||
self._mousey = event.y + event.widget.winfo_rooty()
|
|
||||||
# print(self._startx, self._starty)
|
|
||||||
# print(self._mousex, self._mousey)
|
|
||||||
# print(self.TKroot.geometry())
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
# print('Start move {},{} widget {}'.format(event.x,event.y, event.widget))
|
|
||||||
|
|
||||||
if Window._move_all_windows:
|
|
||||||
for window in Window._active_windows:
|
|
||||||
window._offsetx = event.x + event.widget.winfo_rootx() - window.TKroot.winfo_rootx()
|
|
||||||
window._offsety = event.y + event.widget.winfo_rooty() - window.TKroot.winfo_rooty()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def _StopMove(self, event):
|
def _StopMove(self, event):
|
||||||
"""
|
"""
|
||||||
|
@ -11795,6 +11777,28 @@ class Window:
|
||||||
"""
|
"""
|
||||||
return
|
return
|
||||||
|
|
||||||
|
def _start_move_save_offset(self, event):
|
||||||
|
self._mousex = event.x + event.widget.winfo_rootx()
|
||||||
|
self._mousey = event.y + event.widget.winfo_rooty()
|
||||||
|
geometry = self.TKroot.geometry()
|
||||||
|
location = geometry[geometry.find('+') + 1:].split('+')
|
||||||
|
self._startx = int(location[0])
|
||||||
|
self._starty = int(location[1])
|
||||||
|
self._mouse_offset_x = self._mousex - self._startx
|
||||||
|
self._mouse_offset_y = self._mousey - self._starty
|
||||||
|
# ------ Move All Windows code ------
|
||||||
|
if Window._move_all_windows:
|
||||||
|
# print('Moving all')
|
||||||
|
for win in Window._active_windows:
|
||||||
|
if win == self:
|
||||||
|
continue
|
||||||
|
geometry = win.TKroot.geometry()
|
||||||
|
location = geometry[geometry.find('+') + 1:].split('+')
|
||||||
|
_startx = int(location[0])
|
||||||
|
_starty = int(location[1])
|
||||||
|
win._mouse_offset_x = event.x_root - _startx
|
||||||
|
win._mouse_offset_y = event.y_root - _starty
|
||||||
|
|
||||||
|
|
||||||
def _OnMotionUsingControlKey(self, event):
|
def _OnMotionUsingControlKey(self, event):
|
||||||
self._OnMotion(event)
|
self._OnMotion(event)
|
||||||
|
@ -11815,22 +11819,16 @@ class Window:
|
||||||
|
|
||||||
|
|
||||||
def _OnMotion(self, event):
|
def _OnMotion(self, event):
|
||||||
try:
|
|
||||||
|
|
||||||
_mousex = event.x + event.widget.winfo_rootx()
|
self.TKroot.geometry(f"+{event.x_root-self._mouse_offset_x}+{event.y_root-self._mouse_offset_y}")
|
||||||
_mousey = event.y + event.widget.winfo_rooty()
|
# print(f"+{event.x_root}+{event.y_root}")
|
||||||
deltax = _mousex - self._mousex
|
# ------ Move All Windows code ------
|
||||||
deltay = _mousey - self._mousey
|
try:
|
||||||
x = self._startx + deltax
|
|
||||||
y = self._starty + deltay
|
|
||||||
self.TKroot.geometry("+%s+%s" % (x, y)) # this is what really moves the window
|
|
||||||
if Window._move_all_windows:
|
if Window._move_all_windows:
|
||||||
for window in Window._active_windows:
|
for win in Window._active_windows:
|
||||||
deltax = window._offsetx
|
if win == self:
|
||||||
deltay = window._offsety
|
continue
|
||||||
x = window.TKroot.winfo_pointerx() - deltax
|
win.TKroot.geometry(f"+{event.x_root-win._mouse_offset_x}+{event.y_root-win._mouse_offset_y}")
|
||||||
y = window.TKroot.winfo_pointery() - deltay
|
|
||||||
window.TKroot.geometry("+%s+%s" % (x, y)) # this is what really moves the window
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print('on motion error', e)
|
print('on motion error', e)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue