window resize functionalliy (nice)
finally!
This commit is contained in:
33
SpyderScripts/resize_window.py
Normal file
33
SpyderScripts/resize_window.py
Normal file
@@ -0,0 +1,33 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Core module for resizing the active window on macOS.
|
||||
"""
|
||||
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
|
||||
def resize_active_window(width: int, height: int):
|
||||
"""
|
||||
Resize the currently active window to the specified dimensions.
|
||||
Keeps the window in its current position.
|
||||
|
||||
Args:
|
||||
width: Target width in pixels
|
||||
height: Target height in pixels
|
||||
"""
|
||||
applescript = f'''
|
||||
tell application "System Events"
|
||||
set frontApp to first application process whose frontmost is true
|
||||
tell frontApp
|
||||
set size of window 1 to {{{width}, {height}}}
|
||||
end tell
|
||||
end tell
|
||||
'''
|
||||
|
||||
try:
|
||||
subprocess.run(['osascript', '-e', applescript], check=True, capture_output=True)
|
||||
print(f"✓ Resized active window to {width}x{height}")
|
||||
except subprocess.CalledProcessError as e:
|
||||
print(f"✗ Error resizing window: {e.stderr.decode()}")
|
||||
sys.exit(1)
|
||||
9
SpyderScripts/window_maximum.py
Normal file
9
SpyderScripts/window_maximum.py
Normal file
@@ -0,0 +1,9 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Resize active window to Maximum preset (2400x3500)
|
||||
"""
|
||||
|
||||
from resize_window import resize_active_window
|
||||
|
||||
if __name__ == "__main__":
|
||||
resize_active_window(width=2400, height=3500)
|
||||
9
SpyderScripts/window_medium.py
Normal file
9
SpyderScripts/window_medium.py
Normal file
@@ -0,0 +1,9 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Resize active window to Medium preset (2300x2250)
|
||||
"""
|
||||
|
||||
from resize_window import resize_active_window
|
||||
|
||||
if __name__ == "__main__":
|
||||
resize_active_window(width=2300, height=2250)
|
||||
9
SpyderScripts/window_minimal.py
Normal file
9
SpyderScripts/window_minimal.py
Normal file
@@ -0,0 +1,9 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Resize active window to Minimal preset (2042x1262)
|
||||
"""
|
||||
|
||||
from resize_window import resize_active_window
|
||||
|
||||
if __name__ == "__main__":
|
||||
resize_active_window(width=2042, height=1262)
|
||||
9
SpyderScripts/window_minimalist.py
Normal file
9
SpyderScripts/window_minimalist.py
Normal file
@@ -0,0 +1,9 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Resize active window to Minimalist preset (1250x810)
|
||||
"""
|
||||
|
||||
from resize_window import resize_active_window
|
||||
|
||||
if __name__ == "__main__":
|
||||
resize_active_window(width=1250, height=810)
|
||||
Reference in New Issue
Block a user