text: # -*- coding: utf-8 -*-
  
  # Form implementation generated from reading ui file 'emg.ui'
  #
  # Created by: PyQt5 UI code generator 5.15.4
  #
  # WARNING: Any manual changes made to this file will be lost when pyuic5 is
  # run again.  Do not edit this file unless you know what you are doing.
  
  
  from PyQt5 import QtCore, QtGui, QtWidgets
  from PyQt5.QtWidgets import QMessageBox,QDialog,QApplication,QFileDialog, QWidget
  import serial
  import pandas as pd
  import datetime
  import serial.tools.list_ports
  import os
  import sys
  import numpy as np
  from scipy import signal
  import matplotlib.pyplot as plt
  # import keras
  from sklearn.metrics import confusion_matrix,classification_report
  from pyqtgraph import PlotWidget
  
  class Ui_MainWindow(QWidget):
      wkt, pipix, alisx, iterate = [], [], [], []
      header_list = ['Waktu','Pipi','Alis']
      ptr = 0
      def setupUi(self, MainWindow):
          MainWindow.setObjectName("MainWindow")
          MainWindow.resize(755, 559)
          font = QtGui.QFont()
          font.setPointSize(12)
          MainWindow.setFont(font)
          MainWindow.setAutoFillBackground(False)
          MainWindow.setStyleSheet("background-color: rgb(52, 52, 52);\n"
          "")
          self.centralwidget = QtWidgets.QWidget(MainWindow)
          self.centralwidget.setObjectName("centralwidget")
          self.gridLayout_2 = QtWidgets.QGridLayout(self.centralwidget)
          self.gridLayout_2.setObjectName("gridLayout_2")
          self.listWidget = QtWidgets.QListWidget(self.centralwidget)
          font = QtGui.QFont()
          font.setPointSize(6)
          font.setItalic(True)
          self.listWidget.setFont(font)
          self.listWidget.setStyleSheet("background-color: rgb(0, 0, 0);\n"
          "gridline-color: rgb(255, 255, 255);\n"
          "border: 1px solid white;\n"
          "")
          self.listWidget.setObjectName("listWidget")
          self.gridLayout_2.addWidget(self.listWidget, 4, 1, 1, 1)
          self.horizontalLayout = QtWidgets.QHBoxLayout()
          self.horizontalLayout.setObjectName("horizontalLayout")
          self.startButton = QtWidgets.QPushButton(self.centralwidget)
          sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Preferred)
          sizePolicy.setHorizontalStretch(0)
          sizePolicy.setVerticalStretch(0)
          sizePolicy.setHeightForWidth(self.startButton.sizePolicy().hasHeightForWidth())
          self.startButton.setSizePolicy(sizePolicy)
          font = QtGui.QFont()
          font.setFamily("NewsGoth BT")
          font.setPointSize(10)
          font.setBold(True)
          font.setWeight(75)
          self.startButton.setFont(font)
          self.startButton.setStyleSheet("QPushButton::hover:!pressed\n"
          "{background-color : rgb(255, 170, 0);}\n"
          "\n"
          "QPushButton::!pressed\n"
          "{background-color : rgb(52, 52, 52);\n"
          "color:white;\n"
          "border: 1px solid white;}\n"
          "\n"
          "QPushButton::pressed\n"
          "{background-color :rgb(238, 159, 0);\n"
          "color:white;}\n"
          "\n"
          "\n"
          "")
          self.startButton.setObjectName("startButton")
          self.horizontalLayout.addWidget(self.startButton)
          self.stopButton = QtWidgets.QPushButton(self.centralwidget)
          sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Preferred)
          sizePolicy.setHorizontalStretch(0)
          sizePolicy.setVerticalStretch(0)
          sizePolicy.setHeightForWidth(self.stopButton.sizePolicy().hasHeightForWidth())
          self.stopButton.setSizePolicy(sizePolicy)
          palette = QtGui.QPalette()
          brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
          brush.setStyle(QtCore.Qt.SolidPattern)
          palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.WindowText, brush)
          brush = QtGui.QBrush(QtGui.QColor(52, 52, 52))
          brush.setStyle(QtCore.Qt.SolidPattern)
          palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Button, brush)
          brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
          brush.setStyle(QtCore.Qt.SolidPattern)
          palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Text, brush)
          brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
          brush.setStyle(QtCore.Qt.SolidPattern)
          palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.ButtonText, brush)
          brush = QtGui.QBrush(QtGui.QColor(52, 52, 52))
          brush.setStyle(QtCore.Qt.SolidPattern)
          palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Base, brush)
          brush = QtGui.QBrush(QtGui.QColor(52, 52, 52))
          brush.setStyle(QtCore.Qt.SolidPattern)
          palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Window, brush)
          brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
          brush.setStyle(QtCore.Qt.SolidPattern)
          palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.WindowText, brush)
          brush = QtGui.QBrush(QtGui.QColor(52, 52, 52))
          brush.setStyle(QtCore.Qt.SolidPattern)
          palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Button, brush)
          brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
          brush.setStyle(QtCore.Qt.SolidPattern)
          palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Text, brush)
          brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
          brush.setStyle(QtCore.Qt.SolidPattern)
          palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.ButtonText, brush)
          brush = QtGui.QBrush(QtGui.QColor(52, 52, 52))
          brush.setStyle(QtCore.Qt.SolidPattern)
          palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Base, brush)
          brush = QtGui.QBrush(QtGui.QColor(52, 52, 52))
          brush.setStyle(QtCore.Qt.SolidPattern)
          palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Window, brush)
          brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
          brush.setStyle(QtCore.Qt.SolidPattern)
          palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.WindowText, brush)
          brush = QtGui.QBrush(QtGui.QColor(52, 52, 52))
          brush.setStyle(QtCore.Qt.SolidPattern)
          palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Button, brush)
          brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
          brush.setStyle(QtCore.Qt.SolidPattern)
          palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Text, brush)
          brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
          brush.setStyle(QtCore.Qt.SolidPattern)
          palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.ButtonText, brush)
          brush = QtGui.QBrush(QtGui.QColor(52, 52, 52))
          brush.setStyle(QtCore.Qt.SolidPattern)
          palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Base, brush)
          brush = QtGui.QBrush(QtGui.QColor(52, 52, 52))
          brush.setStyle(QtCore.Qt.SolidPattern)
          palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Window, brush)
          self.stopButton.setPalette(palette)
          font = QtGui.QFont()
          font.setFamily("NewsGoth BT")
          font.setPointSize(10)
          font.setBold(True)
          font.setWeight(75)
          self.stopButton.setFont(font)
          self.stopButton.setStyleSheet("QPushButton::hover:!pressed\n"
          "{background-color : rgb(255, 170, 0);}\n"
          "\n"
          "QPushButton::!pressed\n"
          "{background-color : rgb(52, 52, 52);\n"
          "color:white;\n"
          "border: 1px solid white;}\n"
          "\n"
          "QPushButton::pressed\n"
          "{background-color :rgb(238, 159, 0);\n"
          "color:white;}\n"
          "\n"
          "")
          self.stopButton.setObjectName("stopButton")
          self.horizontalLayout.addWidget(self.stopButton)
          self.gridLayout_2.addLayout(self.horizontalLayout, 6, 1, 1, 1)
          self.lineEmotion = QtWidgets.QLineEdit(self.centralwidget)
          palette = QtGui.QPalette()
          brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
          brush.setStyle(QtCore.Qt.SolidPattern)
          palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.WindowText, brush)
          brush = QtGui.QBrush(QtGui.QColor(0, 0, 0))
          brush.setStyle(QtCore.Qt.SolidPattern)
          palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Button, brush)
          brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
          brush.setStyle(QtCore.Qt.SolidPattern)
          palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Text, brush)
          brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
          brush.setStyle(QtCore.Qt.SolidPattern)
          palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.ButtonText, brush)
          brush = QtGui.QBrush(QtGui.QColor(0, 0, 0))
          brush.setStyle(QtCore.Qt.SolidPattern)
          palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Base, brush)
          brush = QtGui.QBrush(QtGui.QColor(0, 0, 0))
          brush.setStyle(QtCore.Qt.SolidPattern)
          palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Window, brush)
          brush = QtGui.QBrush(QtGui.QColor(255, 170, 0))
          brush.setStyle(QtCore.Qt.SolidPattern)
          palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Highlight, brush)
          brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
          brush.setStyle(QtCore.Qt.SolidPattern)
          palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.WindowText, brush)
          brush = QtGui.QBrush(QtGui.QColor(0, 0, 0))
          brush.setStyle(QtCore.Qt.SolidPattern)
          palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Button, brush)
          brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
          brush.setStyle(QtCore.Qt.SolidPattern)
          palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Text, brush)
          brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
          brush.setStyle(QtCore.Qt.SolidPattern)
          palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.ButtonText, brush)
          brush = QtGui.QBrush(QtGui.QColor(0, 0, 0))
          brush.setStyle(QtCore.Qt.SolidPattern)
          palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Base, brush)
          brush = QtGui.QBrush(QtGui.QColor(0, 0, 0))
          brush.setStyle(QtCore.Qt.SolidPattern)
          palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Window, brush)
          brush = QtGui.QBrush(QtGui.QColor(255, 170, 0))
          brush.setStyle(QtCore.Qt.SolidPattern)
          palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Highlight, brush)
          brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
          brush.setStyle(QtCore.Qt.SolidPattern)
          palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.WindowText, brush)
          brush = QtGui.QBrush(QtGui.QColor(0, 0, 0))
          brush.setStyle(QtCore.Qt.SolidPattern)
          palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Button, brush)
          brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
          brush.setStyle(QtCore.Qt.SolidPattern)
          palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Text, brush)
          brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
          brush.setStyle(QtCore.Qt.SolidPattern)
          palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.ButtonText, brush)
          brush = QtGui.QBrush(QtGui.QColor(0, 0, 0))
          brush.setStyle(QtCore.Qt.SolidPattern)
          palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Base, brush)
          brush = QtGui.QBrush(QtGui.QColor(0, 0, 0))
          brush.setStyle(QtCore.Qt.SolidPattern)
          palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Window, brush)
          brush = QtGui.QBrush(QtGui.QColor(0, 120, 215))
          brush.setStyle(QtCore.Qt.SolidPattern)
          palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Highlight, brush)
          self.lineEmotion.setPalette(palette)
          font = QtGui.QFont()
          font.setFamily("NewsGoth BT")
          font.setPointSize(10)
          font.setBold(True)
          font.setWeight(75)
          self.lineEmotion.setFont(font)
          self.lineEmotion.setStyleSheet("\n"
          "QLineEdit::!pressed\n"
          "{background-color:black;\n"
          "border : 1px solid white;\n"
          "color: white}\n"
          "\n"
          "QLineEdit::focus\n"
          "{border : 1px solid rgb(255, 170, 0);\n"
          "color: white}\n"
          "\n"
          "QLineEdit::hover\n"
          "{border : 1px solid rgb(255, 170, 0);\n"
          "color: white}")
          self.lineEmotion.setAlignment(QtCore.Qt.AlignCenter)
          self.lineEmotion.setObjectName("lineEmotion")
          self.gridLayout_2.addWidget(self.lineEmotion, 3, 1, 1, 1)
          self.lineSubject = QtWidgets.QLineEdit(self.centralwidget)
          font = QtGui.QFont()
          font.setFamily("NewsGoth BT")
          font.setPointSize(10)
          font.setBold(True)
          font.setWeight(75)
          self.lineSubject.setFont(font)
          self.lineSubject.setStyleSheet("\n"
          "QLineEdit::!pressed\n"
          "{background-color:black;\n"
          "border : 1px solid white;\n"
          "color: white}\n"
          "\n"
          "QLineEdit::focus\n"
          "{border : 1px solid rgb(255, 170, 0);\n"
          "color: white}\n"
          "\n"
          "QLineEdit::hover\n"
          "{border : 1px solid rgb(255, 170, 0);\n"
          "color: white}\n"
          "\n"
          "\n"
          "")
          self.lineSubject.setAlignment(QtCore.Qt.AlignCenter)
          self.lineSubject.setObjectName("lineSubject")
          self.gridLayout_2.addWidget(self.lineSubject, 1, 1, 1, 1)
          self.horizontalLayout_3 = QtWidgets.QHBoxLayout()
          self.horizontalLayout_3.setObjectName("horizontalLayout_3")
          self.statusText = QtWidgets.QLabel(self.centralwidget)
          font = QtGui.QFont()
          font.setPointSize(9)
          font.setBold(True)
          font.setWeight(75)
          self.statusText.setFont(font)
          self.statusText.setStyleSheet("color: rgb(255, 255, 255);")
          self.statusText.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
          self.statusText.setWordWrap(False)
          self.statusText.setObjectName("statusText")
          self.horizontalLayout_3.addWidget(self.statusText)
          self.statusValue = QtWidgets.QLabel(self.centralwidget)
          font = QtGui.QFont()
          font.setPointSize(9)
          font.setBold(True)
          font.setWeight(75)
          self.statusValue.setFont(font)
          self.statusValue.setStyleSheet("color: rgb(255, 255, 255);")
          self.statusValue.setAlignment(QtCore.Qt.AlignCenter)
          self.statusValue.setObjectName("statusValue")
          self.horizontalLayout_3.addWidget(self.statusValue)
          self.gridLayout_2.addLayout(self.horizontalLayout_3, 7, 1, 1, 1)
          self.labelEmotion = QtWidgets.QLabel(self.centralwidget)
          font = QtGui.QFont()
          font.setFamily("NewsGoth BT")
          font.setPointSize(14)
          font.setBold(True)
          font.setWeight(75)
          self.labelEmotion.setFont(font)
          self.labelEmotion.setStyleSheet("\n"
          "color: rgb(255, 255, 255);")
          self.labelEmotion.setAlignment(QtCore.Qt.AlignCenter)
          self.labelEmotion.setObjectName("labelEmotion")
          self.gridLayout_2.addWidget(self.labelEmotion, 2, 1, 1, 1)
          self.gridLayout = QtWidgets.QGridLayout()
          self.gridLayout.setObjectName("gridLayout")
          spacerItem = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
          self.gridLayout.addItem(spacerItem, 2, 0, 1, 1)
          self.labelTitle = QtWidgets.QLabel(self.centralwidget)
          font = QtGui.QFont()
          font.setFamily("NewsGoth BT")
          font.setPointSize(16)
          font.setBold(True)
          font.setItalic(False)
          font.setWeight(75)
          self.labelTitle.setFont(font)
          self.labelTitle.setStyleSheet("\n"
          "color: rgb(255, 255, 255);")
          self.labelTitle.setAlignment(QtCore.Qt.AlignCenter)
          self.labelTitle.setObjectName("labelTitle")
          self.gridLayout.addWidget(self.labelTitle, 0, 2, 1, 1)
          spacerItem1 = QtWidgets.QSpacerItem(378, 17, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
          self.gridLayout.addItem(spacerItem1, 3, 2, 1, 1)
          self.widgetPlot = PlotWidget(self.centralwidget)
          self.widgetPlot.setStyleSheet("border:1px solid white")
          self.widgetPlot.setObjectName("widgetPlot")
          self.gridLayout.addWidget(self.widgetPlot, 2, 2, 1, 1)
          self.gridLayout_2.addLayout(self.gridLayout, 0, 0, 8, 1)
          self.horizontalLayout_2 = QtWidgets.QHBoxLayout()
          self.horizontalLayout_2.setObjectName("horizontalLayout_2")
          self.label_port = QtWidgets.QLabel(self.centralwidget)
          font = QtGui.QFont()
          font.setFamily("NewsGoth BT")
          font.setPointSize(12)
          font.setBold(True)
          font.setWeight(75)
          self.label_port.setFont(font)
          self.label_port.setStyleSheet("color: rgb(255, 255, 255);")
          self.label_port.setObjectName("label_port")
          self.horizontalLayout_2.addWidget(self.label_port)
          self.comboBoxPort = QtWidgets.QComboBox(self.centralwidget)
          sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred)
          sizePolicy.setHorizontalStretch(0)
          sizePolicy.setVerticalStretch(0)
          sizePolicy.setHeightForWidth(self.comboBoxPort.sizePolicy().hasHeightForWidth())
          self.comboBoxPort.setSizePolicy(sizePolicy)
          palette = QtGui.QPalette()
          brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
          brush.setStyle(QtCore.Qt.SolidPattern)
          palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.WindowText, brush)
          brush = QtGui.QBrush(QtGui.QColor(0, 0, 0))
          brush.setStyle(QtCore.Qt.SolidPattern)
          palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Button, brush)
          brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
          brush.setStyle(QtCore.Qt.SolidPattern)
          palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Text, brush)
          brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
          brush.setStyle(QtCore.Qt.SolidPattern)
          palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.ButtonText, brush)
          brush = QtGui.QBrush(QtGui.QColor(0, 0, 0))
          brush.setStyle(QtCore.Qt.SolidPattern)
          palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Base, brush)
          brush = QtGui.QBrush(QtGui.QColor(0, 0, 0))
          brush.setStyle(QtCore.Qt.SolidPattern)
          palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Window, brush)
          brush = QtGui.QBrush(QtGui.QColor(255, 170, 0))
          brush.setStyle(QtCore.Qt.SolidPattern)
          palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Highlight, brush)
          brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
          brush.setStyle(QtCore.Qt.SolidPattern)
          palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.WindowText, brush)
          brush = QtGui.QBrush(QtGui.QColor(0, 0, 0))
          brush.setStyle(QtCore.Qt.SolidPattern)
          palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Button, brush)
          brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
          brush.setStyle(QtCore.Qt.SolidPattern)
          palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Text, brush)
          brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
          brush.setStyle(QtCore.Qt.SolidPattern)
          palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.ButtonText, brush)
          brush = QtGui.QBrush(QtGui.QColor(0, 0, 0))
          brush.setStyle(QtCore.Qt.SolidPattern)
          palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Base, brush)
          brush = QtGui.QBrush(QtGui.QColor(0, 0, 0))
          brush.setStyle(QtCore.Qt.SolidPattern)
          palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Window, brush)
          brush = QtGui.QBrush(QtGui.QColor(255, 170, 0))
          brush.setStyle(QtCore.Qt.SolidPattern)
          palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Highlight, brush)
          brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
          brush.setStyle(QtCore.Qt.SolidPattern)
          palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.WindowText, brush)
          brush = QtGui.QBrush(QtGui.QColor(0, 0, 0))
          brush.setStyle(QtCore.Qt.SolidPattern)
          palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Button, brush)
          brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
          brush.setStyle(QtCore.Qt.SolidPattern)
          palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Text, brush)
          brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
          brush.setStyle(QtCore.Qt.SolidPattern)
          palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.ButtonText, brush)
          brush = QtGui.QBrush(QtGui.QColor(0, 0, 0))
          brush.setStyle(QtCore.Qt.SolidPattern)
          palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Base, brush)
          brush = QtGui.QBrush(QtGui.QColor(0, 0, 0))
          brush.setStyle(QtCore.Qt.SolidPattern)
          palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Window, brush)
          brush = QtGui.QBrush(QtGui.QColor(0, 0, 0))
          brush.setStyle(QtCore.Qt.SolidPattern)
          palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Highlight, brush)
          self.comboBoxPort.setPalette(palette)
          font = QtGui.QFont()
          font.setFamily("NewsGoth BT")
          font.setPointSize(12)
          font.setBold(True)
          font.setWeight(75)
          self.comboBoxPort.setFont(font)
          self.comboBoxPort.setMouseTracking(False)
          self.comboBoxPort.setStyleSheet("QComboBox {\n"
          "background-color:black;\n"
          "border : 1px solid white;\n"
          "color: white;\n"
          "}\n"
          "\n"
          "QComboBox:hover{\n"
          "border : 1px solid rgb(255, 170, 0);\n"
          "color: white;\n"
          "}\n"
          "\n"
          "QComboBox QAbstractItemView\n"
          "{\n"
          "background-color: rgb(255, 255, 255);\n"
          "selection-background-color: rgb(170, 170, 255);\n"
          "border-radius: 0px;\n"
          "color: rgb(0, 0, 0);\n"
          "font: 14pt;\n"
          "}\n"
          "")
          self.comboBoxPort.setObjectName("comboBoxPort")
          self.horizontalLayout_2.addWidget(self.comboBoxPort)
          self.gridLayout_2.addLayout(self.horizontalLayout_2, 5, 1, 1, 1)
          self.labelSubject = QtWidgets.QLabel(self.centralwidget)
          ports = serial.tools.list_ports.comports()
          ports = [p.device for p in ports]
          self.comboBoxPort.clear()
          self.comboBoxPort.addItems(ports)
          font = QtGui.QFont()
          font.setFamily("NewsGoth BT")
          font.setPointSize(14)
          font.setBold(True)
          font.setWeight(75)
          self.labelSubject.setFont(font)
          self.labelSubject.setStyleSheet("\n"
          "color: rgb(255, 255, 255);")
          self.labelSubject.setAlignment(QtCore.Qt.AlignCenter)
          self.labelSubject.setObjectName("labelSubject")
          self.gridLayout_2.addWidget(self.labelSubject, 0, 1, 1, 1)
          self.statusValue_2 = QtWidgets.QLabel(self.centralwidget)
          font = QtGui.QFont()
          font.setPointSize(9)
          font.setBold(True)
          font.setWeight(75)
          self.statusValue_2.setFont(font)
          self.statusValue_2.setStyleSheet("color: rgb(255, 255, 255);")
          self.statusValue_2.setAlignment(QtCore.Qt.AlignCenter)
          self.statusValue_2.setObjectName("statusValue_2")
          self.gridLayout_2.addWidget(self.statusValue_2, 8, 0, 1, 2)
          MainWindow.setCentralWidget(self.centralwidget)
          self.menubar = QtWidgets.QMenuBar(MainWindow)
          self.menubar.setGeometry(QtCore.QRect(0, 0, 755, 21))
          self.menubar.setStyleSheet("QMenuBar{\n"
          "background-color:rgb(52, 52, 52);\n"
          "color: rgb(255, 255, 255);\n"
          "}\n"
          "\n"
          "QMenuBar::item:selected{\n"
          "background-color:rgb(255, 170, 0);\n"
          "color: rgb(255, 255, 255);\n"
          "}")
          self.menubar.setObjectName("menubar")
          self.menuFile = QtWidgets.QMenu(self.menubar)
          palette = QtGui.QPalette()
          brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
          brush.setStyle(QtCore.Qt.SolidPattern)
          palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.WindowText, brush)
          brush = QtGui.QBrush(QtGui.QColor(52, 52, 52))
          brush.setStyle(QtCore.Qt.SolidPattern)
          palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Button, brush)
          brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
          brush.setStyle(QtCore.Qt.SolidPattern)
          palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Text, brush)
          brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
          brush.setStyle(QtCore.Qt.SolidPattern)
          palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.ButtonText, brush)
          brush = QtGui.QBrush(QtGui.QColor(52, 52, 52))
          brush.setStyle(QtCore.Qt.SolidPattern)
          palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Base, brush)
          brush = QtGui.QBrush(QtGui.QColor(52, 52, 52))
          brush.setStyle(QtCore.Qt.SolidPattern)
          palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Window, brush)
          brush = QtGui.QBrush(QtGui.QColor(255, 170, 0))
          brush.setStyle(QtCore.Qt.SolidPattern)
          palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Highlight, brush)
          brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
          brush.setStyle(QtCore.Qt.SolidPattern)
          palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.WindowText, brush)
          brush = QtGui.QBrush(QtGui.QColor(52, 52, 52))
          brush.setStyle(QtCore.Qt.SolidPattern)
          palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Button, brush)
          brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
          brush.setStyle(QtCore.Qt.SolidPattern)
          palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Text, brush)
          brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
          brush.setStyle(QtCore.Qt.SolidPattern)
          palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.ButtonText, brush)
          brush = QtGui.QBrush(QtGui.QColor(52, 52, 52))
          brush.setStyle(QtCore.Qt.SolidPattern)
          palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Base, brush)
          brush = QtGui.QBrush(QtGui.QColor(52, 52, 52))
          brush.setStyle(QtCore.Qt.SolidPattern)
          palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Window, brush)
          brush = QtGui.QBrush(QtGui.QColor(255, 170, 0))
          brush.setStyle(QtCore.Qt.SolidPattern)
          palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Highlight, brush)
          brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
          brush.setStyle(QtCore.Qt.SolidPattern)
          palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.WindowText, brush)
          brush = QtGui.QBrush(QtGui.QColor(52, 52, 52))
          brush.setStyle(QtCore.Qt.SolidPattern)
          palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Button, brush)
          brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
          brush.setStyle(QtCore.Qt.SolidPattern)
          palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Text, brush)
          brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
          brush.setStyle(QtCore.Qt.SolidPattern)
          palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.ButtonText, brush)
          brush = QtGui.QBrush(QtGui.QColor(52, 52, 52))
          brush.setStyle(QtCore.Qt.SolidPattern)
          palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Base, brush)
          brush = QtGui.QBrush(QtGui.QColor(52, 52, 52))
          brush.setStyle(QtCore.Qt.SolidPattern)
          palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Window, brush)
          brush = QtGui.QBrush(QtGui.QColor(255, 170, 0))
          brush.setStyle(QtCore.Qt.SolidPattern)
          palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Highlight, brush)
          self.menuFile.setPalette(palette)
          self.menuFile.setStyleSheet("QMenu{\n"
          "background-color: rgb(52, 52, 52);\n"
          "color: rgb(255, 255, 255);\n"
          "selection-background-color:rgb(255, 170, 0)\n"
          "}\n"
          "\n"
          "QMenu::item:selected\n"
          "{background-color : rgb(255, 170, 0)}\n"
          "\n"
          "QMenu::on\n"
          "{background-color : rgb(255, 170, 0)}\n"
          "")
          self.menuFile.setObjectName("menuFile")
          MainWindow.setMenuBar(self.menubar)
          self.statusbar = QtWidgets.QStatusBar(MainWindow)
          self.statusbar.setObjectName("statusbar")
          MainWindow.setStatusBar(self.statusbar)
          self.actionExit = QtWidgets.QAction(MainWindow)
          self.actionExit.setObjectName("actionExit")
          self.actionImport_CSV = QtWidgets.QAction(MainWindow)
          self.actionImport_CSV.setObjectName("actionImport_CSV")
          self.actionNew = QtWidgets.QAction(MainWindow)
          self.actionNew.setObjectName("actionNew")
          self.actionImport_CSV_2 = QtWidgets.QAction(MainWindow)
          self.actionImport_CSV_2.setObjectName("actionImport_CSV_2")
          self.actionSave_as_CSV = QtWidgets.QAction(MainWindow)
          self.actionSave_as_CSV.setObjectName("actionSave_as_CSV")
          self.menuFile.addAction(self.actionImport_CSV_2)
          self.menuFile.addAction(self.actionSave_as_CSV)
          self.menubar.addAction(self.menuFile.menuAction())
  
          self.retranslateUi(MainWindow)
          QtCore.QMetaObject.connectSlotsByName(MainWindow)
  #=================== EDIT HERE======================================
          # self.startButton.clicked.connect(lambda: self.start_button('START'))
          self.startButton.clicked.connect(lambda: self.draw())
          # self.stopButton.clicked.connect(lambda: self.start_button('STOP'))
          self.stopButton.clicked.connect(lambda: self.clearplot())
          self.actionSave_as_CSV.triggered.connect(lambda: self.action_save_csv())
          self.actionImport_CSV_2.triggered.connect(lambda: self.browsefile())
  
      def start_button(self,text):
          self.condition = 1
          self.pipi.clear()
          self.alis.clear()
          self.wkt.clear()
          self.statusValue.setText(text)
          self.statusValue.adjustSize()
          # while self.condition:
          #         self.read_arduino(arduino)
  
      def stop_button(self):
          self.condition = 0
          self.statusValue.setText(text)
          self.statusValue.adjustSize()
          # arduino.close()
  
      def get_port(self):
          ports = serial.tools.list_ports.comports()
          ports = [p.device for p in ports]
          self.comboBoxPort.clear()
          self.comboBoxPort.addItems(ports)
          return ports
  
      def read_arduino(self,arduino):
          data = arduino.readline()
          b = data.decode("ISO-8859-1").strip()
          waktuReal = datetime.datetime.now()
          waktu = waktuReal.strftime('%H:%M:%S.%f')[:-3]
          c = b.split(',')
          if sys.getsizeof(c[0])==56:
                  Ui_MainWindow.pipi.append(c[0])
                  Ui_MainWindow.alis.append(c[1])
                  Ui_MainWindow.wkt.append(waktu)
  
      def action_save_csv(self):
          self.statusValue.setText('Saved!')
          root = 'Data_raw'
          d_t = list(zip(self.wkt,self.pipi,self.alis))
          mentah = pd.DataFrame(d_t, columns=self.header_list)
          nama_file = self.lineSubject.text()+self.lineEmotion.text()
          finaldirs = os.path.join(root,'%s.csv'%nama_file)
          mentah.to_csv(finaldirs,header=self.header_list,mode='w+')
          return mentah
  
      def show_popup(self):
          msg = QMessageBox()
          msg.setWindowTitle('Import CSV')
          xx = msg.exec()
  
      def browsefile(self):
          fname = QFileDialog.getOpenFileName(self,'Open file CSV', 
          'E:\Kuliah\Tugas Akhir\Source Code\test_git\SkripsiEmosiRNN\IAPS hari 2','CSV files (*.csv)')
          self.statusValue_2.setText(fname[0])
          self.statusValue_2.adjustSize()
          df = pd.read_csv(str(fname[0]))
          self.statusValue.setText('Loaded !')
          self.statusValue.adjustSize()
          return df
  
      def action_import_csv(self):
          self.browsefile()
  
      def draw(self):
          df1 = pd.read_csv(self.statusValue_2.text())
          pipi = df1['Pipi'].to_numpy()
          alis = df1['Alis'].to_numpy()
          length = len(pipi)
          self.statusValue.setText('Start !')
          self.iterate = [p for p in range(0,length)]
          self.widgetPlot.plot(self.iterate,pipi,pen=('y'),name='EMG Pipi')
          self.widgetPlot.plot(self.iterate,alis,pen=('g'),name='EMG Alis')
          # for j in range(0,length):
          #         self.iterate.append(int(j))
          #         self.pipix.append(pipi[j])
          #         self.alisx.append(alis[j])
          #         self.widgetPlot.plot(self.iterate,self.pipix)
      def update(self):
          global ptr
          self.statusValue.setText('Start !')
          # while (arduinoData.inWaiting()==0):                         #wait until there is data available
          #     pass # do nothing
          drawplot1 = self.widgetPlot.plot(pen=('y'),name = 'EMG Pipi')
          drawplot2 = self.widgetPlot.plot(pen=('b'), name = 'EMG Alis')
          arduinoString = arduinoData.readline()
          b = arduinoString.decode("ISO-8859-1").strip()
          c = b.split(',')
          if sys.getsizeof(c[0])==56:
                  self.pipix=np.append(self.pipix,c[0])
                  self.alisx=np.append(self.alisx,c[1])
                  self.widgetPlot.setData(self.ptr,self.pipix)
          # df1 = pd.read_csv(self.statusValue_2.text())
          # pipi = df1['Pipi'].to_numpy()
          # alis = df1['Alis'].to_numpy()
          # length = len(pipi)
          self.ptr+=1
          
          # def model_predict(self):
          #         model = keras.models.load_model('iaps_real4')
                  
  
  
  
  
          # self.show_popup()
      def clearplot(self):
              self.statusValue.setText('Stop')
              self.widgetPlot.clear()
  
      def retranslateUi(self, MainWindow):
          _translate = QtCore.QCoreApplication.translate
          MainWindow.setWindowTitle(_translate("MainWindow", "EMGGraph"))
          self.startButton.setText(_translate("MainWindow", "START"))
          self.stopButton.setText(_translate("MainWindow", "STOP"))
          self.statusText.setText(_translate("MainWindow", "Status : "))
          self.statusValue.setText(_translate("MainWindow", "-"))
          self.labelEmotion.setText(_translate("MainWindow", "Notes"))
          self.labelTitle.setText(_translate("MainWindow", "Electromyograph Signal Graph"))
          self.label_port.setText(_translate("MainWindow", "Port"))
          self.labelSubject.setText(_translate("MainWindow", "Subject"))
          self.statusValue_2.setText(_translate("MainWindow", "-"))
          self.menuFile.setTitle(_translate("MainWindow", "File"))
          self.actionExit.setText(_translate("MainWindow", "Exit"))
          self.actionImport_CSV.setText(_translate("MainWindow", "Import CSV"))
          self.actionNew.setText(_translate("MainWindow", "New"))
          self.actionImport_CSV_2.setText(_translate("MainWindow", "Import CSV"))
          self.actionSave_as_CSV.setText(_translate("MainWindow", "Save as CSV"))
  
  from pyqtgraph import PlotWidget
  
  
  if __name__ == "__main__":
      import sys
      arduinoData = serial.Serial('COM6',9600)
      app = QtWidgets.QApplication(sys.argv)
      MainWindow = QtWidgets.QMainWindow()
      ui = Ui_MainWindow()
      ui.setupUi(MainWindow)
      MainWindow.show()
  #     p = list(serial.tools.list_ports.comports())
  #     arduino = serial.Serial(p[0].device,baudrate=9600)
      sys.exit(app.exec_())
  