Message 1 of 1
Change the UI font size ...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
A few days ago, I found an easier way to change the UI font size without any side effects. but I encountered some problems. here is my code:
from PySide2.QtCore import *
from PySide2.QtWidgets import *
from PySide2.QtGui import *
from shiboken2 import wrapInstance
import maya.OpenMayaUI as old_omui
# get maya main window
def getMayaWindow():
ptr = old_omui.MQtUtil.mainWindow()
return wrapInstance(long(ptr), QWidget)
win = getMayaWindow()
# define a new font
f = QFont("Arial")
f.setPixelSize(16)
# set new font to maya main window
win.setFont(f)
But only part of the UI font size is changed, such as the menu bar, Tab title, etc.
For this, I took a more "aggressive" method: set new fonts for all the "window elements" that can be found.
types = [QWidget, QAction]
for t in types:
objs = win.findChildren(t)
for obj in objs:
obj.setFont(f)
Now all the first-level menus have changed the font size, but the second-level menus have changed a few, and others have not changed. weird! and there is still small font in Outliner.