Hello there!
I have been trying to make a window with a collapsible layout, and that’s working great. However, I am also trying to make this window have the ability to be floating or dock-able depending on the artists needs.
To do this, I have used the workspaceControl and parented the window I am creating, into it.
The issue that is happening is that when I resize the window inside the control, and then try to resize the workspaceControl, the workspaceControl will not adjust height back down to the window.
I know that I could do this with QT if I had the knowledge, but I don’t, and learning a whole new language at the moment would be rough.
Any help would be greatly appreciated!! Thank you!
import maya.cmds as mc
from functools import partial
class MainClassToolBox:
def __init__(self):
self.tbWinID = 'ToolsWindow_v002'
self.tbWorkID = 'ToolBox_v002_WorkspaceControl'
self.toolBoxUI()
def toolBoxUI(self, *args):
if mc.window(self.tbWinID, exists=True):
mc.deleteUI(self.tbWinID, wnd=True)
if mc.workspaceControl(self.tbWorkID, q=True, exists=True):
mc.deleteUI(self.tbWorkID)
mc.workspaceControl(self.tbWorkID, retain=False, label='Tool_Box')
mc.window(self.tbWinID, sizeable=False, toolbox=True)
mc.tabLayout('toolsTabs')
tabMenu = mc.columnLayout("Menu", adj=False)
self.tbFileTab = mc.frameLayout(
label="File",
bgc=(0.3, 0.3, 0.3),
collapsable=True,
collapse=True,
collapseCommand=partial(self.tbResizeWin, tbTabHeightWin=66),
expandCommand=partial(self.tbResizeWin, tbTabHeightWin=(-66)))
mc.columnLayout(nch=6, parent=self.tbFileTab, adj=True)
mc.textField("tbTransformMin", h=30, w=50, placeholderText="min")
mc.textField("tbTransformMax", h=30, w=50, placeholderText="min")
self.tbTransformRB = mc.nodeIconButton(label="rotate",
backgroundColor=(0.2, 0.2, 0.2),
height=32,
width=32,
command=partial(self.button_cmd),
ann='LMB: random rotate Y // LMBDbl: random rotate XYZ // RMB: Choose input method or a preset')
mc.setParent('..')
mc.showWindow(self.tbWinID)
mc.window(self.tbWinID, edit=True, width=150, h=125)
mc.control(self.tbWinID, edit=True, parent=self.tbWorkID)
def random_transform_RB(self, options, *args):
for opt in options:
if mc.menuItem(opt, q=True, radioButton=True):
return True
def button_cmd(self, *args):
print 'hello world'
def tbResizeWin(self, tbTabHeightWin, _=False):
tbWindowSize = mc.window(self.tbWinID, query=True, height=True)
mc.window(self.tbWinID, edit=True, height=(tbWindowSize-tbTabHeightWin))
mc.workspaceControl(self.tbWorkID, edit=True, resizeHeight=(tbWindowSize-tbTabHeightWin))
mc.window(self.tbWinID, edit=True, topLeftCorner=[0,0])
def main():
mainClass = MainClassToolBox()
mainClass.__init__()
#import tool_box_simple
#reload(tool_box_simple)
#tool_box_simple.main()
pointed to where I am using the workspace control.