# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'QtDesigner.ui'
#
# Created by: PyQt5 UI code generator 5.15.1
#
# 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 GUI_Data import *
from PyQt5 import QtCore, QtWidgets, QtGui
from Algorithm import route_calculator
from PyQt5.QtWidgets import *
import pandas as pd











class Ui_MainWindow(object):


    def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(1106, 758)
        MainWindow.setStyleSheet("")
        self.centralwidget = QtWidgets.QWidget(MainWindow)
        self.centralwidget.setObjectName("centralwidget")
        self.TimeSelect = QtWidgets.QTimeEdit(self.centralwidget)
        self.TimeSelect.setGeometry(QtCore.QRect(60, 80, 118, 22))
        self.TimeSelect.setObjectName("TimeSelect")
        self.line_2 = QtWidgets.QFrame(self.centralwidget)
        self.line_2.setGeometry(QtCore.QRect(270, 60, 21, 641))
        self.line_2.setFrameShape(QtWidgets.QFrame.VLine)
        self.line_2.setFrameShadow(QtWidgets.QFrame.Sunken)
        self.line_2.setObjectName("line_2")
        self.startlab = QtWidgets.QLabel(self.centralwidget)
        self.startlab.setGeometry(QtCore.QRect(10, 160, 131, 16))
        font = QtGui.QFont()
        font.setFamily("Calisto MT")
        font.setPointSize(14)
        font.setBold(False)
        font.setWeight(50)
        self.startlab.setFont(font)
        self.startlab.setObjectName("startlab")
        self.destlab = QtWidgets.QLabel(self.centralwidget)
        self.destlab.setGeometry(QtCore.QRect(10, 290, 141, 16))
        font = QtGui.QFont()
        font.setFamily("Calisto MT")
        font.setPointSize(14)
        font.setBold(False)
        font.setWeight(50)
        self.destlab.setFont(font)
        self.destlab.setObjectName("destlab")
        self.pushButton = QtWidgets.QPushButton(self.centralwidget)
        self.pushButton.setGeometry(QtCore.QRect(60, 440, 121, 28))
        self.pushButton.setObjectName("pushButton")
        self.resultframe = QtWidgets.QFrame(self.centralwidget)
        self.resultframe.setGeometry(QtCore.QRect(350, 140, 631, 371))
        self.resultframe.setFrameShape(QtWidgets.QFrame.StyledPanel)
        self.resultframe.setFrameShadow(QtWidgets.QFrame.Raised)
        self.resultframe.setObjectName("resultframe")
        self.tableWidget = QtWidgets.QTableWidget(self.resultframe)
        self.tableWidget.setGeometry(QtCore.QRect(0, 0, 631, 371))
        self.tableWidget.setObjectName("tableWidget")

        # all_data = pd.read_csv('Result.csv')
        # tbl = QtWidgets.QTableWidget(len(all_data), 3)  # X is The number of columns that you need
        # header_labels = ['Route', 'Tube Line', 'Time of Arrival']
        # tbl.setHorizontalHeaderLabels(header_labels)
        # for row in all_data:
        #     inx = all_data.index(row)
        #     # self.tableWidget.insertRow(inx)
        #     self.tableWidget.setItem(inx, Y, QTableWidgetItem('Result.csv'))


        self.cbox1 = QtWidgets.QComboBox(self.centralwidget)
        self.cbox1.setGeometry(QtCore.QRect(40, 200, 171, 51))
        self.cbox1.setObjectName("cbox1")
        self.cbox1.addItems(datalist)
        self.cbox2 = QtWidgets.QComboBox(self.centralwidget)
        self.cbox2.setGeometry(QtCore.QRect(40, 330, 171, 51))
        self.cbox2.setObjectName("cbox2")
        self.cbox2.addItems(datalist)
        self.logo = QtWidgets.QLabel(self.centralwidget)
        self.logo.setGeometry(QtCore.QRect(40, 550, 181, 121))
        self.logo.setText("")
        self.logo.setPixmap(QtGui.QPixmap("Tube Logo.png"))
        self.logo.setScaledContents(True)
        self.logo.setObjectName("logo")
        self.label = QtWidgets.QLabel(self.centralwidget)
        self.label.setGeometry(QtCore.QRect(0, -10, 1171, 781))
        self.label.setAutoFillBackground(False)
        self.label.setText("")
        self.label.setPixmap(QtGui.QPixmap("free-blurred-backgrounds.jpg"))
        self.label.setScaledContents(True)
        self.label.setObjectName("label")
        self.label_2 = QtWidgets.QLabel(self.centralwidget)
        self.label_2.setGeometry(QtCore.QRect(20, 10, 391, 31))
        font = QtGui.QFont()
        font.setFamily("Calisto MT")
        font.setPointSize(20)
        font.setBold(False)
        font.setWeight(50)
        self.label_2.setFont(font)
        self.label_2.setObjectName("label_2")
        self.label.raise_()
        self.TimeSelect.raise_()
        self.line_2.raise_()
        self.startlab.raise_()
        self.destlab.raise_()
        self.pushButton.raise_()
        self.resultframe.raise_()
        self.cbox1.raise_()
        self.cbox2.raise_()
        self.logo.raise_()
        self.label_2.raise_()
        MainWindow.setCentralWidget(self.centralwidget)
        self.toolBar = QtWidgets.QToolBar(MainWindow)
        self.toolBar.setObjectName("toolBar")
        MainWindow.addToolBar(QtCore.Qt.TopToolBarArea, self.toolBar)

        self.retranslateUi(MainWindow)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)

    def retranslateUi(self, MainWindow):
        _translate = QtCore.QCoreApplication.translate
        MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
        self.label_2.setText(_translate("MainWindow", "London Underground Tube Guide"))
        self.startlab.setText(_translate("MainWindow", "Start Station :"))
        self.destlab.setText(_translate("MainWindow", "Destination : "))
        self.pushButton.setText(_translate("MainWindow", "FIND ROUTE"))
        self.toolBar.setWindowTitle(_translate("MainWindow", "toolBar"))
        self.pushButton.clicked.connect(self.click)





    def click(self):
        src = str(self.cbox1.currentText())
        tgt = str(self.cbox2.currentText())
        route_calculator(source = src, target=tgt)


    # Create table





    #Class to insert pandas dataframe to tableview
# class PandasModel(QtCore. QAbstractTableModel):
#     """
#     Class to populate a table view with a pandas dataframe
#     """
#     def __init__(self, data, parent=None):
#         QtCore.QAbstractTableModel.__init__(self, parent)
#         self._data = data
#
#     def rowCount(self, parent=None):
#         return len(self._data.values)
#
#     def columnCount(self, parent=None):
#         return self._data.columns.size
#
#     def data(self, index, role=QtCore.Qt.DisplayRole):
#         if index.isValid():
#             if role == QtCore.Qt.DisplayRole:
#                 return str(self._data.values[index.row()][index.column()])
#         return None
#
#     def headerData(self, col, orientation, role):
#         if orientation == QtCore.Qt.Horizontal and role == QtCore.Qt.DisplayRole:
#             return self._data.columns[col]
#         return None





if __name__ == "__main__":
    import sys
    app = QtWidgets.QApplication(sys.argv)
    MainWindow = QtWidgets.QMainWindow()


    ui = Ui_MainWindow()
    ui.setupUi(MainWindow)
    MainWindow.show()
    sys.exit(app.exec_())
