def __init__(self, broker, parent=None):
        super(BrokerWidget, self).__init__(parent)

        self.broker = broker

        self.dataTable = TableView()
        self.dataTable.setModel(self.broker.dataModel)
        self.dataTable.horizontalHeader().setResizeMode(QHeaderView.Stretch)
        #self.dataTable.resizeColumnsToContents()
        dataLabel = QLabel('Price Data')
        dataLabel.setBuddy(self.dataTable)

        dataLayout = QVBoxLayout()

        dataLayout.addWidget(dataLabel)
        dataLayout.addWidget(self.dataTable)

        addButton = QPushButton("&Add Symbol")
        saveDataButton = QPushButton("&Save Data")
        #deleteButton = QPushButton("&Delete")

        buttonLayout = QVBoxLayout()
        buttonLayout.addWidget(addButton)
        buttonLayout.addWidget(saveDataButton)
        buttonLayout.addStretch()

        layout = QHBoxLayout()
        layout.addLayout(dataLayout)
        layout.addLayout(buttonLayout)
        self.setLayout(layout)

        self.connect(addButton, SIGNAL('clicked()'), self.addSubscription)
        self.connect(saveDataButton, SIGNAL('clicked()'), self.saveData)
class BrokerWidget(QWidget):
    def __init__(self, broker, parent=None):
        super(BrokerWidget, self).__init__(parent)


        self.broker = broker


        self.dataTable = TableView()
        self.dataTable.setModel(self.broker.dataModel)
        self.dataTable.horizontalHeader().setResizeMode(QHeaderView.Stretch)
        #self.dataTable.resizeColumnsToContents()
        dataLabel = QLabel('Price Data')
        dataLabel.setBuddy(self.dataTable)


        dataLayout = QVBoxLayout()


        dataLayout.addWidget(dataLabel)
        dataLayout.addWidget(self.dataTable)


        addButton = QPushButton("&Add Symbol")
        saveDataButton = QPushButton("&Save Data")
        #deleteButton = QPushButton("&Delete")


        buttonLayout = QVBoxLayout()
        buttonLayout.addWidget(addButton)
        buttonLayout.addWidget(saveDataButton)
        buttonLayout.addStretch()


        layout = QHBoxLayout()
        layout.addLayout(dataLayout)
        layout.addLayout(buttonLayout)
        self.setLayout(layout)


        self.connect(addButton, SIGNAL('clicked()'), self.addSubscription)
        self.connect(saveDataButton, SIGNAL('clicked()'), self.saveData)
        #self.connect(deleteButton,SIGNAL('clicked()'),self.deleteSubscription)


    def addSubscription(self):
        dialog = AddSubscriptionDlg(self)
        if dialog.exec_():
            self.broker.subscribeStk(str(dialog.symbolEdit.text()), str(dialog.secTypeEdit.text()),
                                     str(dialog.exchangeEdit.text()), str(dialog.currencyEdit.text()))


    def saveData(self):
        """ save data to a .csv file """
        fname = unicode(QFileDialog.getSaveFileName(self, caption="Save data to csv", filter='*.csv'))
        if fname:
            self.broker.saveData(fname)
class BrokerWidget(QWidget):
    def __init__(self, broker, parent=None):
        super(BrokerWidget, self).__init__(parent)

        self.broker = broker

        self.dataTable = TableView()
        self.dataTable.setModel(self.broker.dataModel)
        self.dataTable.horizontalHeader().setResizeMode(QHeaderView.Stretch)
        #self.dataTable.resizeColumnsToContents()
        dataLabel = QLabel('Price Data')
        dataLabel.setBuddy(self.dataTable)

        dataLayout = QVBoxLayout()

        dataLayout.addWidget(dataLabel)
        dataLayout.addWidget(self.dataTable)

        addButton = QPushButton("&Add Symbol")
        saveDataButton = QPushButton("&Save Data")
        #deleteButton = QPushButton("&Delete")

        buttonLayout = QVBoxLayout()
        buttonLayout.addWidget(addButton)
        buttonLayout.addWidget(saveDataButton)
        buttonLayout.addStretch()

        layout = QHBoxLayout()
        layout.addLayout(dataLayout)
        layout.addLayout(buttonLayout)
        self.setLayout(layout)

        self.connect(addButton, SIGNAL('clicked()'), self.addSubscription)
        self.connect(saveDataButton, SIGNAL('clicked()'), self.saveData)
        #self.connect(deleteButton,SIGNAL('clicked()'),self.deleteSubscription)

    def addSubscription(self):
        dialog = AddSubscriptionDlg(self)
        if dialog.exec_():
            self.broker.subscribeStk(str(dialog.symbolEdit.text()),
                                     str(dialog.secTypeEdit.text()),
                                     str(dialog.exchangeEdit.text()),
                                     str(dialog.currencyEdit.text()))

    def saveData(self):
        """ save data to a .csv file """
        fname = unicode(
            QFileDialog.getSaveFileName(self,
                                        caption="Save data to csv",
                                        filter='*.csv'))
        if fname:
            self.broker.saveData(fname)
 def __init__(self,broker,parent = None ):
     super(BrokerWidget,self).__init__(parent)
     
     self.broker = broker
     
     self.dataTable = TableView()
     self.dataTable.setModel(self.broker.dataModel)
     self.dataTable.horizontalHeader().setResizeMode(QHeaderView.Stretch)
     #self.dataTable.resizeColumnsToContents()
     dataLabel = QLabel('Price Data')
     dataLabel.setBuddy(self.dataTable)
     
     dataLayout = QVBoxLayout()
     
     dataLayout.addWidget(dataLabel)
     dataLayout.addWidget(self.dataTable)
     
     
     addButton = QPushButton("&Add Symbol")
     saveDataButton = QPushButton("&Save Data")
     #deleteButton = QPushButton("&Delete")
     
     buttonLayout = QVBoxLayout()
     buttonLayout.addWidget(addButton)
     buttonLayout.addWidget(saveDataButton)
     buttonLayout.addStretch()
     
     layout = QHBoxLayout()
     layout.addLayout(dataLayout)
     layout.addLayout(buttonLayout)
     self.setLayout(layout)
     
     self.connect(addButton,SIGNAL('clicked()'),self.addSubscription)
     self.connect(saveDataButton,SIGNAL('clicked()'),self.saveData)