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


import updata_ssh
import updata_uart
import memory_pic




_QSS="""
QListView {
    border: 1px solid white;
    border-radius: 3px;
    show-decoration-selected: 1;
}

QWidget {
    font-size: 16px;
}

"""





class updata_dlg(QWidget):
    def __init__(self):
        QWidget.__init__(self)
        self.resize(930, 430)
        self.setStyleSheet (_QSS)
        self.tab_widget=QTabWidget(self)
        self.setWindowTitle("设备软件升级维护工具")
        self.tab_widget.setGeometry(QRect(0,0,930,430))
        self.widget_ssh=updata_ssh.updata_dlg()
        self.widget_uart=updata_uart.updata_dlg()
        self.tab_widget.setTabPosition(QTabWidget.TabPosition.North)
        self.tab_widget.addTab(self.widget_ssh,"批检仪/赋码仪主板(SSH)")
        self.tab_widget.addTab(self.widget_uart,"MCU串口升级")
        # self.tab_widget.setTabShape(QTabWidget.TabShape.Triangular)
        self.setWindowFlags(self.windowFlags() &(~ Qt.WindowType.WindowMaximizeButtonHint))
        self.setFixedSize(self.width(), self.height())

        Logo = QPixmap()
        Logo.loadFromData(base64.b64decode(memory_pic.icon_ico))
        icon = QIcon()
        icon.addPixmap(Logo, QIcon.Mode.Normal, QIcon.State.Off)
        self.setWindowIcon(icon)

    def closeEvent(self,e:QCloseEvent):
        print("close clicked.")
        self.widget_ssh.quit()
        self.widget_uart.quit()


if __name__ == "__main__":
    QCoreApplication.setAttribute(Qt.ApplicationAttribute.AA_EnableHighDpiScaling)
    app = QApplication(sys.argv)
    dlg=updata_dlg()
    dlg.show()
    app.exec()
    print("exe end.")
    sys.exit(0)
    print("exe end2.")
