예제 #1
0
    def updateTabLabel(self, data):
        try:
            dock = util.getDockWidget(self.parent())
        except (AttributeError, ):
            return

        caption = self.captions[data] % (self.file_name, )
        ## only both will make the change visible ??
        dock.setTabPageLabel(caption)
        dock.setCaption(caption)


if __name__ == '__main__':
    """ When run from the command line, this pops up the SimpleEditor window
        with the source of this script.

    """
    import profit.device.about as about
    win, app = util.kMain(SimpleEditor, 
                        'Editor Test', 
                         about=about.aboutData)
    try:
        filename = sys.argv[0]
    except (IndexError, ):
        filename = __file__
    win.setupEditor(filename)

    win.show()
    app.exec_loop()
예제 #2
0
        """
        path = []
        item = self.view.selectedItem()
        while item:
            txt = "%s" % (item.text(0),)
            name, ext = os.path.splitext(txt)
            if ext in sourceExts:
                txt = name
            path.append(txt)
            item = item.parent()
        path.reverse()
        self.path = path[1:]

    def printPath(self):
        """ printPath() -> simple pprint

        """
        import pprint

        pprint.pprint(self.path, sys.__stdout__)


if __name__ == "__main__":
    import profit.device.about as about

    win, app = util.kMain(SysPathDialog, "sys.path Browser Test", about=about.aboutData)
    win.show()
    win.connect(win.view, util.sigSelectChanged, win.printPath)
    app.exec_loop()
예제 #3
0
        """
        try:
            self.startScriptName = os.path.expanduser(self.startScriptName)
            startScriptName = file(self.startScriptName, 'r')
        except (IOError, ), ex:
            pass
        else:
            try:
                for line in startScriptName.readlines():
                    self.interpreter.runsource(line)
            except (SyntaxError, ValueError, OverflowError), ex:
                print 'Compiling code in startup script failed: %s' % (ex, )
            except (Exception, ), ex:
                print 'Startup script failure (non-compile): %s' % (ex, )

    def configChanged(self, config):
        config.setGroup(util.groups.fonts)
        font = config.readFontEntry('shell', qt.QFont('fixed'))
        self.setFont(font)

    def close(self):
        base.stdnotee(self, 'stderr', 'stdout')

if __name__ == '__main__':
    import profit.device.about as about
    window, application = util.kMain(InteractiveShell,
                                     'Interactive Python Shell',
                                     about=about.aboutData)
    window.show()
    application.exec_loop()
예제 #4
0
        """
        menu = qt.QPopupMenu(self)
        menu.insertTearOffHandle()
        self.menuBar().insertItem(i18n(label), menu)
        return menu

    def placeOrder(self, contract, order):
        account = self.session.account
        if not account.order_acceptable(order):
            return ## add a msg box
        oid = account.order_id_generator.next()
        account.orders.new_order(order_id=oid, contract=contract, order=order)
        account.connection.place_order(oid, contract, order)


if __name__ == '__main__':
    options = [
        ('nosession', 'Disable initial session construction.'), 
        ('start-tws', 'Launch TWS application on startup.'), 
        ('noembed', 'Disable embedding the TWS application.'),
    ]
    window, application = util.kMain(ProfitDeviceMainWindow, 
                                    'Profit Device', 
                                    about=about.aboutData,
                                    options=options)

    window.connect(application, qt.SIGNAL('kdisplayPaletteChanged()'),
                   window.rebuildGui)
    window.show()
    application.exec_loop()
예제 #5
0
        """
        target= self.sender().target
        dlg = syspath.SysPathDialog(self)
        if dlg.exec_loop() == kdeui.KFontDialog.Accepted:
            path = str.join('.', dlg.path)
            target.setText(path)


    def setConfigWidget(self, page, record):
        """ setConfigWidget(...) -> adds a config record to widget
    
        """
        widgets = self.configWidgets.setdefault(page, [])
        widgets.append(record)


    def getConfigWidgets(self, page):
        """ getConfigWidgets(parent) -> children of parent with a config record
    
        """
        return self.configWidgets.get(page, [])


if __name__ == '__main__':
    import profit.device.about as about
    win, app = util.kMain(ConfigurationDialog, 
                        'Profit Device Configuration', 
                         about=about.aboutData)
    win.show()
    app.exec_loop()
예제 #6
0
            mod_status_sig = qt.PYSIGNAL('modificationStatusChanged')
            self.connect(self.editor, mod_status_sig, self.updateTabLabel)

    def updateTabLabel(self, data):
        try:
            dock = util.getDockWidget(self.parent())
        except (AttributeError, ):
            return

        caption = self.captions[data] % (self.file_name, )
        ## only both will make the change visible ??
        dock.setTabPageLabel(caption)
        dock.setCaption(caption)


if __name__ == '__main__':
    """ When run from the command line, this pops up the SimpleEditor window
        with the source of this script.

    """
    import profit.device.about as about
    win, app = util.kMain(SimpleEditor, 'Editor Test', about=about.aboutData)
    try:
        filename = sys.argv[0]
    except (IndexError, ):
        filename = __file__
    win.setupEditor(filename)

    win.show()
    app.exec_loop()
예제 #7
0
        self.showSummaries()
        self.writeSelected()

    def removeSummary(self, param=None, key=None):
        """ removeSummary() -> remove the label and lcd

        """
        if key is None:
            key = self.context[0]

        label, lcd = self.summaries[key]
        layout = self.layout()

        param = param  # pylint
        del (self.summaries[key])

        for widget in (label, lcd):
            layout.remove(widget)
            self.removeChild(widget)
            widget.close()
        self.writeSelected()


if __name__ == '__main__':
    import profit.device.about as about
    win, app = util.kMain(SummaryLCDFrame,
                          'Profit Device Summary View',
                          about=about.aboutData)
    win.show()
    app.exec_loop()
예제 #8
0
            wid.setRange(currentbid-10, currentbid+10, 0.01, 0.1)
            wid.setValue(currentbid)


    def emitOrder(self):
        """ emitOrder() -> emit an order and a contract

        """
        symbol = '%s' % self.symbolCombo.currentText()
        action = self.actions['%s' % self.actionCombo.currentText()]
        orty = self.types['%s' % self.typeCombo.currentText()]

        quan = self.quantitySpin.value()
        lmt = self.priceEdit.value()
        aux = self.auxEdit.value()

        contract = base.Contract.stock_factory(symbol)
        order = base.Order(quantity=quan, limit_price=lmt, aux_price=aux, 
                           open_close='O', action=action, order_type=orty)
        self.emit(util.sigSubmitOrder, (contract, order))


if __name__ == '__main__':
    import profit.device.about as about
    ttl = 'Profit Device Configuration'
    win, app = util.kMain(OrderDialog, ttl, about=about.aboutData)

    win.configFromSymTable(([100, 'ADBE'], [101, 'AAPL']))
    win.show()
    app.exec_loop()
예제 #9
0
        plotwin.setCaption('%s Test Plot' % (symbol, ))
        plotwin.reparent(self, qt.Qt.WType_TopLevel, qt.QPoint(0, 0), True)
        plotwin.resize(qt.QSize(850, 600))

    def not__closeEvent(self, event):
        base.stdnotee(self, 'stdout', 'stderr')
        for child in self.children():
            child.deleteLater()
        event.accept()

    def write(self, value):
        self.stdoutTextEdit.insert(qt.QString(value))


if __name__ == '__main__':
    win, app = util.kMain(PlotApp, "Plot App", args=sys.argv[0:1])
    win.show()

    try:
        strategyname = sys.argv[1]
    except (IndexError, ):
        strategyname = os.environ.get('PROFITPY_STRATEGY', '')
    win.setStrategy(strategyname)

    try:
        filename = sys.argv[2]
    except (IndexError, ):
        pass
    else:
        win.loadTickers(filename)
예제 #10
0
        """
        path = []
        item = self.view.selectedItem()
        while item:
            txt = '%s' % (item.text(0), )
            name, ext = os.path.splitext(txt)
            if ext in sourceExts:
                txt = name
            path.append(txt)
            item = item.parent()
        path.reverse()
        self.path = path[1:]

    def printPath(self):
        """ printPath() -> simple pprint

        """
        import pprint
        pprint.pprint(self.path, sys.__stdout__)


if __name__ == '__main__':
    import profit.device.about as about
    win, app = util.kMain(SysPathDialog,
                          'sys.path Browser Test',
                          about=about.aboutData)
    win.show()
    win.connect(win.view, util.sigSelectChanged, win.printPath)
    app.exec_loop()
예제 #11
0
    def buildMenu(self, label):
        """ buildMenu(label) -> create and configure a popup menu on the menubar

        """
        menu = qt.QPopupMenu(self)
        menu.insertTearOffHandle()
        self.menuBar().insertItem(i18n(label), menu)
        return menu

    def placeOrder(self, contract, order):
        account = self.session.account
        if not account.order_acceptable(order):
            return  ## add a msg box
        oid = account.order_id_generator.next()
        account.orders.new_order(order_id=oid, contract=contract, order=order)
        account.connection.place_order(oid, contract, order)


if __name__ == "__main__":
    options = [
        ("nosession", "Disable initial session construction."),
        ("start-tws", "Launch TWS application on startup."),
        ("noembed", "Disable embedding the TWS application."),
    ]
    window, application = util.kMain(ProfitDeviceMainWindow, "Profit Device", about=about.aboutData, options=options)

    window.connect(application, qt.SIGNAL("kdisplayPaletteChanged()"), window.rebuildGui)
    window.show()
    application.exec_loop()
예제 #12
0
        plotwin.setCaption('%s Test Plot' % (symbol, ))
        plotwin.reparent(self, qt.Qt.WType_TopLevel, qt.QPoint(0,0), True)
        plotwin.resize(qt.QSize(850, 600))

    def not__closeEvent(self, event):
        base.stdnotee(self, 'stdout', 'stderr')
        for child in self.children():
            child.deleteLater()
        event.accept()

    def write(self, value):
        self.stdoutTextEdit.insert(qt.QString(value))


if __name__ == '__main__':
    win, app = util.kMain(PlotApp, "Plot App", args=sys.argv[0:1])
    win.show()

    try:
        strategyname = sys.argv[1]
    except (IndexError, ):
        strategyname = os.environ.get('PROFITPY_STRATEGY', '')
    win.setStrategy(strategyname)

    try:
        filename = sys.argv[2]
    except (IndexError, ):
        pass
    else:
        win.loadTickers(filename)
예제 #13
0
        try:
            self.startScriptName = os.path.expanduser(self.startScriptName)
            startScriptName = file(self.startScriptName, 'r')
        except (IOError, ), ex:
            pass
        else:
            try:
                for line in startScriptName.readlines():
                    self.interpreter.runsource(line)
            except (SyntaxError, ValueError , OverflowError), ex: 
                print 'Compiling code in startup script failed: %s' % (ex, )
            except (Exception ,), ex:
                print 'Startup script failure (non-compile): %s' % (ex, )

    def configChanged(self, config):
        config.setGroup(util.groups.fonts)
        font = config.readFontEntry('shell', qt.QFont('fixed'))
        self.setFont(font)


    def close(self):
        base.stdnotee(self, 'stderr', 'stdout')

if __name__ == '__main__':
    import profit.device.about as about
    window, application = util.kMain(InteractiveShell, 
                                    'Interactive Python Shell', 
                                    about=about.aboutData)
    window.show()
    application.exec_loop()
예제 #14
0
        """ selectSysPath() -> select an item from sys.path

        """
        target = self.sender().target
        dlg = syspath.SysPathDialog(self)
        if dlg.exec_loop() == kdeui.KFontDialog.Accepted:
            path = str.join('.', dlg.path)
            target.setText(path)

    def setConfigWidget(self, page, record):
        """ setConfigWidget(...) -> adds a config record to widget
    
        """
        widgets = self.configWidgets.setdefault(page, [])
        widgets.append(record)

    def getConfigWidgets(self, page):
        """ getConfigWidgets(parent) -> children of parent with a config record
    
        """
        return self.configWidgets.get(page, [])


if __name__ == '__main__':
    import profit.device.about as about
    win, app = util.kMain(ConfigurationDialog,
                          'Profit Device Configuration',
                          about=about.aboutData)
    win.show()
    app.exec_loop()
예제 #15
0
        self.showSummaries()
        self.writeSelected()

    def removeSummary(self, param=None, key=None):
        """ removeSummary() -> remove the label and lcd

        """
        if key is None:
            key = self.context[0]

        label, lcd = self.summaries[key]
        layout = self.layout()

        param = param # pylint
        del(self.summaries[key])

        for widget in (label, lcd):
            layout.remove(widget)
            self.removeChild(widget)
            widget.close()
        self.writeSelected()


if __name__ == '__main__':
    import profit.device.about as about
    win, app = util.kMain(SummaryLCDFrame, 
                        'Profit Device Summary View', 
                         about=about.aboutData)
    win.show()
    app.exec_loop()