Hi, I have an existing project that uses dynamic popup menu’s for users (system.gui.createPopupMenu()). This is working fine, however, we have recently gone to touch screens, and require font size modifications. If I collect the current font from the menu using .getFont() and manipulate it, then set it back in the PopupMenu using setFont(), it does not modify during runtime (or in designer). If I read back the new font size, it reads back correctly, but does not display it. I have modified my code below to show what I have tried.
Try recursing through the menu to set the font on every item. Also, when posting code or other plain text, use a line with just a triple-backquote (these ```) above and below the pasted text. That displays indentation and code formatting so we can understand…
You’ll need to recurse into the submenu items - the constructed JyPopupMenu itself contains JyMenuItems, which each have their own getSubMenus() method, and so on. A simple recursive function should do it, unless your menu gets over 1024 elements deep Something like this, after the createPopupMenu call:
menu = system.gui.createPopupMenu(names, funcs)
def updateFont(menu, font):
menu.setFont(font)
for item in menu.subElements:
updateFont(item, font)
updateFont(menu, font4)