Skip to content

Python: Controlling window size and position

by nikos on May 7th, 2011

32 bit Maya Windows users can control the size and position of a window by querying the GetSystemMetrics command that is part of the win32api module.

import sys
sys.path.append( 'c:/python26//lib/site-packages/win32' )     # Path to Python package
from win32api import GetSystemMetrics
import maya.cmds as cmds

# Create a window that is exactly center on screen
systemWidth = GetSystemMetrics (0)
systemHeight = GetSystemMetrics (1)
width = systemWidth / 2
height = systemHeight / 2
left = width / 2
top = height / 2

window = cmds.window()
cmds.showWindow( window )
cmds.window( window, edit=True, topLeftCorner=( top, left ), widthHeight=( width, height ) )

From → Python

No comments yet

Leave a Reply

You must be logged in to post a comment.