Hi Justin,

Thanks for getting back. Noted about Qt hacks, had thought it will be 
possible as I was using userSetup.py which seems to have resolve the issue 
I had on hand.
Am trying to see if the change I made, can be implemented/ enforce into 
Maya.

May not be ideal to apply a python event filter then. Thanks again :D


On Monday, May 28, 2018 at 12:45:58 PM UTC-7, Justin Israel wrote:
>
> This is probably the same issue one faces when trying to make custom Qt 
> hacks on a 3d viewport. They will work the first time, but new viewport 
> instances will not have the changes. One approach is to use an event filter 
> that checks for QEvent::ChildAdded. This even is fired when the parent 
> (main window?) has a new child widget. You can test if the widget is a 
> script editor and apply changes to it. 
> Be aware, as Marcus just recently pointed out in another thread, applying 
> a python event filter to a high traffic widget like the main window or 
> application can have performance impacts. So you may need to do it in C++ 
> if the parent is main window. 
>
> On Tue, May 29, 2018, 5:21 AM likage <dissid...@gmail.com <javascript:>> 
> wrote:
>
>> Hi all,
>>
>> I am trying to "fix" the spacing/ fonts in the Script Editor of Maya 2017 
>> version as I am used to the format and style of Maya 2016 versions and 
>> before.
>> After some searching, I created the script for the change as well as 
>> created a userSetup.py that will load and executes the script that I did 
>> whenever a new Maya 2017 is boot up.
>>
>> Currently I have a problem in which, while it seems to run correctly for 
>> the first run, but as soon as I close the current script editor and re-open 
>> it, the space/ font etc, got reverted back to the default state. While I 
>> can rectify the issue by creating a new shelf button with the code I did, 
>> are there any ways that I can force Maya to only load the custom settings 
>> that I have done?
>>
>> This is the script that I have done:
>> # script name : script_editor_fix.py
>>
>> from maya import OpenMayaUI as omui
>> from PySide2 import QtWidgets
>> from shiboken2 import wrapInstance
>>
>>
>> def get_maya_ui_element(ui_element):
>>     omui.MQtUtil.mainWindow()
>>     ptr = omui.MQtUtil.findControl(ui_element)
>>     widget = wrapInstance(long(ptr), QtWidgets.QWidget)
>>     return widget
>>
>>
>> def change_ui_font(ui_element):
>>     widget = get_maya_ui_element(ui_element)
>>
>>     widget.setStyleSheet(
>>         "font-family: {0}; font-weight: {1}; font-style: {2}; font-size: 
>> {3}px;".format(
>>             "FreeMono",
>>             "normal",
>>             "normal",
>>             12
>>         )
>>     )
>>
>>
>> def main():
>>     change_ui_font(ui_element="scriptEditorPanel1Window")
>>
>> This is the userSetup.py that I have done:
>> # script name : userSetup.py
>> from maya import cmds
>> import script_editor_fix
>>
>> cmds.evalDeferred("script_editor_fix.main()", lowestPriority=True)
>>
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Python Programming for Autodesk Maya" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to python_inside_maya+unsubscr...@googlegroups.com <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/python_inside_maya/f359fe16-c462-4f70-ae31-ef8e2ecd984f%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/python_inside_maya/f359fe16-c462-4f70-ae31-ef8e2ecd984f%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to python_inside_maya+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/ebd4715a-8913-4b1c-b1f0-6c3910f5cd88%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to