import GafferUI def buttonCallback(button): print("Button clicked!") button = GafferUI.Button("Click me") button.clickedSignal().connect(buttonCallback)
import GafferUI class MyButton(GafferUI.Button): def __init__(self, label, color): GafferUI.Button.__init__(self, label) self.__color = color self._qtWidget().setStyleSheet("background-color: {}".format(color)) button1 = MyButton("Red", "#ff0000") button2 = MyButton("Green", "#00ff00")This example creates a custom button class that takes a label and a color as arguments. The button's background color is set to the specified color using the `setStyleSheet()` method. Two instances of the custom button class are created with different colors. The Python GafferUI Button class is part of the GafferUI package library, which is a set of tools for building graphical user interfaces in Python. The package also includes other classes for creating UI components like windows, menus, and widgets.