Thanks! But I guess that would not solve my problem, because my menu is disapearing everytime I close the Camera Sequencer Window... not the Maya Window.
If this can help someone, I've come to this (not optimal, I guess) solution, based on other solutions I've found. While Maya is in Idle state, is constantly asking if Camera Sequencer is opened. When It's opened, It adds the Tools Menu on the window.
import maya.cmds as cmds
import pymel.core as pm
class WindowWatcher():
""" A class to watch for a particular window in Maya """
def __init__(self, window_name, on_open_callback, on_close_callback=None):
self.window_name = window_name
self.on_open_callback = on_open_callback
self.on_close_callback = on_close_callback
self.window_opened = False
def check_for_window_open(self):
if not self.window_opened:
if self.window_name in cmds.getPanel(vis=1):
self.on_open_callback.__call__()
self.window_opened = True
else:
if not self.window_name in cmds.getPanel(vis=1):
self.window_opened = False
if self.on_close_callback:
self.on_close_callback.__call__()
camera_sequencer_name = "sequenceEditorPanel1"
def on_open_camera_sequencer():
# your on_window_open code here
cmds.menu( label='Tools', parent="sequenceEditorPanel1", tearOff = True)
camera_sequencer_watcher = WindowWatcher(camera_sequencer_name, on_open_camera_sequencer)
cmds.scriptJob(event=["idle", pm.windows.Callback(camera_sequencer_watcher.check_for_window_open)])
I'm pretty sure there's a better way to do this, but I couldn't find It. If someone knows a better solution, pls, I'd love to know.
Thanks!