def numbered_list_unknown_at_row(self, index):
        """
        Add the unknown icon to the numbered list row with an unknown.

        Args:
            index: index of numbered list item where unkown occurred.

        Returns:
            QListWidgetItem
        """
        item = self.numbered_List.item(index)
        # Get the unknown icon from path
        icon_path = app_util.get_property("ProgramResourcesPath").replace('\\', '/')
        icon_path = icon_path + "/images/unknown.gif"
        # Create icon
        error_icon = QtGui.QIcon(icon_path)
        # Add icon to QListWidgetItem
        item.setIcon(error_icon)
    def view_documentation(self, ref_command_name=None):
        """
        View the command's user documentation in the default browser.

        Args:
            ref_command_name (str):  Command name for command reference, defaults to the command name.

        Returns:
            None
        """

        # Open the command's user documentation in the default browser.
        logger = logging.getLogger(__name__)
        command_doc_url = None
        command_name = self.command.command_name
        if ref_command_name is not None and ref_command_name != "":
            # Use the specific command name for documentation
            # TODO smalers 2019-01-19 why does ref_command_name have a value of False here?
            # logger.info("Viewing documentation for command name '" + str(command_name) +
            #             "' ref='"+str(ref_command_name)+"'")
            # command_name = ref_command_name
            pass
        try:
            user_doc_url = app_util.get_property('ProgramUserDocumentationUrl')
            if user_doc_url is None:
                qt_util.warning_message_box(
                    "Can't view documentation...no application configuration value for 'ProgramUserDocumenationUrl'")
                return
            # Append the command name to the documentation
            logger.info("Now, command name '" + str(command_name) + "'")
            command_doc_url = "{}/command-ref/{}/{}/".format(user_doc_url, command_name, command_name)
            # message = "Displaying command documentation using URL: " + command_doc_url
            # logger.info(message)
            # Open the command's user documentation in the default browser.
            # - open in a new tab or if this fails open a new window
            try:
                webbrowser.open_new_tab(command_doc_url)
            except Exception:
                # Try the other variant, may work on different operating system
                webbrowser.open(command_doc_url)
        except Exception as e:
            message = 'Error viewing command documentation using url "' + str(command_doc_url) + '"'
            logger.error(message, e, exc_info=True)
            qt_util.warning_message_box(message)
    def numbered_list_warning_at_row(self, index):
        """
        Add the warning icon to the numbered list row with an warning.

        Args:
            index: index of numbered list item where warning occurred.

        Returns:
            None
        """
        # Get item from index
        item = self.numbered_List.item(index)
        # Get the warning icon from path
        icon_path = app_util.get_property("ProgramResourcesPath").replace('\\', '/')
        icon_path = icon_path + "/images/warning.gif"
        # Create icon
        error_icon = QtGui.QIcon(icon_path)
        # Add icon to QListWidgetItem
        item.setIcon(error_icon)
def new_message_box(message_type, standard_buttons_mask, message, title):
    """
    Create and execute a message box, returning an indicator for the button that was selected.
    REF: https://www.tutorialspoint.com/pyqt/pyqt_qmessagebox.htm

    Args:
            message_type (str): the type of message box, for example QtWidgets.QMessageBox.Question
            standard_buttons_mask (str): a bitmask indicating the buttons to include in the message box,
                    for example QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No
            message (str): a message to display in the message box
            title (str) a title for the message box. Appears in the top window bar.

    Returns:
        The clicked button name. See the button_value_dic for more information.
    """

    # Create the Message Box object.
    message_box = QtWidgets.QMessageBox()

    # Set the Message Box icon.
    message_box.setIcon(message_type)

    # Set the Message Box message text.
    message_box.setText(message)

    # Set the Message Box title text.
    message_box.setWindowTitle(title)

    # Set the Message Box standard buttons.
    message_box.setStandardButtons(standard_buttons_mask)

    # Set the icon
    # - icon path should use Qt / notation
    icon_path = app_util.get_property("ProgramIconPath").replace('\\', '/')
    # print("Icon path='" + icon_path + "'")
    # message_box.setWindowIcon(QtGui.Icon(icon_path))
    message_box.setWindowIcon(QtGui.QIcon(QtGui.QPixmap(icon_path)))

    # Execute the Message Box and retrieve the clicked button enumerator.
    btn_value = message_box.exec_()

    # Return the clicked button Qt type
    return btn_value
def info_message_box(message, app_name=None, title="Information"):
    """
    Display an information message dialog.

    Args:
        app_name (str): Application name to use in dialog title
            (default if None is to get from app_util.get_property("ProgramName")
        message (str): Message string.
        title (str): Title for dialog.

    Returns:
        Which button was selected as QtWidgets.QMessageBox.Ok (only one button is available).
    """
    app_name = app_util.get_property("ProgramName")
    if app_name is not None:
        # Use the application name in the title
        title = app_name + " - " + title
    message_box = new_message_box(QtWidgets.QMessageBox.Information,
                                  QtWidgets.QMessageBox.Ok, message, title)
    return message_box
    def setup_ui_core_top(self):
        """
        Setup core UI components at the top of the dialog.

        Returns:  None
        """
        # Set the window title to the command name
        self.setObjectName("InsertLineCommand")
        self.setWindowTitle("Edit " + self.command.command_string + " command")
        self.setWindowFlags(QtCore.Qt.WindowCloseButtonHint)
        icon_path = app_util.get_property("ProgramIconPath").replace('\\','/')
        self.setWindowIcon(QtGui.QIcon(icon_path))

        # Because components are added to the UI the dialog will have a size.
        # - don't set the size unless a dialog misbehaves, perhaps a maximum size
        # self.resize(684, 404)

        # Add a grid layout for components to be added
        self.grid_layout = QtWidgets.QGridLayout(self)
        self.grid_layout.setObjectName(qt_util.from_utf8("gridLayout"))

        self.setup_ui_core_command_description()