Exemple #1
0
"""
Script for invoking pytest with options to select Qt library
"""

import sys
import pytest

args = sys.argv[1:]
if '--pyside' in args:
    args.remove('--pyside')
    import PySide
elif '--pyqt4' in args:
    args.remove('--pyqt4')
    import PyQt4
elif '--pyqt5' in args:
    args.remove('--pyqt5')
    import PyQt5
elif '--pyside2' in args:
    args.remove('--pyside2')
    import PySide2

import pyqtgraph as pg

pg.systemInfo()
pytest.main(args)
Exemple #2
0
def main():
    """
    Parse any input arguments and run the application
    """

    # Enable multiprocessing on windows frozen binaries. Does nothing on other systems
    multiprocessing.freeze_support()

    # Parse input arguments to pass info to GUI
    parser = argparse.ArgumentParser()
    parser.add_argument('data', help='Load data files', nargs="*", type=str)
    parser.add_argument('--batch', help='Run batch file', default=None, type=str)
    parser.add_argument('--debug', help='Activate debug mode', action="store_true")
    parser.add_argument('--test-all', help='Run all tests', action="store_true")
    parser.add_argument('--test', help='Specify test suite to be run (default=run all)', default=None)
    parser.add_argument('--test-fast', help='Run only fast tests', action="store_true")
    parser.add_argument('--qv', help='Activate quick-view mode', action="store_true")
    parser.add_argument('--register', help='Force display of registration dialog', action="store_true")
    args = parser.parse_args()

    # Apply global options
    if args.debug:
        set_base_log_level(logging.DEBUG)
    else:
        set_base_log_level(logging.WARN)

    if args.register:
        QtCore.QSettings().setValue("license_accepted", 0)

    # Set the local file path, used for finding icons, plugins, etc
    set_local_file_path()

    # Handle CTRL-C correctly
    signal.signal(signal.SIGINT, signal.SIG_DFL)

    if args.batch is not None:
        # Batch runs need a QCoreApplication to avoid initializing the GUI - this
        # would fail when running on a displayless system 
        app = QtCore.QCoreApplication(sys.argv)
        runner = BatchScript()
        # Add delay to make sure script is run after the main loop starts, in case
        # batch script is completely synchronous
        QtCore.QTimer.singleShot(200, lambda: runner.execute({"yaml-file" : args.batch}))
        sys.exit(app.exec_())
    else:
        # Otherwise we need a QApplication and to initialize the GUI
        
        if sys.platform.startswith("darwin") and PYSIDE1:
            # Required on Mac with Pyside 1
            QtGui.QApplication.setGraphicsSystem('native')

        app = QtGui.QApplication(sys.argv)
        app.setStyle('plastique')
        QtCore.QCoreApplication.setOrganizationName("ibme-qubic")
        QtCore.QCoreApplication.setOrganizationDomain("eng.ox.ac.uk")
        QtCore.QCoreApplication.setApplicationName("Quantiphyse")
        QtGui.QApplication.setWindowIcon(QtGui.QIcon(get_icon("main_icon.png")))

        if args.debug:
            import pyqtgraph as pg
            pg.systemInfo()

        if args.test_all or args.test:
            # Run tests
            run_tests(args.test)
            sys.exit(0)
        else:
            # Create window and start main loop
            pixmap = QtGui.QPixmap(get_icon("quantiphyse_splash.png"))
            splash = QtGui.QSplashScreen(pixmap)
            splash.show()
            app.processEvents()

            win = MainWindow(load_data=args.data, widgets=not args.qv)
            splash.finish(win)
            sys.excepthook = my_catch_exceptions
            set_main_window(win)
            register.check_register()
            sys.exit(app.exec_())
Exemple #3
0
"""
Script for invoking pytest with options to select Qt library
"""

import sys
import pytest

args = sys.argv[1:]
if '--pyside' in args:
    args.remove('--pyside')
    import PySide
elif '--pyqt4' in args:
    args.remove('--pyqt4')
    import PyQt4
elif '--pyqt5' in args:
    args.remove('--pyqt5')
    import PyQt5

import pyqtgraph as pg
pg.systemInfo()

pytest.main(args)
    
    
    def __init__(self, app, parent=None):
        super(MainWindow, self).__init__()
        self.setWindowTitle(u'UpMachine Project')
        # ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID("myappid")

        self.app = app
        self.getSetting()
        self.setWindowOpacity(1)  # 初始透明度
        self.setWindowIcon(QtGui.QIcon('./icon.ico'))  # 窗口图标
        self.isMaxShow = 0

        # 窗口样式表文件读取
        sshFile = "./three.qss"
        with open(sshFile, "r") as fh:
            self.setStyleSheet(fh.read())
        #-----------------------------------------------------------------------------
        self.serial = SerialDev()
        # self.soundThread = SoundThread()
        # self.soundThread.run()
        # 左窗口-----------------------------------------------------------------------
        self.leftWidget = QtGui.QWidget()
        # self.leftWidget.setMaximumSize(200,700)
        self.leftWidget.setMaximumSize(200, 4000)
        # self.leftWidget.resize(200,650)
        # self.leftWidget.setStyleSheet("""border:1px solid red""")
        # 使用QSS样式表设置背景颜色
        self.leftWidget.setStyleSheet("""
            .QWidget{
                background:rgb(143,143,143)
            }
            .QLabel{
                background:rgb(143,143,143)
            }
            """)
        # self.leftWidget.setStyleSheet(".QWidget{background:rgb(212,212,212)}")

        # self.leftWidget.testButton = QtGui.QPushButton(u'刷新串口',self.leftWidget)
        self.leftWidget.testButton = PushButton(u'刷新串口', self.leftWidget)

        self.leftWidget.testButton.clicked.connect(self.updateSerial)
        self.leftWidget.linkButton = PushButton(u'连接串口', self.leftWidget)
        self.leftWidget.linkButton.clicked.connect(self.connectSerial)

        self.leftWidget.stopUpdataVoltageDataButton = PushButton(
            u'电压表暂停刷新', self.leftWidget)
        self.leftWidget.stopUpdataGalvanicDataButton = PushButton(
            u'电流表暂停刷新', self.leftWidget)
        self.leftWidget.stopUpdataGalvanicDataButton.clicked.connect(
            self.stopUpdataGalvanicData)
        self.leftWidget.stopUpdataVoltageDataButton.clicked.connect(
            self.stopUpdataVoltageData)
        # 串口选择框
        self.comboBox = QtGui.QComboBox(self.leftWidget)

        # 识别可用的串口
        # for i in self.serial.getPort():
        #     self.comboBox.addItem(i)

        # 波特率选择框
        self.baudrateComboBox = QtGui.QComboBox()
        index = 0
        for i in (2400, 4800, 9600, 19200, 115200):
            self.baudrateComboBox.addItem(str(i))
            if str(i) == self.baudrate:
                self.baudrateComboBox.setCurrentIndex(index)
            index += 1
        self.baudrateLabel = QtGui.QLabel(u' 波特率选择')
        # 数据位数选择框
        self.bytesizeComboBox = QtGui.QComboBox()
        index = 0
        for i in range(len(SerialDev.BYTESIZES)):
            self.bytesizeComboBox.addItem(str(SerialDev.BYTESIZES[i]))
            if SerialDev.BYTESIZES[i] == SerialDev.SETTING.EIGHTBITS:
                index = i
            if SerialDev.BYTESIZES[i] == self.bytesize:
                index = i
        self.bytesizeComboBox.setCurrentIndex(index)
        self.bytesizeComboBox.setEnabled(False)
        self.bytesizeLabel = QtGui.QLabel(u' 数据位选择')
        # 停止位选择框
        self.stopbitsComboBox = QtGui.QComboBox()
        for i in range(len(SerialDev.STOPBITS)):
            self.stopbitsComboBox.addItem(str(SerialDev.STOPBITS[i]))
            if SerialDev.STOPBITS[i] == SerialDev.SETTING.STOPBITS_ONE:
                index = i
            if SerialDev.STOPBITS[i] == self.stopbits:
                index = i
        self.stopbitsComboBox.setCurrentIndex(index)
        self.stopbitsComboBox.setEnabled(False)
        self.stopbitsLabel = QtGui.QLabel(u' 停止位选择')

        # 左下角提示Label
        self.tipLabel = QtGui.QLabel(u'          ')
        self.statusLabel = QtGui.QLabel(u'          ')
        # self.tipLabel = QtGui.QLabel(u'Hello World')

        # 左边边框布局
        self.grid = QtGui.QGridLayout()
        self.verticalLayout = QtGui.QVBoxLayout(self.leftWidget)

        # 左上关于按钮
        self.aboutPushButton = labelBtn(u'about', self.leftWidget)
        self.aboutPushButton.setMaximumSize(200, 101)
        self.aboutPushButton.resize(200, 101)
        self.aboutPushButton.setPixmap(QtGui.QPixmap(r'./aboutNormal.png'))
        self.aboutPushButton.Entered.connect(self.buttonEnterFunc)
        self.aboutPushButton.Leaved.connect(self.buttonLeavedFunc)

        self.verticalLayout.addWidget(self.aboutPushButton, 0)  #列
        self.verticalLayout.addLayout(self.grid)

        # 输入框  ---------------------------------
        # VoltageLayout_one  = QtGui.QHBoxLayout()
        # GalvanicLayout_one = QtGui.QHBoxLayout()

        # self.leftWidget.sendVoltageDataButton  = PushButton(u'电压指令',self.leftWidget)
        # self.leftWidget.sendGalvanicDataButton = PushButton(u'电流指令',self.leftWidget)

        # self.leftWidget.sendVoltageDataLineEdit  = QtGui.QDoubleSpinBox(self.leftWidget)
        # self.leftWidget.sendGalvanicDataLineEdit = QtGui.QDoubleSpinBox(self.leftWidget)

        # self.leftWidget.sendVoltageDataLineEdit.setMinimumHeight(40)
        # self.leftWidget.sendVoltageDataLineEdit.setStyleSheet("""
        #     background:transparent;
        #     border: 0px solid red;
        #     font-size:40px;
        #     color:rgb(0,220,0);
        #     selection-color:rgb(0,220,0);
        #     selection-background-color: rgb(143,143,143);
        #     """)
        # self.leftWidget.sendVoltageDataLineEdit.setButtonSymbols(QtGui.QAbstractSpinBox.NoButtons)

        # self.leftWidget.sendGalvanicDataLineEdit.setMinimumHeight(40)
        # self.leftWidget.sendGalvanicDataLineEdit.setStyleSheet("""
        #     background:transparent;
        #     border: 0px solid red;
        #     font-size:40px;
        #     color:rgb(0,220,0);
        #     selection-color:rgb(0,220,0);
        #     selection-background-color: rgb(143,143,143);
        #     """)
        # self.leftWidget.sendGalvanicDataLineEdit.setButtonSymbols(QtGui.QAbstractSpinBox.NoButtons)

        # VoltageLayout_one.addWidget(self.leftWidget.sendVoltageDataLineEdit )
        # VoltageLayout_one.addWidget(self.leftWidget.sendVoltageDataButton )
        # GalvanicLayout_one.addWidget(self.leftWidget.sendGalvanicDataLineEdit)
        # GalvanicLayout_one.addWidget(self.leftWidget.sendGalvanicDataButton)

        # VoltageLayout_one.setContentsMargins(3,0,0,0)
        # GalvanicLayout_one.setContentsMargins(3,0,0,0)

        # self.verticalLayout.addLayout(VoltageLayout_one )
        # self.verticalLayout.addLayout(GalvanicLayout_one)
        # 输入框 Over ---------------------------------

        # 连接按钮
        self.verticalLayout.addWidget(self.leftWidget.linkButton)
        # 暂停按钮
        self.verticalLayout.addWidget(
            self.leftWidget.stopUpdataVoltageDataButton)
        self.verticalLayout.addWidget(
            self.leftWidget.stopUpdataGalvanicDataButton)

        # 输入框  ---------------------------------
        VoltageLayout_one = QtGui.QHBoxLayout()
        GalvanicLayout_one = QtGui.QHBoxLayout()
        startStopLayout = QtGui.QHBoxLayout()

        self.leftWidget.sendVoltageDataButton = PushButton(
            u'电压指令', self.leftWidget)
        self.leftWidget.sendGalvanicDataButton = PushButton(
            u'电流指令', self.leftWidget)

        # 可调范围 0 ~ 500
        self.leftWidget.sendVoltageDataLineEdit = QtGui.QDoubleSpinBox(
            self.leftWidget)
        self.leftWidget.sendVoltageDataLineEdit.setRange(0, 500)
        self.leftWidget.sendVoltageDataLineEdit.setDecimals(0)  # 小数位数
        # 可调范围 0 ~ 20
        self.leftWidget.sendGalvanicDataLineEdit = QtGui.QDoubleSpinBox(
            self.leftWidget)
        self.leftWidget.sendGalvanicDataLineEdit.setRange(0, 20)
        self.leftWidget.sendGalvanicDataLineEdit.setDecimals(0)  # 小数位数

        self.leftWidget.sendVoltageDataLineEdit.setMinimumHeight(40)
        self.leftWidget.sendVoltageDataLineEdit.setStyleSheet("""
            background:transparent;
            border: 0px solid red;
            font-size:40px;
            color:rgb(0,220,0);
            selection-color:rgb(0,220,0);
            selection-background-color: rgb(143,143,143);
            """)
        self.leftWidget.sendVoltageDataLineEdit.setButtonSymbols(
            QtGui.QAbstractSpinBox.NoButtons)

        self.leftWidget.sendGalvanicDataLineEdit.setMinimumHeight(40)
        self.leftWidget.sendGalvanicDataLineEdit.setStyleSheet("""
            background:transparent;
            border: 0px solid red;
            font-size:40px;
            color:rgb(0,220,0);
            selection-color:rgb(0,220,0);
            selection-background-color: rgb(143,143,143);
            """)
        self.leftWidget.sendGalvanicDataLineEdit.setButtonSymbols(
            QtGui.QAbstractSpinBox.NoButtons)

        VoltageLayout_one.addWidget(self.leftWidget.sendVoltageDataLineEdit)
        VoltageLayout_one.addWidget(self.leftWidget.sendVoltageDataButton)
        GalvanicLayout_one.addWidget(self.leftWidget.sendGalvanicDataLineEdit)
        GalvanicLayout_one.addWidget(self.leftWidget.sendGalvanicDataButton)

        VoltageLayout_one.setContentsMargins(3, 0, 0, 0)
        GalvanicLayout_one.setContentsMargins(3, 0, 0, 0)
        # startStopLayout.setContentsMargins(3,0,0,0)

        self.verticalLayout.addLayout(startStopLayout)
        self.verticalLayout.addLayout(VoltageLayout_one)
        self.verticalLayout.addLayout(GalvanicLayout_one)

        # 输入框 Over ---------------------------------
        # 启动暂停按钮
        self.startButton = PushButton(u'启动', self.leftWidget)
        self.stopButton = PushButton(u'暂停', self.leftWidget)
        self.startButton.clicked.connect(self.requestStartData)
        self.stopButton.clicked.connect(self.requestStopData)
        startStopLayout.addWidget(self.startButton)
        startStopLayout.addWidget(self.stopButton)
        # 启动暂停按钮 Over

        self.verticalLayout.addWidget(self.tipLabel)
        self.verticalLayout.addWidget(self.statusLabel)
        self.verticalLayout.setContentsMargins(3, 2, 3, 3)

        # 窗口伸缩控件
        self.verticalLayout.addItem(
            QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum,
                              QtGui.QSizePolicy.Expanding))
        self.verticalLayout.addWidget(QtGui.QSizeGrip(self))

        self.leftWidget.setLayout(self.verticalLayout)

        self.grid.addWidget(self.leftWidget.testButton, 0, 1)  # 行 列
        self.grid.addWidget(self.comboBox, 0, 0)
        self.grid.addWidget(self.baudrateComboBox, 1, 0)
        self.grid.addWidget(self.baudrateLabel, 1, 1)
        self.grid.addWidget(self.bytesizeComboBox, 2, 0)
        self.grid.addWidget(self.bytesizeLabel, 2, 1)
        self.grid.addWidget(self.stopbitsComboBox, 3, 0)
        self.grid.addWidget(self.stopbitsLabel, 3, 1)

        self.grid.setContentsMargins(5, 10, 5, 5)  # 显示边距

        # ----------------------------------------------------------------------------

        self.content_splitter = QtGui.QSplitter()
        self.content_splitter.setSizePolicy(QtGui.QSizePolicy.Expanding,
                                            QtGui.QSizePolicy.Expanding)
        self.content_splitter.setOrientation(QtCore.Qt.Horizontal)
        self.content_splitter.setHandleWidth(1)
        self.content_splitter.setStyleSheet(
            "QSplitter.handle{background:lightgray}")
        # self.content_splitter.setStyleSheet("""border:1px solid red""")

        # 容纳主部件的 widget
        self.contentWidget = QtGui.QMainWindow()
        self.content_splitter.addWidget(self.leftWidget)
        self.content_splitter.addWidget(self.contentWidget)
        # 主 Layout
        self.main_layout = QtGui.QVBoxLayout()
        # self.content_splitter.setStyleSheet("""border:1px solid red""")
        # self.main_layout.addWidget(self.titlebar)
        self.main_layout.addWidget(self.content_splitter)
        self.main_layout.setSpacing(0)  # 间距     # layout.addStretch() 弹簧
        self.main_layout.setContentsMargins(10, 7, 10, 7)
        # 主窗口底层
        self.widget = QtGui.QWidget()
        self.setCentralWidget(self.widget)
        self.widget.setLayout(self.main_layout)

        # 窗口伸缩问题
        # self.main_layout.addWidget(QtGui.QSizeGrip(self));

        # 窗口属性
        self.setWindowFlags(QtCore.Qt.FramelessWindowHint)
        self.setAttribute(QtCore.Qt.WA_TranslucentBackground, True)
        self.desktop = QtGui.QApplication.desktop()
        self.LeftButtonPreesed = 0
        self.resize(1000, 650)
        self.center(1)  # 居中显示

        # 表格界面
        self.PlotWidget = pyqtgraph.GraphicsWindow()  # QtGui.QWidget()
        self.PlotWidget.setWindowOpacity(0)
        self.contentWidget.setCentralWidget(self.PlotWidget)

        # 黑色前景色
        # pyqtgraph.setConfigOption('foreground',(255,255,255))
        # useOpenGL
        # pyqtgraph.setConfigOption('useOpenGL',True)
        # 抗锯齿
        # pyqtgraph.setConfigOption('antialias',True)

        # http://www.pyqtgraph.org/documentation/functions.html#pyqtgraph.mkPen
        # 画笔 颜色 宽度 美化?
        # self.greenPen = pyqtgraph.mkPen((0,220,0), width=1.2,cosmetic=True,style=QtCore.Qt.SolidLine)
        self.greenPen = pyqtgraph.mkPen((0, 220, 0),
                                        width=1.2,
                                        cosmetic=False,
                                        style=QtCore.Qt.SolidLine)

        # 上层第一个电压图表
        # http://localhost:7464/pyqtgraph.graphicsItems.PlotItem.PlotItem.html
        self.upPlot = self.PlotWidget.addPlot()
        # self.upPlot.setLimits(xMax=350) # X轴显示最大值
        self.upPlot.showGrid(x=True, y=True)  #网格

        self.data = np.random.normal(size=300)
        self.lastestData = 0

        # self.upCurve = self.upPlot.plot(self.data, pen=self.greenPen)
        self.upPlot.setLabel('bottom',
                             text=u'时间',
                             units='s',
                             unitPrefix='test')
        self.upPlot.setLabel('left', text=u'电压', units='V')
        self.upPlot.setTitle(u'电压信号图')
        # self.upPlot.setRange(xRange=[0, 350])   #坐标默认显示的区间

        # 换行画图
        self.PlotWidget.nextRow()

        # 下层第二个电流图表
        self.downPlot = self.PlotWidget.addPlot()
        self.downPlot.showGrid(x=True, y=True)
        # antialias抗锯齿
        # self.downCurve = self.downPlot.plot(self.data, pen=self.greenPen)#antialias=True)
        self.downPlot.setLabel('bottom', text=u'时间', units='s')
        self.downPlot.setLabel('left', text=u'电流', units='A')
        self.downPlot.setTitle(u'电流信号图')
        self.downPlot.setRange(yRange=[0, 30])

        # self.PlotWidget.setBackground((252,252,252))#QtGui.QBrush(QtGui.QColor(255,255,255,255)))

        # -------------------------------------------------------------------------------
        self.galvanicData = []  # 电流数据
        self.voltageData = []  # 电压数据
        self.lastestGalvanicData = 0  # 最新电流数据
        self.lastestVoltageData = 0  # 最新电压数据
        self.serialDataString = ""  # 所有的数据字符串
        self.serialDataCursor = 0  # 数据指针
        self.serialDataList = []  # 数据存储列表
        self.stopUpdateGalvanicDataFlag = 1  # 电流暂停标志
        self.stopUpdateVoltageDataFlag = 1  # 电压暂停标志
        # 输出系统信息 ----------------------------------------------------------------------
        print pyqtgraph.systemInfo()

        # 窗口按钮 Grid 此布局利用QtDesign设计代码移入-----------------------------------
        self.gridLayout = QtGui.QGridLayout(self.PlotWidget)
        self.gridLayout.setMargin(0)  # 间距
        self.gridLayout.setSpacing(0)  # 间距
        # 最大化按钮
        self.maxPushButton = labelBtn(u'max', self.PlotWidget)
        self.maxPushButton.setPixmap(QtGui.QPixmap(r'./maxNormal.png'))
        self.maxPushButton.Entered.connect(self.buttonEnterFunc)
        self.maxPushButton.Leaved.connect(self.buttonLeavedFunc)
        self.maxPushButton.Clicked.connect(self.maxFunc)
        self.gridLayout.addWidget(self.maxPushButton, 0, 2, 1, 1)
        # 关闭按钮
        self.closePushButton = labelBtn(u'close', self.PlotWidget)
        self.closePushButton.setPixmap(QtGui.QPixmap(r'./closeNormal.png'))
        self.closePushButton.Entered.connect(self.buttonEnterFunc)
        self.closePushButton.Leaved.connect(self.buttonLeavedFunc)
        self.closePushButton.Clicked.connect(self.closeFunc)
        self.gridLayout.addWidget(self.closePushButton, 0, 3, 1, 1)

        spacerItem = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum,
                                       QtGui.QSizePolicy.Expanding)  # 两个弹簧控件
        self.gridLayout.addItem(spacerItem, 1, 3, 1, 1)  # 行 列
        spacerItem2 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding,
                                        QtGui.QSizePolicy.Minimum)
        self.gridLayout.addItem(spacerItem2, 0, 0, 1, 1)
        # 最小化按钮
        self.minPushButton = labelBtn(u'min', self.PlotWidget)
        self.minPushButton.Entered.connect(self.buttonEnterFunc)
        self.minPushButton.Leaved.connect(self.buttonLeavedFunc)
        self.minPushButton.Clicked.connect(self.minFunc)
        self.minPushButton.setPixmap(QtGui.QPixmap(r'./minNormal.png'))
        self.gridLayout.addWidget(self.minPushButton, 0, 1, 1, 1)
        # 窗口按钮Over ------------------------------------------------------------------
        # QtDesign设计的两个lable布局-------------------------------------------------------------------------------

        self.gridLayout2 = QtGui.QGridLayout()

        spacerItem = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum,
                                       QtGui.QSizePolicy.Expanding)
        self.gridLayout2.addItem(spacerItem, 6, 1, 1, 1)
        self.label = QtGui.QLabel(u'     ', self.PlotWidget)
        self.gridLayout2.addWidget(self.label, 1, 0, 1, 1)
        spacerItem1 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum,
                                        QtGui.QSizePolicy.Expanding)
        self.gridLayout2.addItem(spacerItem1, 2, 1, 1, 1)
        self.label_3 = QtGui.QLabel(self.PlotWidget)
        self.gridLayout2.addWidget(self.label_3, 0, 0, 1, 1)
        self.label_2 = QtGui.QLabel(u'     ', self.PlotWidget)
        self.gridLayout2.addWidget(self.label_2, 4, 0, 1, 1)
        self.label_4 = QtGui.QLabel(self.PlotWidget)
        self.gridLayout2.addWidget(self.label_4, 3, 0, 1, 1)
        spacerItem2 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding,
                                        QtGui.QSizePolicy.Minimum)
        self.gridLayout2.addItem(spacerItem2, 3, 1, 1, 1)

        self.gridLayout.addLayout(self.gridLayout2, 1, 0, 1, 1)

        self.label.setWindowFlags(QtCore.Qt.FramelessWindowHint)
        self.label.setAttribute(QtCore.Qt.WA_TranslucentBackground, True)
        self.label_2.setWindowFlags(QtCore.Qt.FramelessWindowHint)
        self.label_2.setAttribute(QtCore.Qt.WA_TranslucentBackground, True)
        self.label_3.setWindowFlags(QtCore.Qt.FramelessWindowHint)
        self.label_3.setAttribute(QtCore.Qt.WA_TranslucentBackground, True)
        self.label_4.setWindowFlags(QtCore.Qt.FramelessWindowHint)
        self.label_4.setAttribute(QtCore.Qt.WA_TranslucentBackground, True)

        self.font = QtGui.QFont()
        self.font.setPixelSize(60)  #设置字号32,以像素为单位

        print self.font.family()
        QtGui.QFontDatabase.addApplicationFont("MiuiEx-Light.ttf")
        self.font.setFamily("MIUI EX")
        print self.font.family()
        for i in QtGui.QFontDatabase.families(QtGui.QFontDatabase()):
            # print i.toUtf8()
            pass

        # self.font.setFamily("SimSun") #设置字体
        # self.font.setWeight(1)     #设置字型,不加粗

        self.label.setStyleSheet("color:rgb(0,220,0)")
        self.label.setFont(self.font)
        self.label_2.setStyleSheet("color:rgb(0,220,0)")
        self.label_2.setFont(self.font)

        # --------------------------------------------------------------------------------
        # Connect Event 串口接收信号与槽连接-----------------------------------------------------------------
        self.connect(self.serial.qObj, QtCore.SIGNAL('SerialRecvData'),
                     self.recvSerialData)
        '''电压指令'''
        self.leftWidget.sendVoltageDataButton.clicked.connect(
            self.requestVoltageData)
        '''电流指令'''
        self.leftWidget.sendGalvanicDataButton.clicked.connect(
            self.requestGalvanicData)

        # Timer To ADD AblePort
        self.timer = QtCore.QTimer()
        self.timer.setSingleShot(True)
        self.timer.timeout.connect(self.timerTaskForSearchSeries)
        self.timer.start(0)  # Start Now

        # self.setFocusProxy()
        self.setFocus()
    def __init__(self,app,parent=None):
        super(MainWindow,self).__init__()
        self.setWindowTitle(u'UpMachine Project')
        # ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID("myappid")

        self.app = app
        self.getSetting()
        self.setWindowOpacity(1) # 初始透明度
        self.setWindowIcon(QtGui.QIcon('./icon.ico')) # 窗口图标
        self.isMaxShow = 0

        # 窗口样式表文件读取
        sshFile="./three.qss"
        with open(sshFile,"r") as fh:
            self.setStyleSheet(fh.read())
        #-----------------------------------------------------------------------------
        self.serial = SerialDev()
        # self.soundThread = SoundThread()
        # self.soundThread.run()
        # 左窗口-----------------------------------------------------------------------
        self.leftWidget = QtGui.QWidget()
        # self.leftWidget.setMaximumSize(200,700)
        self.leftWidget.setMaximumSize(200,4000)
        # self.leftWidget.resize(200,650)
        # self.leftWidget.setStyleSheet("""border:1px solid red""")
        # 使用QSS样式表设置背景颜色
        self.leftWidget.setStyleSheet("""
            .QWidget{
                background:rgb(143,143,143)
            }
            .QLabel{
                background:rgb(143,143,143)
            }
            """)
        # self.leftWidget.setStyleSheet(".QWidget{background:rgb(212,212,212)}")

        # self.leftWidget.testButton = QtGui.QPushButton(u'刷新串口',self.leftWidget)
        self.leftWidget.testButton = PushButton(u'刷新串口',self.leftWidget)

        self.leftWidget.testButton.clicked.connect(self.updateSerial)
        self.leftWidget.linkButton = PushButton(u'连接串口',self.leftWidget)
        self.leftWidget.linkButton.clicked.connect(self.connectSerial)
        
        self.leftWidget.stopUpdataVoltageDataButton  = PushButton(u'电压表暂停刷新',self.leftWidget)
        self.leftWidget.stopUpdataGalvanicDataButton = PushButton(u'电流表暂停刷新',self.leftWidget)        
        self.leftWidget.stopUpdataGalvanicDataButton.clicked.connect(self.stopUpdataGalvanicData)
        self.leftWidget.stopUpdataVoltageDataButton.clicked.connect(self.stopUpdataVoltageData)
        # 串口选择框
        self.comboBox = QtGui.QComboBox(self.leftWidget) 

        # 识别可用的串口
        # for i in self.serial.getPort(): 
        #     self.comboBox.addItem(i)
        
        # 波特率选择框        
        self.baudrateComboBox = QtGui.QComboBox()
        index = 0
        for i in (2400, 4800, 9600, 19200, 115200):
            self.baudrateComboBox.addItem(str(i))
            if str(i) == self.baudrate:
                self.baudrateComboBox.setCurrentIndex(index)
            index += 1        
        self.baudrateLabel = QtGui.QLabel(u' 波特率选择')
        # 数据位数选择框
        self.bytesizeComboBox = QtGui.QComboBox()
        index = 0
        for i in range(len(SerialDev.BYTESIZES)):
            self.bytesizeComboBox.addItem(str(SerialDev.BYTESIZES[i]))
            if SerialDev.BYTESIZES[i] == SerialDev.SETTING.EIGHTBITS:
                index = i
            if SerialDev.BYTESIZES[i] == self.bytesize:
                index = i
        self.bytesizeComboBox.setCurrentIndex(index)
        self.bytesizeComboBox.setEnabled(False)
        self.bytesizeLabel = QtGui.QLabel(u' 数据位选择')
        # 停止位选择框
        self.stopbitsComboBox = QtGui.QComboBox()
        for i in range(len(SerialDev.STOPBITS)):
            self.stopbitsComboBox.addItem(str(SerialDev.STOPBITS[i]))
            if SerialDev.STOPBITS[i] == SerialDev.SETTING.STOPBITS_ONE:
                index = i
            if SerialDev.STOPBITS[i] == self.stopbits:
                index = i
        self.stopbitsComboBox.setCurrentIndex(index)
        self.stopbitsComboBox.setEnabled(False)
        self.stopbitsLabel = QtGui.QLabel(u' 停止位选择')        

        # 左下角提示Label
        self.tipLabel = QtGui.QLabel(u'          ')
        self.statusLabel = QtGui.QLabel(u'          ')
        # self.tipLabel = QtGui.QLabel(u'Hello World')

        # 左边边框布局
        self.grid = QtGui.QGridLayout()
        self.verticalLayout = QtGui.QVBoxLayout(self.leftWidget)

        # 左上关于按钮
        self.aboutPushButton = labelBtn(u'about',self.leftWidget)
        self.aboutPushButton.setMaximumSize(200,101)
        self.aboutPushButton.resize(200,101)
        self.aboutPushButton.setPixmap(QtGui.QPixmap(r'./aboutNormal.png'))
        self.aboutPushButton.Entered.connect(self.buttonEnterFunc)
        self.aboutPushButton.Leaved.connect(self.buttonLeavedFunc)

        self.verticalLayout.addWidget(self.aboutPushButton,0) #列
        self.verticalLayout.addLayout(self.grid)

        # 输入框  ---------------------------------      
        # VoltageLayout_one  = QtGui.QHBoxLayout()
        # GalvanicLayout_one = QtGui.QHBoxLayout()
        
        # self.leftWidget.sendVoltageDataButton  = PushButton(u'电压指令',self.leftWidget)
        # self.leftWidget.sendGalvanicDataButton = PushButton(u'电流指令',self.leftWidget) 

        # self.leftWidget.sendVoltageDataLineEdit  = QtGui.QDoubleSpinBox(self.leftWidget)
        # self.leftWidget.sendGalvanicDataLineEdit = QtGui.QDoubleSpinBox(self.leftWidget)

        # self.leftWidget.sendVoltageDataLineEdit.setMinimumHeight(40)
        # self.leftWidget.sendVoltageDataLineEdit.setStyleSheet("""
        #     background:transparent;
        #     border: 0px solid red;
        #     font-size:40px;
        #     color:rgb(0,220,0);
        #     selection-color:rgb(0,220,0);
        #     selection-background-color: rgb(143,143,143);
        #     """)
        # self.leftWidget.sendVoltageDataLineEdit.setButtonSymbols(QtGui.QAbstractSpinBox.NoButtons)

        # self.leftWidget.sendGalvanicDataLineEdit.setMinimumHeight(40)
        # self.leftWidget.sendGalvanicDataLineEdit.setStyleSheet("""
        #     background:transparent;
        #     border: 0px solid red;
        #     font-size:40px;
        #     color:rgb(0,220,0);
        #     selection-color:rgb(0,220,0);
        #     selection-background-color: rgb(143,143,143);
        #     """)
        # self.leftWidget.sendGalvanicDataLineEdit.setButtonSymbols(QtGui.QAbstractSpinBox.NoButtons)

        # VoltageLayout_one.addWidget(self.leftWidget.sendVoltageDataLineEdit )
        # VoltageLayout_one.addWidget(self.leftWidget.sendVoltageDataButton )
        # GalvanicLayout_one.addWidget(self.leftWidget.sendGalvanicDataLineEdit)
        # GalvanicLayout_one.addWidget(self.leftWidget.sendGalvanicDataButton)

        # VoltageLayout_one.setContentsMargins(3,0,0,0)
        # GalvanicLayout_one.setContentsMargins(3,0,0,0)

        # self.verticalLayout.addLayout(VoltageLayout_one )
        # self.verticalLayout.addLayout(GalvanicLayout_one)
        # 输入框 Over ---------------------------------

        # 连接按钮
        self.verticalLayout.addWidget(self.leftWidget.linkButton)
        # 暂停按钮
        self.verticalLayout.addWidget(self.leftWidget.stopUpdataVoltageDataButton)
        self.verticalLayout.addWidget(self.leftWidget.stopUpdataGalvanicDataButton)            

        # 输入框  ---------------------------------      
        VoltageLayout_one  = QtGui.QHBoxLayout()
        GalvanicLayout_one = QtGui.QHBoxLayout()
        startStopLayout = QtGui.QHBoxLayout()
        
        self.leftWidget.sendVoltageDataButton  = PushButton(u'电压指令',self.leftWidget)
        self.leftWidget.sendGalvanicDataButton = PushButton(u'电流指令',self.leftWidget) 

        # 可调范围 0 ~ 500
        self.leftWidget.sendVoltageDataLineEdit  = QtGui.QDoubleSpinBox(self.leftWidget)    
        self.leftWidget.sendVoltageDataLineEdit.setRange(0,500)
        self.leftWidget.sendVoltageDataLineEdit.setDecimals(0) # 小数位数
        # 可调范围 0 ~ 20
        self.leftWidget.sendGalvanicDataLineEdit = QtGui.QDoubleSpinBox(self.leftWidget)
        self.leftWidget.sendGalvanicDataLineEdit.setRange(0,20)
        self.leftWidget.sendGalvanicDataLineEdit.setDecimals(0) # 小数位数

        self.leftWidget.sendVoltageDataLineEdit.setMinimumHeight(40)
        self.leftWidget.sendVoltageDataLineEdit.setStyleSheet("""
            background:transparent;
            border: 0px solid red;
            font-size:40px;
            color:rgb(0,220,0);
            selection-color:rgb(0,220,0);
            selection-background-color: rgb(143,143,143);
            """)
        self.leftWidget.sendVoltageDataLineEdit.setButtonSymbols(QtGui.QAbstractSpinBox.NoButtons)

        self.leftWidget.sendGalvanicDataLineEdit.setMinimumHeight(40)
        self.leftWidget.sendGalvanicDataLineEdit.setStyleSheet("""
            background:transparent;
            border: 0px solid red;
            font-size:40px;
            color:rgb(0,220,0);
            selection-color:rgb(0,220,0);
            selection-background-color: rgb(143,143,143);
            """)
        self.leftWidget.sendGalvanicDataLineEdit.setButtonSymbols(QtGui.QAbstractSpinBox.NoButtons)

        VoltageLayout_one.addWidget(self.leftWidget.sendVoltageDataLineEdit )
        VoltageLayout_one.addWidget(self.leftWidget.sendVoltageDataButton )
        GalvanicLayout_one.addWidget(self.leftWidget.sendGalvanicDataLineEdit)
        GalvanicLayout_one.addWidget(self.leftWidget.sendGalvanicDataButton)

        VoltageLayout_one.setContentsMargins(3,0,0,0)
        GalvanicLayout_one.setContentsMargins(3,0,0,0)
        # startStopLayout.setContentsMargins(3,0,0,0)

        self.verticalLayout.addLayout(startStopLayout)
        self.verticalLayout.addLayout(VoltageLayout_one )
        self.verticalLayout.addLayout(GalvanicLayout_one)
        
        # 输入框 Over ---------------------------------
        # 启动暂停按钮
        self.startButton = PushButton(u'启动',self.leftWidget)
        self.stopButton = PushButton(u'暂停',self.leftWidget)
        self.startButton.clicked.connect(self.requestStartData)
        self.stopButton.clicked.connect(self.requestStopData)
        startStopLayout.addWidget(self.startButton)
        startStopLayout.addWidget(self.stopButton)
        # 启动暂停按钮 Over

        self.verticalLayout.addWidget(self.tipLabel)
        self.verticalLayout.addWidget(self.statusLabel)
        self.verticalLayout.setContentsMargins(3,2,3,3)

        # 窗口伸缩控件
        self.verticalLayout.addItem(QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding))
        self.verticalLayout.addWidget(QtGui.QSizeGrip(self))

        self.leftWidget.setLayout(self.verticalLayout)

        self.grid.addWidget(self.leftWidget.testButton,0,1) # 行 列
        self.grid.addWidget(self.comboBox,0,0)
        self.grid.addWidget(self.baudrateComboBox,1,0)
        self.grid.addWidget(self.baudrateLabel,1,1)
        self.grid.addWidget(self.bytesizeComboBox,2,0)
        self.grid.addWidget(self.bytesizeLabel,2,1)
        self.grid.addWidget(self.stopbitsComboBox,3,0)
        self.grid.addWidget(self.stopbitsLabel,3,1)

        self.grid.setContentsMargins(5,10,5,5) # 显示边距

        # ----------------------------------------------------------------------------

        self.content_splitter = QtGui.QSplitter()
        self.content_splitter.setSizePolicy(QtGui.QSizePolicy.Expanding,QtGui.QSizePolicy.Expanding)
        self.content_splitter.setOrientation(QtCore.Qt.Horizontal)
        self.content_splitter.setHandleWidth(1)
        self.content_splitter.setStyleSheet("QSplitter.handle{background:lightgray}")
        # self.content_splitter.setStyleSheet("""border:1px solid red""")

        # 容纳主部件的 widget
        self.contentWidget = QtGui.QMainWindow()
        self.content_splitter.addWidget(self.leftWidget)
        self.content_splitter.addWidget(self.contentWidget)
        # 主 Layout
        self.main_layout = QtGui.QVBoxLayout()
        # self.content_splitter.setStyleSheet("""border:1px solid red""")
        # self.main_layout.addWidget(self.titlebar)
        self.main_layout.addWidget(self.content_splitter)        
        self.main_layout.setSpacing(0) # 间距     # layout.addStretch() 弹簧
        self.main_layout.setContentsMargins(10,7,10,7)
        # 主窗口底层
        self.widget = QtGui.QWidget()
        self.setCentralWidget(self.widget)
        self.widget.setLayout(self.main_layout)
        
        # 窗口伸缩问题
        # self.main_layout.addWidget(QtGui.QSizeGrip(self));


        # 窗口属性
        self.setWindowFlags(QtCore.Qt.FramelessWindowHint)
        self.setAttribute(QtCore.Qt.WA_TranslucentBackground, True)
        self.desktop = QtGui.QApplication.desktop()
        self.LeftButtonPreesed = 0
        self.resize(1000,650)
        self.center(1) # 居中显示

        # 表格界面
        self.PlotWidget = pyqtgraph.GraphicsWindow() # QtGui.QWidget()
        self.PlotWidget.setWindowOpacity(0)
        self.contentWidget.setCentralWidget(self.PlotWidget)
        
        # 黑色前景色
        # pyqtgraph.setConfigOption('foreground',(255,255,255))
        # useOpenGL
        # pyqtgraph.setConfigOption('useOpenGL',True)
        # 抗锯齿
        # pyqtgraph.setConfigOption('antialias',True)

        # http://www.pyqtgraph.org/documentation/functions.html#pyqtgraph.mkPen
        # 画笔 颜色 宽度 美化?
        # self.greenPen = pyqtgraph.mkPen((0,220,0), width=1.2,cosmetic=True,style=QtCore.Qt.SolidLine)
        self.greenPen = pyqtgraph.mkPen((0,220,0), width=1.2,cosmetic=False,style=QtCore.Qt.SolidLine)

        # 上层第一个电压图表
        # http://localhost:7464/pyqtgraph.graphicsItems.PlotItem.PlotItem.html
        self.upPlot = self.PlotWidget.addPlot()
        # self.upPlot.setLimits(xMax=350) # X轴显示最大值
        self.upPlot.showGrid(x=True, y=True) #网格
        
        self.data = np.random.normal(size=300)
        self.lastestData = 0
        
        # self.upCurve = self.upPlot.plot(self.data, pen=self.greenPen)
        self.upPlot.setLabel('bottom', text=u'时间', units='s',unitPrefix='test')
        self.upPlot.setLabel('left', text=u'电压', units='V')
        self.upPlot.setTitle(u'电压信号图')
        # self.upPlot.setRange(xRange=[0, 350])   #坐标默认显示的区间

        # 换行画图
        self.PlotWidget.nextRow()

        # 下层第二个电流图表
        self.downPlot = self.PlotWidget.addPlot()
        self.downPlot.showGrid(x=True, y=True)
        # antialias抗锯齿
        # self.downCurve = self.downPlot.plot(self.data, pen=self.greenPen)#antialias=True)
        self.downPlot.setLabel('bottom', text=u'时间', units='s')
        self.downPlot.setLabel('left', text=u'电流', units='A')
        self.downPlot.setTitle(u'电流信号图')
        self.downPlot.setRange(yRange=[0,30])

        # self.PlotWidget.setBackground((252,252,252))#QtGui.QBrush(QtGui.QColor(255,255,255,255)))

        # -------------------------------------------------------------------------------
        self.galvanicData = [] # 电流数据
        self.voltageData = []  # 电压数据
        self.lastestGalvanicData = 0 # 最新电流数据
        self.lastestVoltageData = 0  # 最新电压数据
        self.serialDataString = ""  # 所有的数据字符串
        self.serialDataCursor = 0 # 数据指针
        self.serialDataList = [] # 数据存储列表
        self.stopUpdateGalvanicDataFlag = 1 # 电流暂停标志
        self.stopUpdateVoltageDataFlag = 1 # 电压暂停标志        
        # 输出系统信息 ----------------------------------------------------------------------
        print pyqtgraph.systemInfo()

        # 窗口按钮 Grid 此布局利用QtDesign设计代码移入-----------------------------------
        self.gridLayout = QtGui.QGridLayout(self.PlotWidget)
        self.gridLayout.setMargin(0)  # 间距
        self.gridLayout.setSpacing(0) # 间距
        # 最大化按钮
        self.maxPushButton = labelBtn(u'max',self.PlotWidget)
        self.maxPushButton.setPixmap(QtGui.QPixmap(r'./maxNormal.png'))
        self.maxPushButton.Entered.connect(self.buttonEnterFunc)
        self.maxPushButton.Leaved.connect(self.buttonLeavedFunc)
        self.maxPushButton.Clicked.connect(self.maxFunc)
        self.gridLayout.addWidget(self.maxPushButton, 0, 2, 1, 1)
        # 关闭按钮
        self.closePushButton = labelBtn(u'close',self.PlotWidget)
        self.closePushButton.setPixmap(QtGui.QPixmap(r'./closeNormal.png'))
        self.closePushButton.Entered.connect(self.buttonEnterFunc)
        self.closePushButton.Leaved.connect(self.buttonLeavedFunc)
        self.closePushButton.Clicked.connect(self.closeFunc)
        self.gridLayout.addWidget(self.closePushButton, 0, 3, 1, 1)

        spacerItem = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) # 两个弹簧控件
        self.gridLayout.addItem(spacerItem, 1, 3, 1, 1) # 行 列
        spacerItem2 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
        self.gridLayout.addItem(spacerItem2, 0, 0, 1, 1)
        # 最小化按钮
        self.minPushButton = labelBtn(u'min',self.PlotWidget)
        self.minPushButton.Entered.connect(self.buttonEnterFunc)
        self.minPushButton.Leaved.connect(self.buttonLeavedFunc)
        self.minPushButton.Clicked.connect(self.minFunc)
        self.minPushButton.setPixmap(QtGui.QPixmap(r'./minNormal.png'))
        self.gridLayout.addWidget(self.minPushButton, 0, 1, 1, 1)
        # 窗口按钮Over ------------------------------------------------------------------        
        # QtDesign设计的两个lable布局------------------------------------------------------------------------------- 

        self.gridLayout2 = QtGui.QGridLayout()

        spacerItem = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
        self.gridLayout2.addItem(spacerItem, 6, 1, 1, 1)
        self.label = QtGui.QLabel(u'     ',self.PlotWidget)
        self.gridLayout2.addWidget(self.label, 1, 0, 1, 1)
        spacerItem1 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
        self.gridLayout2.addItem(spacerItem1, 2, 1, 1, 1)
        self.label_3 = QtGui.QLabel(self.PlotWidget)
        self.gridLayout2.addWidget(self.label_3, 0, 0, 1, 1)
        self.label_2 = QtGui.QLabel(u'     ',self.PlotWidget)
        self.gridLayout2.addWidget(self.label_2, 4, 0, 1, 1)
        self.label_4 = QtGui.QLabel(self.PlotWidget)
        self.gridLayout2.addWidget(self.label_4, 3, 0, 1, 1)
        spacerItem2 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
        self.gridLayout2.addItem(spacerItem2, 3, 1, 1, 1)

        self.gridLayout.addLayout(self.gridLayout2, 1, 0, 1, 1)

        self.label.setWindowFlags(QtCore.Qt.FramelessWindowHint)
        self.label.setAttribute(QtCore.Qt.WA_TranslucentBackground, True)
        self.label_2.setWindowFlags(QtCore.Qt.FramelessWindowHint)
        self.label_2.setAttribute(QtCore.Qt.WA_TranslucentBackground, True)        
        self.label_3.setWindowFlags(QtCore.Qt.FramelessWindowHint)
        self.label_3.setAttribute(QtCore.Qt.WA_TranslucentBackground, True)
        self.label_4.setWindowFlags(QtCore.Qt.FramelessWindowHint)
        self.label_4.setAttribute(QtCore.Qt.WA_TranslucentBackground, True)

        self.font = QtGui.QFont()
        self.font.setPixelSize(60)   #设置字号32,以像素为单位

        print self.font.family()
        QtGui.QFontDatabase.addApplicationFont("MiuiEx-Light.ttf");
        self.font.setFamily("MIUI EX")
        print self.font.family()
        for i in QtGui.QFontDatabase.families(QtGui.QFontDatabase()):
            # print i.toUtf8()
            pass

        # self.font.setFamily("SimSun") #设置字体
        # self.font.setWeight(1)     #设置字型,不加粗

        self.label.setStyleSheet("color:rgb(0,220,0)")
        self.label.setFont(self.font)
        self.label_2.setStyleSheet("color:rgb(0,220,0)")
        self.label_2.setFont(self.font)

        # --------------------------------------------------------------------------------
        # Connect Event 串口接收信号与槽连接-----------------------------------------------------------------
        self.connect(self.serial.qObj, QtCore.SIGNAL('SerialRecvData'), self.recvSerialData)
        '''电压指令'''
        self.leftWidget.sendVoltageDataButton.clicked.connect(self.requestVoltageData)
        '''电流指令'''
        self.leftWidget.sendGalvanicDataButton.clicked.connect(self.requestGalvanicData)        

        # Timer To ADD AblePort
        self.timer = QtCore.QTimer()
        self.timer.setSingleShot(True)
        self.timer.timeout.connect(self.timerTaskForSearchSeries)
        self.timer.start(0) # Start Now
        
        # self.setFocusProxy()
        self.setFocus()