"""Customized button with rotated text"""

from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
from PyQt5.QtCore import *
import sys


class rotatedButton(QPushButton):
    def __init__(self, text: str, parent: QWidget) -> None:
        """Create a button with rotated text for the mainWindowGUI class"""
        super(rotatedButton, self).__init__(text, parent)

    def paintEvent(self, event):
        painter = QStylePainter(self)
        painter.rotate(-90)
        painter.translate(-1 * self.height(), 0)
        painter.drawControl(QStyle.CE_PushButton, self.getSyleOptions())

    def getSyleOptions(self):
        options = QStyleOptionButton()
        options.initFrom(self)
        size = options.rect.size()
        size.transpose()
        options.rect.setSize(size)
        #options.features = QStyleOptionButton.None_
        options.text = self.text()
        options.icon = self.icon()
        options.iconSize = self.iconSize()
        return options




