Created
April 19, 2021 13:49
-
-
Save yamahigashi/db3ca3bb5d398bd01054c01f8079d58b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
"""Resize gameExporter's frame range textfields width of animation clips tab.""" | |
import PySide2 | |
def get_maya_main_window(): | |
for obj in PySide2.QtWidgets.QApplication.topLevelWidgets(): | |
if obj.objectName() == 'MayaWindow': | |
return obj | |
raise Exception("Maya main window not found") | |
def find_window_by_name(name): | |
for kid in get_maya_main_window().children(): | |
if kid.objectName() == name: | |
return kid | |
raise Exception("window named {} not found".format(name)) | |
def find_widget_by_objectName(window, name): | |
for kid in window.findChildren(PySide2.QtWidgets.QWidget): | |
if kid.objectName() == name: | |
return kid | |
raise Exception("widget named {} not found".format(name)) | |
def find_widget_by_accessibleName(window, name): | |
for kid in window.findChildren(PySide2.QtWidgets.QWidget): | |
if kid.accessibleName() == name: | |
return kid | |
raise Exception("widget named {} not found".format(name)) | |
def inject_resize_button(window): | |
container = find_widget_by_objectName(window, "anim_gameFbxExporterAnimClipFormLayout") | |
labels = container.children() | |
button = PySide2.QtWidgets.QPushButton("resize", parent=container) | |
button.clicked.connect(set_frame_field_width) | |
button.show() | |
def set_frame_field_width(): | |
try: | |
window = find_window_by_name("gameExporterWindow") | |
width = 65 | |
# container = find_widget_by_objectName(window, "anim_gameFbxExporterAnimClipFormLayout") | |
container = find_widget_by_objectName(window, "anim_gameFbxExporterScrollLayout") | |
forms = container.children()[1].children()[0].children()[0].children() | |
for form in forms[1:]: | |
# text_filed = form.children()[2] | |
start_field = form.children()[3] | |
end_field = form.children()[4] | |
start_field.setMinimumSize(width, 20) | |
end_field.setMinimumSize(width, 20) | |
except: | |
print("error") | |
def main(): | |
window = find_window_by_name("gameExporterWindow") | |
inject_resize_button(window) | |
set_frame_field_width() | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment