Dock any window

One thing that has always bothered me in Maya was that some windows were dockable, but some weren’t. Especially the outliner not being dockable by default has always irritated the crap out of me. That’s why I made this very small, simple script that allows you to take any open window and dock it on the left, right, top or bottom. That way you can merrily work away in 4 views while still having another window docked on the side. Grab it here.

Screenshot_1

Screenshot_2

##############################################
#
#
# dockAnyWindows.py
# This script shows you all open windows in Maya and allows you to dock them anywhere
#
#
##############################################

import maya.cmds as cmds

#var for the window width 
windowWidth = 600

def CreateUI():
	#check to see if the window exists
	if cmds.window("dock_any_window", exists = True):
		cmds.deleteUI("dock_any_window")

	#create the window
	cmds.window("dock_any_window", title="Dock any window", w = windowWidth, topLeftCorner = (0, 0), mnb = False, mxb = False, sizeable = False)

	#############################
	#
	# Create the main layout
	#
	#############################
	mainLayout = cmds.columnLayout(w = windowWidth)

	cmds.text(label = "Windows found")

	cmds.separator(height = 10, style = "none")

	cmds.rowColumnLayout(numberOfColumns = 2, columnWidth = [(1, (windowWidth / 2)), (2, (windowWidth / 2))])
	cmds.textScrollList("txtScrOpenWindows", h = 100, doubleClickCommand = DockWindow)

	cmds.columnLayout(w = windowWidth / 2)
	cmds.button(label = "Reload list", w = windowWidth / 2, command = FillWindowsTextScrollList)
	cmds.button(label = "Dock this window", w = windowWidth / 2, command = DockWindow)
	
	cmds.rowColumnLayout(numberOfColumns = 2, columnWidth = [(1, windowWidth / 4), (2, windowWidth / 4), (3, windowWidth / 4), (4, windowWidth / 4)])
	cmds.radioCollection("radColDockLocation")
	cmds.radioButton("radLeft", label = "left", w = windowWidth / 4, select = True)
	cmds.radioButton("radRight", label = "right", w = windowWidth / 4)
	cmds.radioButton("radTop", label = "top", w = windowWidth / 4)
	cmds.radioButton("radBottom", label = "bottom", w = windowWidth / 4)
	cmds.setParent("..")


	cmds.separator(height = 25, style = "none")

	cmds.button(label = "Close selected window", width = windowWidth / 2, command = CloseWindow, backgroundColor = [1, 0, 0])

	cmds.setParent(mainLayout)

	#fill the text scroll list when the window is first opened
	FillWindowsTextScrollList()

	cmds.showWindow("dock_any_window")

def DockWindow(*args):
	try:
		windowName = cmds.textScrollList("txtScrOpenWindows", query = True, selectItem = True)[0]

		#check to see which radio button we have selected from the radiobutton collection
		selectedRadioButton = cmds.radioCollection("radColDockLocation", query = True, select = True)
		#get the label of the radio button, this is the area the window needs to be docked
		dockArea = cmds.radioButton(selectedRadioButton, query = True, label = True)

	except: 
		cmds.confirmDialog(title = "Dock any window", message = "Select a window from the list", icon = "warning")
		return

	#dock the selected window in the selected location
	cmds.dockControl(content = windowName, allowedArea = "all", area = dockArea)
		

def FillWindowsTextScrollList(*args):
	openWindows = cmds.lsUI(windows = True)

	try:
		cmds.textScrollList("txtScrOpenWindows", edit = True, removeAll = True)
		for openWindow in openWindows:
			cmds.textScrollList("txtScrOpenWindows", edit = True, append = openWindow)

	except:
		pass
	

def CloseWindow(*args):
	try:
		windowName = cmds.textScrollList("txtScrOpenWindows", query = True, selectItem = True)[0]

	except: 
		cmds.confirmDialog(title = "Dock any window", message = "Select a window from the list", icon = "warning")
		return

	cmds.deleteUI(windowName)
	FillWindowsTextScrollList()


CreateUI()

Share This: