Skip to content

Instantly share code, notes, and snippets.

@boredstiff
Created August 24, 2018 19:00
Show Gist options
  • Save boredstiff/6c62c159b9e020d4bb64b82172f509ea to your computer and use it in GitHub Desktop.
Save boredstiff/6c62c159b9e020d4bb64b82172f509ea to your computer and use it in GitHub Desktop.
Get the Time Slider Widget in Maya
from maya import mel
from PySide2 import QtWidgets
def get_widget(name):
"""Get the widget from the active QApplication that matches the given name.
Args:
name (str): The name of the widget to retrieve.
Returns:
dict: A dictionary containing
"""
return dict(
(w.objectName(), w) for w in QtWidgets.QApplication.allWidgets()).get(name)
def get_time_slider_widget():
"""Get the Time Slider Widget based on whatever it's current name is."""
time_slider_name = mel.eval('$tmpVar=$gPlayBackSlider').rsplit('|')[-1]
return get_widget(time_slider_name)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment