def __init__(self, parent=None): QtGui.QWidget.__init__(self, parent) self.ui = Ui_Hakija() self.ui.setupUi(self) self.ui.endDate.setDate(QtCore.QDateTime.currentDateTime().date()) self.ui.startDate.setDate(QtCore.QDateTime.currentDateTime().date()) self.ui.endDate.setMaximumDate( QtCore.QDateTime.currentDateTime().date()) self.ui.startDate.setMaximumDate( QtCore.QDateTime.currentDateTime().date()) # Disable cancel button self.ui.cancelButton.setDisabled(True) # Create thread object and connect its signals to methods on # this object self.ponderous = DownloadData() self.connect(self.ponderous, QtCore.SIGNAL("updategui(PyQt_PyObject)"), self.appendUpdates) self.connect(self.ponderous, QtCore.SIGNAL("finished()"), self.downloadComplete) QtCore.QObject.connect(self.ui.downloadButton, QtCore.SIGNAL("clicked()"), self.startDownload) QtCore.QObject.connect(self.ui.cancelButton, QtCore.SIGNAL("clicked()"), self.cancelDownload) QtCore.QObject.connect(self.ui.actionExit, QtCore.SIGNAL("triggered()"), sys.exit) self.ui.actionExit.setShortcut("Ctrl+Q") QtCore.QObject.connect(self.ui.actionaboutHakija, QtCore.SIGNAL("triggered()"), self.aboutHakija)
class Hakija(QtGui.QMainWindow): def __init__(self, parent=None): QtGui.QWidget.__init__(self, parent) self.ui = Ui_Hakija() self.ui.setupUi(self) self.ui.endDate.setDate(QtCore.QDateTime.currentDateTime().date()) self.ui.startDate.setDate(QtCore.QDateTime.currentDateTime().date()) self.ui.endDate.setMaximumDate( QtCore.QDateTime.currentDateTime().date()) self.ui.startDate.setMaximumDate( QtCore.QDateTime.currentDateTime().date()) # Disable cancel button self.ui.cancelButton.setDisabled(True) # Create thread object and connect its signals to methods on # this object self.ponderous = DownloadData() self.connect(self.ponderous, QtCore.SIGNAL("updategui(PyQt_PyObject)"), self.appendUpdates) self.connect(self.ponderous, QtCore.SIGNAL("finished()"), self.downloadComplete) QtCore.QObject.connect(self.ui.downloadButton, QtCore.SIGNAL("clicked()"), self.startDownload) QtCore.QObject.connect(self.ui.cancelButton, QtCore.SIGNAL("clicked()"), self.cancelDownload) QtCore.QObject.connect(self.ui.actionExit, QtCore.SIGNAL("triggered()"), sys.exit) self.ui.actionExit.setShortcut("Ctrl+Q") QtCore.QObject.connect(self.ui.actionaboutHakija, QtCore.SIGNAL("triggered()"), self.aboutHakija) def aboutHakija(self): text = """ <html> <head> <title></title> </head> <body> <p> <span style="font-size: 22px;"> <strong>Hakija v1.0.7</strong> </span> <br /> Hakija lets you download End of Day data from NSE. </p> <p>Author : Sahil Gupta</p> <p> <a href="http://www.github.com/sahilgupta/hakija" target="_blank"> Hakija Source Code <br /> </a> </p> <p> </p> </body> </html> """ QtGui.QMessageBox.about(self, "About Hakija", text) # Method called asynchronously by other thread when progress should # be updated def appendUpdates(self, update): print update self.ui.progressUpdate.setText(self.ui.progressUpdate.text() + update + "\n") self.ui.scrollArea.verticalScrollBar().setValue( self.ui.scrollArea.verticalScrollBar().maximum()) def startDownload(self): self.ui.downloadButton.setDisabled(True) self.ui.cancelButton.setEnabled(True) self.ui.startDate.setDisabled(True) self.ui.endDate.setDisabled(True) # Disable checkbox checkability once the download has started self.checkBoxDisability(True) startdate = str(self.ui.startDate.date().toString("dd-MM-yyyy")) enddate = str(self.ui.endDate.date().toString("dd-MM-yyyy")) self.ponderous.goNow(startdate, enddate, self.ui.bhavcopyCB.isChecked(), self.ui.nseniftyCB.isChecked(), self.ui.niftyjuniorCB.isChecked(), self.ui.nse100CB.isChecked(), self.ui.bankniftyCB.isChecked(), self.ui.nsemidcapCB.isChecked(), self.ui.nseitCB.isChecked(), self.ui.nse500CB.isChecked(), self.ui.midcap50CB.isChecked(), self.ui.vixCB.isChecked()) def cancelDownload(self): self.ponderous.stopTask() self.ui.downloadButton.setEnabled(True) self.ui.cancelButton.setDisabled(True) self.ui.startDate.setEnabled(True) self.ui.endDate.setEnabled(True) # Re-enable checkbox checkability once the download has been # cancelled self.checkBoxDisability(False) def checkBoxDisability(self, bool): self.ui.bhavcopyCB.setDisabled(bool) self.ui.nseniftyCB.setDisabled(bool) self.ui.niftyjuniorCB.setDisabled(bool) self.ui.nse100CB.setDisabled(bool) self.ui.bankniftyCB.setDisabled(bool) self.ui.nsemidcapCB.setDisabled(bool) self.ui.nseitCB.setDisabled(bool) self.ui.nse500CB.setDisabled(bool) self.ui.midcap50CB.setDisabled(bool) self.ui.vixCB.setDisabled(bool) def downloadComplete(self): self.ui.downloadButton.setEnabled(True) self.ui.cancelButton.setDisabled(True) self.ui.startDate.setEnabled(True) self.ui.endDate.setEnabled(True) # Re-enable checkbox checkability once the download is complete self.checkBoxDisability(False)
class Hakija(QtGui.QMainWindow): def __init__(self, parent=None): QtGui.QWidget.__init__(self, parent) self.ui = Ui_Hakija() self.ui.setupUi(self) self.ui.endDate.setDate(QtCore.QDateTime.currentDateTime().date()) self.ui.startDate.setDate(QtCore.QDateTime.currentDateTime().date()) self.ui.endDate.setMaximumDate(QtCore.QDateTime.currentDateTime().date()) self.ui.startDate.setMaximumDate(QtCore.QDateTime.currentDateTime().date()) #disable cancel button self.ui.cancelButton.setDisabled(True) # Create thread object and connect its signals to methods on this object self.ponderous = DownloadData() self.connect(self.ponderous, QtCore.SIGNAL("updategui(PyQt_PyObject)"), self.appendUpdates) self.connect(self.ponderous, QtCore.SIGNAL("finished()"), self.downloadComplete) QtCore.QObject.connect(self.ui.downloadButton, QtCore.SIGNAL("clicked()"), self.startDownload) QtCore.QObject.connect(self.ui.cancelButton, QtCore.SIGNAL("clicked()"), self.cancelDownload) QtCore.QObject.connect(self.ui.actionExit, QtCore.SIGNAL('triggered()'), sys.exit) self.ui.actionExit.setShortcut('Ctrl+Q') QtCore.QObject.connect(self.ui.actionaboutHakija, QtCore.SIGNAL('triggered()'), self.aboutHakija) def aboutHakija(self): text = """<html><head><title></title></head><body><p><span style="font-size: 22px;"> <strong>Hakija v1.0.1</strong></span><br />Hakija lets you download End of Day data from NSE.</p> <p>Author : Sahil Gupta</p><p><a href="http://www.github.com/sahilgupta/hakija" target="_blank"> Hakija Source Code<br /></a></p><p> </p></body></html>""" QtGui.QMessageBox.about (self, "About Hakija", text) # Method called asynchronously by other thread when progress should be updated def appendUpdates(self, update): print update self.ui.progressUpdate.setText(self.ui.progressUpdate.text() + update + "\n") self.ui.scrollArea.verticalScrollBar().setValue(self.ui.scrollArea.verticalScrollBar().maximum()) def startDownload(self): self.ui.downloadButton.setDisabled(True) self.ui.cancelButton.setEnabled(True) self.ui.startDate.setDisabled(True) self.ui.endDate.setDisabled(True) #Disable checkbox checkability once the download has started self.checkBoxDisability(True) startdate = str(self.ui.startDate.date().toString("dd-MM-yyyy")) enddate = str(self.ui.endDate.date().toString("dd-MM-yyyy")) self.ponderous.goNow(startdate, enddate, self.ui.bhavcopyCB.isChecked(), self.ui.nseniftyCB.isChecked(), self.ui.niftyjuniorCB.isChecked(), self.ui.nse100CB.isChecked(), self.ui.bankniftyCB.isChecked(), self.ui.nsemidcapCB.isChecked(), self.ui.nseitCB.isChecked(), self.ui.nse500CB.isChecked(), self.ui.midcap50CB.isChecked(), self.ui.vixCB.isChecked()) def cancelDownload(self): self.ponderous.stopTask() self.ui.downloadButton.setEnabled(True) self.ui.cancelButton.setDisabled(True) self.ui.startDate.setEnabled(True) self.ui.endDate.setEnabled(True) #Re-enable checkbox checkability once the download has been cancelled self.checkBoxDisability(False) def checkBoxDisability(self, bool): self.ui.bhavcopyCB.setDisabled(bool) self.ui.nseniftyCB.setDisabled(bool) self.ui.niftyjuniorCB.setDisabled(bool) self.ui.nse100CB.setDisabled(bool) self.ui.bankniftyCB.setDisabled(bool) self.ui.nsemidcapCB.setDisabled(bool) self.ui.nseitCB.setDisabled(bool) self.ui.nse500CB.setDisabled(bool) self.ui.midcap50CB.setDisabled(bool) self.ui.vixCB.setDisabled(bool) def downloadComplete(self): self.ui.downloadButton.setEnabled(True) self.ui.cancelButton.setDisabled(True) self.ui.startDate.setEnabled(True) self.ui.endDate.setEnabled(True) #Re-enable checkbox checkability once the download is complete self.checkBoxDisability(False)