# Path: argos/qt/bindings.py
# API_PYSIDE2 = 'pyside2'
# API_PYQT5 = 'pyqt5'
# ALL_API = [API_PYQT5, API_PYSIDE2]
# QT_API_NAME = os.environ.get('QT_API')
#     QT_API_NAME = None
#         QT_API_NAME = API_PYQT5
#         QT_API_NAME = API_PYSIDE2
#         QT_API_NAME = API_PYQT5
#         QT_API_NAME = API_PYSIDE2


import logging
import os.path
from argos.qt import QtWidgets


def setApplicationQtStyle(styleName):
    """ Sets the Qt style (e.g. to 'fusion')
    """
    qApp = QtWidgets.QApplication.instance()
    logger.debug("Setting Qt style to: {}".format(styleName))
    qApp.setStyle(QtWidgets.QStyleFactory.create(styleName))
    if qApp.style().objectName().lower() != styleName.lower():
        logger.warning(
            "Setting style failed: actual style {!r} is not the specified style {!r}"
            .format(qApp.style().objectName(), styleName))


def setApplicationStyleSheet(fileName):
    """ Reads the style sheet from file and set it as application style sheet.
    """
    fileName = os.path.abspath(fileName)
    logger.debug("Reading qss from: {}".format(fileName))
    try:
        with open(fileName) as input:
            qss = input.read()
    except Exception as ex:
        logger.warning("Unable to read style sheet from '{}'. Reason: {}".format(fileName, ex))
        return

    QtWidgets.QApplication.instance().setStyleSheet(qss)




# Path: argos/qt/bindings.py
# API_PYSIDE2 = 'pyside2'
# API_PYQT5 = 'pyqt5'
# ALL_API = [API_PYQT5, API_PYSIDE2]
# QT_API_NAME = os.environ.get('QT_API')
#     QT_API_NAME = None
#         QT_API_NAME = API_PYQT5
#         QT_API_NAME = API_PYSIDE2
#         QT_API_NAME = API_PYQT5
#         QT_API_NAME = API_PYSIDE2


# Path: argos/widgets/misc.py
import logging
import os.path
from argos.qt import QtWidgets



def setApplicationQtStyle(styleName):
    """ Sets the Qt style (e.g. to 'fusion')
    """
    qApp = QtWidgets.QApplication.instance()
    logger.debug("Setting Qt style to: {}".format(styleName))
    qApp.setStyle(QtWidgets.QStyleFactory.create(styleName))
    if qApp.style().objectName().lower() != styleName.lower():
        logger.warning(
            "Setting style failed: actual style {!r} is not the specified style {!r}"
            .format(qApp.style().objectName(), styleName))


def setApplicationStyleSheet(fileName):
    """ Reads the style sheet from file and set it as application style sheet.
    """
    fileName = os.path.abspath(fileName)
    logger.debug("Reading qss from: {}".format(fileName))
    try:
        with open(fileName) as input:
            qss = input.read()
    except Exception as ex:
        logger.warning("Unable to read style sheet from '{}'. Reason: {}".format(fileName, ex))
        return

    QtWidgets.QApplication.instance().setStyleSheet(qss)




class BasePanel(QtWidgets.QFrame):