import sys from PyQt4.QtCore import * from PyQt4.QtGui import * from csv_service import csvServ from models import * #from windows import * from GUI.main_window import * from GUI.inbox_window import * from GUI.message_window import * from GUI.sent_window import * msgs=csvServ("sms.csv", "sent.csv") def showInboxMessages(): #ui.stackedWidget.setCurrentIndex(1) inboxWindow.show() def showSentMessages(): #ui.stackedWidget.setCurrentIndex(3) sentWindow.show() def showMsg(): #ui.stackedWidget.setCurrentIndex(2) msg = msgs.getMsg(inboxWindow.listView.currentIndex().row()) print msg.getMsgText() inboxMsgWindow.msg_text.setText(msg.getMsgText()) inboxMsgWindow.msg_address.setText(msg.getSenderName()) inboxMsgWindow.msg_date.setText(msg.getDate()) ##################################### if msg.getImageData() == "": inboxMsgWindow.frame.setPixmap(QPixmap("graphics/contact_trans_120.png")) else: arr=QByteArray(msg.getImageData()) img = QPixmap() img.loadFromData(arr) inboxMsgWindow.frame.setPixmap(img.scaled(120,120, Qt.KeepAspectRatioByExpanding)) inboxMsgWindow.show() def showSentMsg(): #ui.stackedWidget.setCurrentIndex(4) msg = msgs.getMsg(sentWindow.listView.currentIndex().row(), 1) sentMsgWindow.msg_text.setText(msg.getMsgText()) sentMsgWindow.msg_address.setText(msg.getRecName()) sentMsgWindow.msg_date.setText(msg.getDate()) ##################################### if msg.getImageData() == "": sentMsgWindow.frame.setPixmap(QPixmap("graphics/contact_trans_120.png")) else: arr=QByteArray(msg.getImageData()) img = QPixmap() img.loadFromData(arr) sentMsgWindow.frame.setPixmap(img.scaled(120,120, Qt.KeepAspectRatioByExpanding)) sentMsgWindow.show() def populateInbox(): #allSenders=msgs.getAllSenders() #for x in allSenders: recvModel=RecvModel(msgs.recvLst) inboxWindow.listView.setModel(recvModel) def populateSent(): #allSenders=msgs.getAllSenders() #for x in allSenders: sentModel=SentModel(msgs.sentLst) sentWindow.listView.setModel(sentModel) #for x in msgs.sentLst: #print x.getRecName() def init(): ################## Connect SIGNALS ####################### QObject.connect(mainWindow.inbox_button, SIGNAL("clicked()"), showInboxMessages) QObject.connect(mainWindow.sent_button, SIGNAL("clicked()"),showSentMessages) QObject.connect(inboxWindow.listView, SIGNAL("clicked(QModelIndex)"),showMsg) QObject.connect(sentWindow.listView, SIGNAL("clicked(QModelIndex)"),showSentMsg) #QObject.connect(ui.msg_back, SIGNAL("clicked()"),showInboxMessages) #QObject.connect(ui.sent_msg_back, SIGNAL("clicked()"),showSentMessages) #QObject.connect(ui.sentView, SIGNAL("clicked(QModelIndex)"),showSentMsg) ############################################################ ################# Other Init functions ##################### populateInbox() populateSent() ########################################################### if __name__ == '__main__': app = QApplication(sys.argv) #MainWindow = QtGui.QMainWindow() #ui = Ui_MainWindow() #ui.setupUi(MainWindow) #MainWindow.show() ####### Initialization ######### mainWindow = Ui_MainWindow() inboxWindow = Ui_InboxWindow(mainWindow) sentWindow = Ui_SentWindow(mainWindow) inboxMsgWindow = Ui_MessageWindow(inboxWindow) sentMsgWindow = Ui_MessageWindow(sentWindow) #mainWindow=QMainWindow() init() ################################ mainWindow.show() sys.exit(app.exec_())