#!/usr/bin/python
#coding=utf8

from PyQt4.QtGui import QWidget
from ui.ui_muiltScreen import Ui_Form
from PyQt4.QtCore import QString,Qt
from os import getenv
from common import common_run

class MuiltScreenQss (QWidget, Ui_Form):

    def __init__(self, parent=None):
        super(MuiltScreenQss, self).__init__(parent)
        self.__borderImagesPath = getenv('WIN_UI_IMAGES_PATH')
        self.setupUi(self)
        self.__setitstyle()
        self.radioButton_2.setFocusPolicy(Qt.NoFocus)
        self.radioButton.setFocusPolicy(Qt.NoFocus)
        self.radioButton_3.setFocusPolicy(Qt.NoFocus)
        self.radioButton_5.setFocusPolicy(Qt.NoFocus)
    def __setitstyle(self):
        '''  设置样式   '''
        #设置多屏显示图片
        self.verticalLayout_main.setContentsMargins(int(common_run.get_width(40.0)),
                                                    int(common_run.get_height(20.0)),
                                                    int(common_run.get_width(40.0)),
                                                    int(common_run.get_height(20.0)))
        temp_l = []
        temp_l.append(self.label_dx_1)
        temp_l.append(self.label_dx_2)
        temp_l.append(self.label_spyx_1)
        temp_l.append(self.label_spyx_2)
        temp_l.append(self.label_zhx_1)
        temp_l.append(self.label_zhx_2)
        temp_l.append(self.label_tx_1)
        temp_l.append(self.label_tx_2)
        for item in temp_l:
            item.setMinimumHeight(int(common_run.get_height(70.0)))
            item.setMaximumHeight(int(common_run.get_height(70.0)))
            item.setMinimumWidth(int(common_run.get_width(122.0)))
            item.setMinimumWidth(int(common_run.get_width(122.0)))

        temp_l = []
        temp_l.append(self.label_dx_text)
        temp_l.append(self.label_tx_text)
        temp_l.append(self.label_xhx_text)
        temp_l.append(self.label_yx_text)
        __font_size = str(int(common_run.get_height(11.0)))
        for item in temp_l:
            item.setMinimumWidth(int(common_run.get_width(250.0)))
            item.setMaximumWidth(int(common_run.get_width(250.0)))
            item.setMinimumHeight(int(common_run.get_height(15.0)))
            item.setMaximumHeight(int(common_run.get_height(15.0)))
            item.setStyleSheet("font: 63 "+__font_size+"pt;")

        self.label_dx_1.setStyleSheet(QString("QLabel {border-image:url(%1/debugWindow/1.png);border: 4px;}"
                                      ).arg( str(self.__borderImagesPath)))

        self.label_spyx_1.setStyleSheet(QString("QLabel {border-image:url(%1/debugWindow/1.png);border: 4px;}"
                                      ).arg( str(self.__borderImagesPath))
         )
        self.label_spyx_2.setStyleSheet(QString("QLabel {border-image:url(%1/debugWindow/2.png);border: 4px;}"
                                      ).arg( str(self.__borderImagesPath))
         )

        self.label_zhx_1.setStyleSheet(QString("QLabel {border-image:url(%1/debugWindow/2-1.png);border: 4px;}"
                                      ).arg( str(self.__borderImagesPath))
         )
        self.label_zhx_2.setStyleSheet(QString("QLabel {border-image:url(%1/debugWindow/2-2.png);border: 4px;}"
                                      ).arg( str(self.__borderImagesPath))
         )

        self.label_tx_1.setStyleSheet(QString("QLabel {border-image:url(%1/debugWindow/1.png);border: 4px;}"
                                      ).arg( str(self.__borderImagesPath))
         )
        self.label_tx_2.setStyleSheet(QString("QLabel {border-image:url(%1/debugWindow/1.png);border: 4px;}"
                                      ).arg( str(self.__borderImagesPath))
        )

        #设置单选框图片格式
        __font_size = str(int(common_run.get_height(13.0)))
        __indicator_size = int(common_run.get_height(16.0))
        self.radioButton_2.setStyleSheet(QString("QRadioButton{font:"+__font_size+"pt;}"
                                               "QRadioButton:indicator:unchecked{image: url(%1/debugWindow/radio1.png);width:%2px;height:%2px;}"
                                               "QRadioButton:indicator:checked{image: url(%1/debugWindow/radio2.png);width:%2px;height:%2px;}"
                                      ).arg( str(self.__borderImagesPath),str(__indicator_size)))

        self.radioButton.setStyleSheet(QString("QRadioButton{font:"+__font_size+"pt;}"
                                               "QRadioButton:indicator:unchecked{image: url(%1/debugWindow/radio1.png);width:%2px;height:%2px;}"
                                               "QRadioButton:indicator:checked{image: url(%1/debugWindow/radio2.png);width:%2px;height:%2px;}"
                                      ).arg( str(self.__borderImagesPath),str(__indicator_size)))
        self.radioButton_3.setStyleSheet(QString("QRadioButton{font:"+__font_size+"pt;}"
                                               "QRadioButton:indicator:unchecked{image: url(%1/debugWindow/radio1.png);width:%2px;height:%2px;}"
                                               "QRadioButton:indicator:checked{image: url(%1/debugWindow/radio2.png);width:%2px;height:%2px;}"
                                      ).arg( str(self.__borderImagesPath),str(__indicator_size)))
        self.radioButton_5.setStyleSheet(QString("QRadioButton{font:"+__font_size+"pt;}"
                                               "QRadioButton:indicator:unchecked{image: url(%1/debugWindow/radio1.png);width:%2px;height:%2px;}"
                                               "QRadioButton:indicator:checked{image: url(%1/debugWindow/radio2.png);width:%2px;height:%2px;}"
                                      ).arg( str(self.__borderImagesPath),str(__indicator_size)))

if __name__ == "__main__":
    from PyQt4 import QtGui
    from os import environ
    environ["WIN_UI_IMAGES_PATH"]="../../../images"
    app = QtGui.QApplication([])
    win = MuiltScreenQss()
    win.show()
    app.exec_()