Copy link to clipboard
Copied
Hello,
I'm developing a custom plugin for Substance 3D Painter version 11.0.1 using the Python API on Windows 11.
Using add_plugins_toolbar_widget(), I successfully added a QPushButton to the plugin toolbar. However, I’m having trouble matching the button’s size to the default plugin toolbar icon buttons (such as the resources-updater icon).
I tried using setFixedSize() to manually set the size, but it doesn’t perfectly match the default icons.
Here is a simplified version of my code:
import substance_painter
from PySide6 import QtWidgets
# Global variable
sample = None
class Button:
def __init__(self):
self.initialization()
def initialization(self):
self.init_widget_button()
self.show_ui()
def init_widget_button(self):
self.button = QtWidgets.QPushButton()
self.button.setFixedSize(32, 32)
def show_ui(self):
substance_painter.ui.add_plugins_toolbar_widget(self.button)
def cleanup(self):
if self.button:
substance_painter.ui.delete_ui_element(self.button)
self.button = None
def start_plugin():
global sample
sample = Button()
def close_plugin():
global sample
if sample:
sample.cleanup()
sample = None
if __name__ == "__main__":
start_plugin()
Question:
Is there a way to make this QPushButton match the size and look of the built-in plugin toolbar icon buttons?
Any help or guidance would be greatly appreciated.
Thank you in advance!
Update:
I managed to solve the issue.
Instead of using QPushButton, I used QToolButton, which allowed me to achieve the desired size and appearance matching the default plugin toolbar icons. It worked seamlessly when added via add_plugins_toolbar_widget().
Thank you to everyone who took the time to read my post! I hope this helps anyone facing a similar issue.
Copy link to clipboard
Copied
Update:
I managed to solve the issue.
Instead of using QPushButton, I used QToolButton, which allowed me to achieve the desired size and appearance matching the default plugin toolbar icons. It worked seamlessly when added via add_plugins_toolbar_widget().
Thank you to everyone who took the time to read my post! I hope this helps anyone facing a similar issue.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now