def create_button(self, name, callback=None, image_path=None, size=(128, 160), always_enabled=False): """Create a push button which the mock input device can register. :param name: Name of the button :param callback: The callback to attach to the button when pressed :param image_path: The name of the image file :param size: Default size of the button :param always_enabled: Never disable the button if it's not in possible gaits :return: A QPushButton object which contains the passed arguments """ if image_path is None: qt_button = QPushButton() text = check_string(name) qt_button.setText(text) else: qt_button = ImageButton(get_image_path(image_path)) qt_button.setObjectName(name) if always_enabled: self._always_enabled_buttons.append(name) qt_button.setEnabled(True) qt_button.setMinimumSize(QSize(*size)) qt_button.setMaximumSize(QSize(*size)) if callback: qt_button.clicked.connect(callback) return qt_button
def create_button(text, callback=None, image_path=None, size=(125, 150), visible=True, color_code='#1F1E24'): """Create a push button which the mock input device can register. :param text: Possible name of the button :param callback: The callback to attach to the button when pressed :param image_path: The name of the image file :param size: Default size of the button :param visible: Turn button invisible on the gui :param color_code: Possible background color of the button :return: A QPushButton object which contains the passed arguments """ qt_button = QPushButton() if image_path: qt_button.setStyleSheet( create_image_button_css(get_image_path(image_path))) else: text = check_string(text) qt_button.setStyleSheet(create_color_button_css(color_code)) qt_button.setText(text) qt_button.setMinimumSize(QSize(*size)) if not visible: qt_button.setVisible(False) if callback: qt_button.clicked.connect(callback) return qt_button