Change the UI font size ...

Change the UI font size ...

g2m.agent
Collaborator Collaborator
2,123 Views
0 Replies
Message 1 of 1

Change the UI font size ...

g2m.agent
Collaborator
Collaborator
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.
maya_iFXhDmmhHZ.png
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.
maya_8PsDTDbJrR.png
 
 
 
 
0 Likes
2,124 Views
0 Replies
Replies (0)